diff --git a/circuits.go b/circuits.go index 4411387..4919660 100644 --- a/circuits.go +++ b/circuits.go @@ -96,11 +96,10 @@ type Circuits struct { UpstreamSpeed int `json:"upstream_speed"` XconnectID string `json:"xconnect_id"` } `json:"termination_z"` - Comments string `json:"comments"` - Tags []string `json:"tags"` - CustomFields struct { - } `json:"custom_fields"` - Created string `json:"created"` - LastUpdated time.Time `json:"last_updated"` + Comments string `json:"comments"` + Tags []string `json:"tags"` + CustomFields struct{} `json:"custom_fields"` + Created string `json:"created"` + LastUpdated time.Time `json:"last_updated"` } `json:"results"` } diff --git a/clusters.go b/clusters.go index 675859d..3f591dc 100644 --- a/clusters.go +++ b/clusters.go @@ -114,7 +114,7 @@ type ClusterFilter struct { Tag string `schema:"tag,omitempty"` } -const clustersPath = "/virtualization/clusters" +const clustersPath = virtualizationPath + "/clusters" // List clusters. ClusterFilter is used to list based on filter queries. func (s *ClustersService) List(ctx context.Context, f *ClusterFilter) (*Clusters, error) { diff --git a/device_roles.go b/device_roles.go index 7bb75c2..8e93041 100644 --- a/device_roles.go +++ b/device_roles.go @@ -43,7 +43,7 @@ type DeviceRoleFilter struct { Q string `schema:"q,omitempty"` } -const deviceRolesPath = "/dcim/device-roles" +const deviceRolesPath = dcimPath + "/device-roles" // List deviceroles. DeviceRoleFilter is used to list based on filter queries. func (s *DeviceRolesService) List(ctx context.Context, f *DeviceRoleFilter) (*DeviceRoles, error) { diff --git a/device_types.go b/device_types.go index 2a3f2ca..b903389 100644 --- a/device_types.go +++ b/device_types.go @@ -70,7 +70,7 @@ type DeviceTypeFilter struct { Tag string `schema:"tag,omitempty"` } -const deviceTypesPath = "/dcim/device-types" +const deviceTypesPath = dcimPath + "/device-types" // List device-types. DeviceTypeFilter is used to list based on filter queries. func (s *DeviceTypesService) List(ctx context.Context, f *DeviceTypeFilter) (*DeviceTypes, error) { diff --git a/devices.go b/devices.go index 6b7ed0e..efb1fca 100644 --- a/devices.go +++ b/devices.go @@ -310,7 +310,7 @@ type DeviceFilter struct { Tag string `schema:"tag,omitempty"` } -const devicesPath = "/dcim/devices" +const devicesPath = dcimPath + "/devices" // List devices. DeviceFilter is used to list based on filter queries. func (s *DevicesService) List(ctx context.Context, f *DeviceFilter) (*Devices, error) { diff --git a/interfaces.go b/interfaces.go index 2be934e..c29f434 100644 --- a/interfaces.go +++ b/interfaces.go @@ -112,7 +112,7 @@ type InterfaceFilter struct { VLAN string `schema:"vlan,omitempty"` } -const interfacesPath = "/dcim/interfaces" +const interfacesPath = dcimPath + "/interfaces" // List devices. DeviceFilter is used to list based on filter queries. func (s *InterfacesService) List(ctx context.Context, f *InterfaceFilter) (*Interfaces, error) { diff --git a/inventory.go b/inventory.go index 86173bc..178fca2 100644 --- a/inventory.go +++ b/inventory.go @@ -58,7 +58,7 @@ type InventoryItemFilter struct { Device string `schema:"device"` } -const inventoryItemsPath = "/dcim/inventory-items" +const inventoryItemsPath = dcimPath + "/inventory-items" // List inventory-items. InventoryItemFilter is used to list based on filter queries. func (s *InventoryItemsService) List(ctx context.Context, f *InventoryItemFilter) (*InventoryItems, error) { diff --git a/netbox.go b/netbox.go index 241aa26..8a10a33 100644 --- a/netbox.go +++ b/netbox.go @@ -105,6 +105,16 @@ type service struct { client *Client } +const ( + circuitsPath = "/circuits" + dcimPath = "/dcim" + extrasPath = "/extras" + ipamPath = "/ipam" + tenancyPath = "/tenancy" + usersPath = "/users" + virtualizationPath = "/virtualization" +) + // NetBoxSessionKey sets the session key for secrets retrieval type NetBoxSessionKey struct { XSessionKey string `json:"session_key"` diff --git a/prefixes.go b/prefixes.go index 23a9cad..ee77658 100644 --- a/prefixes.go +++ b/prefixes.go @@ -126,7 +126,7 @@ type PrefixFilter struct { Status string `schema:"status,omitempty"` } -const prefixesPath = "/ipam/prefixes" +const prefixesPath = ipamPath + "/prefixes" // List prefixes. PrefixFilter is used to list based on filter queries. func (s *PrefixesService) List(ctx context.Context, f *PrefixFilter) (*Prefixes, error) { diff --git a/rear_ports.go b/rear_ports.go index e65b788..eeff745 100644 --- a/rear_ports.go +++ b/rear_ports.go @@ -52,7 +52,7 @@ type RearPortFilter struct { Device string `schema:"device,omitempty"` } -const rearPortsPath = "/dcim/rear-ports" +const rearPortsPath = dcimPath + "/rear-ports" // List rearports. RearPortFilter is used to list based on filter queries. func (s *RearPortsService) List(ctx context.Context, f *RearPortFilter) (*RearPorts, error) { diff --git a/secrets.go b/secrets.go index 08534c0..96f9913 100644 --- a/secrets.go +++ b/secrets.go @@ -65,7 +65,7 @@ type SecretFilter struct { Tag string `schema:"tag,omitempty"` } -const secretsPath = "/secrets/secrets" +const secretsPath = "/secrets" // List secrets. SecretsFilter is used to list based on filter queries. func (s *SecretsService) List(ctx context.Context, f *SecretFilter) (*Secrets, error) { @@ -87,7 +87,7 @@ func (s *SecretsService) List(ctx context.Context, f *SecretFilter) (*Secrets, e } query = form.Encode() - req, err = s.client.newRequest(ctx, "GET", secretsPath, query, nil) + req, err = s.client.newRequest(ctx, "GET", secretsPath+"/secrets", query, nil) if err != nil { return &secrets, err } diff --git a/site_groups.go b/site_groups.go index 4db214b..d59fd57 100644 --- a/site_groups.go +++ b/site_groups.go @@ -60,7 +60,7 @@ type SiteGroupFilter struct { Tag string `schema:"tag,omitempty"` } -const siteGroupsPath = "/dcim/site-groups" +const siteGroupsPath = dcimPath + "/site-groups" // List sitegroups. SiteGroupFilter is used to list based on filter queries. func (s *SiteGroupsService) List(ctx context.Context, f *SiteGroupFilter) (*SiteGroups, error) { diff --git a/sites.go b/sites.go index fd747dd..7490e1b 100644 --- a/sites.go +++ b/sites.go @@ -101,7 +101,7 @@ type SiteFilter struct { Tag string `schema:"tag,omitempty"` } -const sitesPath = "/dcim/sites" +const sitesPath = dcimPath + "/sites" // List sites. SiteFilter is used to list based on filter queries. func (s *SitesService) List(ctx context.Context, f *SiteFilter) (*Sites, error) { diff --git a/tenants.go b/tenants.go index 76732ca..9663712 100644 --- a/tenants.go +++ b/tenants.go @@ -75,7 +75,7 @@ type TenantFilter struct { Tag string `schema:"tag,omitempty"` } -const tenantsPath = "/tenancy/tenants" +const tenantsPath = tenancyPath + "/tenants" // List tenants. TenantFilter is used to list based on filter queries. func (s *TenantsService) List(ctx context.Context, f *TenantFilter) (*Tenants, error) { diff --git a/virtual_machines.go b/virtual_machines.go index 83e5918..cda07af 100644 --- a/virtual_machines.go +++ b/virtual_machines.go @@ -85,7 +85,7 @@ type NewVirtualMachine struct { LastUpdated time.Time `json:"last_updated"` } -const virtualMachinesPath = "/virtualization/virtual-machines" +const virtualMachinesPath = virtualizationPath + "/virtual-machines" // Create a virtual-machine func (s *VirtualMachinesService) Create(ctx context.Context, c *NewVirtualMachine) error { diff --git a/vlans.go b/vlans.go index 1778bf4..991da26 100644 --- a/vlans.go +++ b/vlans.go @@ -102,7 +102,7 @@ type VLANFilter struct { Tag string `schema:"tag,omitempty"` } -const vlansPath = "/ipam/vlans" +const vlansPath = ipamPath + "/vlans" // List vlans. VLANFilter is used to list based on filter queries. func (s *VLANsService) List(ctx context.Context, f *VLANFilter) (*VLANs, error) { diff --git a/vrfs.go b/vrfs.go index c507ff8..de200c6 100644 --- a/vrfs.go +++ b/vrfs.go @@ -68,7 +68,7 @@ type VRFFilter struct { Tag string `schema:"tag,omitempty"` } -const vrfsPath = "/ipam/vrfs" +const vrfsPath = ipamPath + "/vrfs" // List vrfs. VRFFilter is used to list based on filter queries. func (s *VRFsService) List(ctx context.Context, f *VRFFilter) (*VRFs, error) {