Add Device to its own type

This commit is contained in:
Kalle Carlbark 2021-05-24 15:10:20 +02:00
parent 3eb210c9e5
commit 8383ef9bb9
No known key found for this signature in database
GPG key ID: 5E4BAB01A57CDD62

View file

@ -17,158 +17,160 @@ import (
// DcimDevicesList is used for Netbox dcim_device_list return struct
type DcimDevicesList struct {
Count int `json:"count"`
Next string `json:"next"`
Previous string `json:"previous"`
Results []struct {
Count int `json:"count"`
Next string `json:"next"`
Previous string `json:"previous"`
Results []Device `json:"results"`
}
type Device struct {
ID int `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
DeviceType struct {
ID int `json:"id"`
URL string `json:"url"`
Manufacturer struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
DevicetypeCount int `json:"devicetype_count"`
} `json:"manufacturer"`
Model string `json:"model"`
Slug string `json:"slug"`
DisplayName string `json:"display_name"`
DeviceCount int `json:"device_count"`
} `json:"device_type"`
DeviceRole struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
DeviceCount int `json:"device_count"`
VirtualmachineCount int `json:"virtualmachine_count"`
} `json:"device_role"`
Tenant struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
} `json:"tenant"`
Platform struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
DeviceCount int `json:"device_count"`
VirtualmachineCount int `json:"virtualmachine_count"`
} `json:"platform"`
Serial string `json:"serial"`
AssetTag string `json:"asset_tag"`
Site struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
} `json:"site"`
Rack struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
DeviceType struct {
ID int `json:"id"`
URL string `json:"url"`
Manufacturer struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
DevicetypeCount int `json:"devicetype_count"`
} `json:"manufacturer"`
Model string `json:"model"`
Slug string `json:"slug"`
DisplayName string `json:"display_name"`
DeviceCount int `json:"device_count"`
} `json:"device_type"`
DeviceRole struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
DeviceCount int `json:"device_count"`
VirtualmachineCount int `json:"virtualmachine_count"`
} `json:"device_role"`
Tenant struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
} `json:"tenant"`
Platform struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
DeviceCount int `json:"device_count"`
VirtualmachineCount int `json:"virtualmachine_count"`
} `json:"platform"`
Serial string `json:"serial"`
AssetTag string `json:"asset_tag"`
Site struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
} `json:"site"`
Rack struct {
DeviceCount int `json:"device_count"`
} `json:"rack"`
Position int `json:"position"`
Face struct {
Label string `json:"label"`
Value string `json:"value"`
} `json:"face"`
ParentDevice struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
} `json:"parent_device"`
Status struct {
Label string `json:"label"`
Value string `json:"value"`
} `json:"status"`
PrimaryIP struct {
ID int `json:"id"`
URL string `json:"url"`
Family int `json:"family"`
Address string `json:"address"`
} `json:"primary_ip"`
PrimaryIP4 struct {
ID int `json:"id"`
URL string `json:"url"`
Family int `json:"family"`
Address string `json:"address"`
} `json:"primary_ip4"`
PrimaryIP6 struct {
ID int `json:"id"`
URL string `json:"url"`
Family int `json:"family"`
Address string `json:"address"`
} `json:"primary_ip6"`
Cluster struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
VirtualmachineCount int `json:"virtualmachine_count"`
} `json:"cluster"`
VirtualChassis struct {
ID int `json:"id"`
URL string `json:"url"`
Master struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
DeviceCount int `json:"device_count"`
} `json:"rack"`
Position int `json:"position"`
Face struct {
} `json:"master"`
MemberCount int `json:"member_count"`
} `json:"virtual_chassis"`
VcPosition int `json:"vc_position"`
VcPriority int `json:"vc_priority"`
Comments string `json:"comments"`
// LocalContextData string `json:"local_context_data"`
Tags []struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
Color string `json:"color"`
} `json:"tags"`
CustomFields struct {
DcimDeviceBelongsToService struct {
Value int `json:"value"`
Label string `json:"label"`
Value string `json:"value"`
} `json:"face"`
ParentDevice struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
} `json:"parent_device"`
Status struct {
} `json:"dcim_device_belongs_to_service"`
DcimDeviceCendotid string `json:"dcim_device_cendotid"`
DcimDeviceExposedToInternet struct {
Value int `json:"value"`
Label string `json:"label"`
Value string `json:"value"`
} `json:"status"`
PrimaryIP struct {
ID int `json:"id"`
URL string `json:"url"`
Family int `json:"family"`
Address string `json:"address"`
} `json:"primary_ip"`
PrimaryIP4 struct {
ID int `json:"id"`
URL string `json:"url"`
Family int `json:"family"`
Address string `json:"address"`
} `json:"primary_ip4"`
PrimaryIP6 struct {
ID int `json:"id"`
URL string `json:"url"`
Family int `json:"family"`
Address string `json:"address"`
} `json:"primary_ip6"`
Cluster struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
VirtualmachineCount int `json:"virtualmachine_count"`
} `json:"cluster"`
VirtualChassis struct {
ID int `json:"id"`
URL string `json:"url"`
Master struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
} `json:"master"`
MemberCount int `json:"member_count"`
} `json:"virtual_chassis"`
VcPosition int `json:"vc_position"`
VcPriority int `json:"vc_priority"`
Comments string `json:"comments"`
// LocalContextData string `json:"local_context_data"`
Tags []struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
Slug string `json:"slug"`
Color string `json:"color"`
} `json:"tags"`
CustomFields struct {
DcimDeviceBelongsToService struct {
Value int `json:"value"`
Label string `json:"label"`
} `json:"dcim_device_belongs_to_service"`
DcimDeviceCendotid string `json:"dcim_device_cendotid"`
DcimDeviceExposedToInternet struct {
Value int `json:"value"`
Label string `json:"label"`
} `json:"dcim_device_exposed_to_internet"`
DcimDeviceImportOsVersion bool `json:"dcim_device_import_os_version"`
DcimDeviceOsVersion interface{} `json:"dcim_device_os_version"`
DcimDevicesImportInterfaces interface{} `json:"dcim_devices_import_interfaces"`
DcimDeviceImportvlan bool `json:"dcim_device_importvlan"`
DcimDeviceL2Domain interface{} `json:"dcim_device_l2domain"`
DcimDeviceCountTrunkVlans interface{} `json:"dcim_device_count_trunk_vlans"`
DcimDeviceLogicalportsDeviceLimit interface{} `json:"dcim_device_logicalports_device_limit"`
DcimDeviceLogicalportsActiveNum interface{} `json:"dcim_device_logicalports_active_num"`
DcimDeviceLogicalportsConfiguredNum interface{} `json:"dcim_device_logicalports_configured_num"`
DcimDeviceCountTimesLastRun interface{} `json:"dcim_device_count_times_last_run"`
DcimDeviceImportVrfs interface{} `json:"dcim_device_import_vrfs"`
DcimDeviceVrfTag interface{} `json:"dcim_device_vrf_tag"`
DcimDevicePod interface{} `json:"dcim_device_pod"`
} `json:"custom_fields"`
ConfigContext struct {
AdditionalProp1 string `json:"additionalProp1"`
AdditionalProp2 string `json:"additionalProp2"`
AdditionalProp3 string `json:"additionalProp3"`
} `json:"config_context"`
Created string `json:"created"`
LastUpdated time.Time `json:"last_updated"`
} `json:"results"`
} `json:"dcim_device_exposed_to_internet"`
DcimDeviceImportOsVersion bool `json:"dcim_device_import_os_version"`
DcimDeviceOsVersion interface{} `json:"dcim_device_os_version"`
DcimDevicesImportInterfaces interface{} `json:"dcim_devices_import_interfaces"`
DcimDeviceImportvlan bool `json:"dcim_device_importvlan"`
DcimDeviceL2Domain interface{} `json:"dcim_device_l2domain"`
DcimDeviceCountTrunkVlans interface{} `json:"dcim_device_count_trunk_vlans"`
DcimDeviceLogicalportsDeviceLimit interface{} `json:"dcim_device_logicalports_device_limit"`
DcimDeviceLogicalportsActiveNum interface{} `json:"dcim_device_logicalports_active_num"`
DcimDeviceLogicalportsConfiguredNum interface{} `json:"dcim_device_logicalports_configured_num"`
DcimDeviceCountTimesLastRun interface{} `json:"dcim_device_count_times_last_run"`
DcimDeviceImportVrfs interface{} `json:"dcim_device_import_vrfs"`
DcimDeviceVrfTag interface{} `json:"dcim_device_vrf_tag"`
DcimDevicePod interface{} `json:"dcim_device_pod"`
} `json:"custom_fields"`
ConfigContext struct {
AdditionalProp1 string `json:"additionalProp1"`
AdditionalProp2 string `json:"additionalProp2"`
AdditionalProp3 string `json:"additionalProp3"`
} `json:"config_context"`
Created string `json:"created"`
LastUpdated time.Time `json:"last_updated"`
}
type DcimCreateDevice struct {