Update netbox dto's
This commit is contained in:
parent
d107d2f742
commit
d98de3282c
4 changed files with 111 additions and 54 deletions
|
@ -1,2 +1,5 @@
|
||||||
[core]
|
[core]
|
||||||
sshCommand = "/usr/bin/ssh"
|
sshCommand = "/usr/bin/ssh"
|
||||||
|
[user]
|
||||||
|
name = Kalle Carlbark
|
||||||
|
email = kalle.carlbark@kcbark.net
|
||||||
|
|
|
@ -13,22 +13,31 @@ type ClusterTypesService service
|
||||||
|
|
||||||
// ClusterTypes is used to list cluster types
|
// ClusterTypes is used to list cluster types
|
||||||
type ClusterTypes struct {
|
type ClusterTypes struct {
|
||||||
Next interface{} `json:"next"`
|
Next interface{} `json:"next"`
|
||||||
Previous interface{} `json:"previous"`
|
Previous interface{} `json:"previous"`
|
||||||
Results []struct {
|
Results []ClusterType `json:"results"`
|
||||||
CustomFields struct{} `json:"custom_fields"`
|
Count int `json:"count"`
|
||||||
LastUpdated time.Time `json:"last_updated"`
|
}
|
||||||
Display string `json:"display"`
|
|
||||||
Slug string `json:"slug"`
|
type ClusterType struct {
|
||||||
Description string `json:"description"`
|
CustomFields struct{} `json:"custom_fields"`
|
||||||
URL string `json:"url"`
|
LastUpdated time.Time `json:"last_updated"`
|
||||||
Created string `json:"created"`
|
Display string `json:"display"`
|
||||||
Name string `json:"name"`
|
Slug string `json:"slug"`
|
||||||
Tags []interface{} `json:"tags"`
|
Description string `json:"description"`
|
||||||
ID int `json:"id"`
|
URL string `json:"url"`
|
||||||
ClusterCount int `json:"cluster_count"`
|
Created string `json:"created"`
|
||||||
} `json:"results"`
|
Name string `json:"name"`
|
||||||
Count int `json:"count"`
|
Tags []struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Display string `json:"display"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
Color string `json:"color"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
} `json:"tags"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
ClusterCount int `json:"cluster_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClusterTypeFilter is used to filter out VirtualizationClusters
|
// ClusterTypeFilter is used to filter out VirtualizationClusters
|
||||||
|
@ -52,7 +61,7 @@ type ClusterTypeFilter struct {
|
||||||
Limit int64 `schema:"limit,omitempty"`
|
Limit int64 `schema:"limit,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const clusterTypesPath = "/cluster-types/"
|
const clusterTypesPath = virtualizationPath + "/cluster-types/"
|
||||||
|
|
||||||
// List cluster types. ClusterTypeFilter is used to list based on filter queries.
|
// List cluster types. ClusterTypeFilter is used to list based on filter queries.
|
||||||
func (s *ClusterTypesService) List(ctx context.Context, f *ClusterTypeFilter) (*ClusterTypes, error) {
|
func (s *ClusterTypesService) List(ctx context.Context, f *ClusterTypeFilter) (*ClusterTypes, error) {
|
||||||
|
@ -82,3 +91,23 @@ func (s *ClusterTypesService) List(ctx context.Context, f *ClusterTypeFilter) (*
|
||||||
|
|
||||||
return &clusterTypes, nil
|
return &clusterTypes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get cluster type.
|
||||||
|
func (s *ClusterTypesService) Get(ctx context.Context, id string) (*ClusterTypes, error) {
|
||||||
|
var clusterTypes ClusterTypes
|
||||||
|
var query string
|
||||||
|
var req *http.Request
|
||||||
|
var err error
|
||||||
|
|
||||||
|
req, err = s.client.newRequest(ctx, "GET", clusterTypesPath+id+"/", query, nil)
|
||||||
|
if err != nil {
|
||||||
|
return &clusterTypes, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = s.client.do(req, &clusterTypes)
|
||||||
|
if err != nil {
|
||||||
|
return &clusterTypes, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &clusterTypes, nil
|
||||||
|
}
|
||||||
|
|
|
@ -4,36 +4,48 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/schema"
|
"github.com/gorilla/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeviceRolesService service
|
type DeviceRolesService service
|
||||||
|
|
||||||
|
// DeviceRoles is used to list device roles
|
||||||
type DeviceRoles struct {
|
type DeviceRoles struct {
|
||||||
Count int `json:"count"`
|
|
||||||
Next string `json:"next"`
|
Next string `json:"next"`
|
||||||
Previous string `json:"previous"`
|
Previous string `json:"previous"`
|
||||||
Results []DeviceRole `json:"results"`
|
Results []DeviceRole `json:"results"`
|
||||||
|
Count int `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeviceRole is a role of a device
|
||||||
type DeviceRole struct {
|
type DeviceRole struct {
|
||||||
ID int `json:"id"`
|
LastUpdated time.Time `json:"last_updated"`
|
||||||
URL string `json:"url"`
|
CustomFields struct{} `json:"custom_fields"`
|
||||||
Name string `json:"name"`
|
URL string `json:"url"`
|
||||||
Slug string `json:"slug"`
|
Display string `json:"display"`
|
||||||
Color string `json:"color"`
|
Slug string `json:"slug"`
|
||||||
VMRole bool `json:"vm_role"`
|
Color string `json:"color"`
|
||||||
Description string `json:"description"`
|
Created string `json:"created"`
|
||||||
DeviceCount int `json:"device_count"`
|
Description string `json:"description"`
|
||||||
VirtualmachineCount int `json:"virtualmachine_count"`
|
Name string `json:"name"`
|
||||||
|
Tags []struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Display string `json:"display"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
Color string `json:"color"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
} `json:"tags"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
DeviceCount int `json:"device_count"`
|
||||||
|
VirtualMachineCount int `json:"virtualmachine_count"`
|
||||||
|
VMRole bool `json:"vm_role"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeviceTypeFilter is used to filter dcim_device_roles query to the Netbox API
|
// DeviceTypeFilter is used to filter dcim_device_roles query to the Netbox API
|
||||||
type DeviceRoleFilter struct {
|
type DeviceRoleFilter struct {
|
||||||
Offset int64 `schema:"offset,omitempty"`
|
|
||||||
Limit int64 `schema:"limit,omitempty"`
|
|
||||||
|
|
||||||
// User specific filters
|
// User specific filters
|
||||||
ID string `schema:"id,omitempty"`
|
ID string `schema:"id,omitempty"`
|
||||||
Name string `schema:"name,omitempty"`
|
Name string `schema:"name,omitempty"`
|
||||||
|
@ -41,6 +53,9 @@ type DeviceRoleFilter struct {
|
||||||
Color string `schema:"color,omitempty"`
|
Color string `schema:"color,omitempty"`
|
||||||
VMRole string `schema:"vm_role,omitempty"`
|
VMRole string `schema:"vm_role,omitempty"`
|
||||||
Q string `schema:"q,omitempty"`
|
Q string `schema:"q,omitempty"`
|
||||||
|
|
||||||
|
Offset int64 `schema:"offset,omitempty"`
|
||||||
|
Limit int64 `schema:"limit,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceRolesPath = dcimPath + "/device-roles"
|
const deviceRolesPath = dcimPath + "/device-roles"
|
||||||
|
|
58
platforms.go
58
platforms.go
|
@ -15,29 +15,39 @@ type Platforms struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
Next interface{} `json:"next"`
|
Next interface{} `json:"next"`
|
||||||
Previous interface{} `json:"previous"`
|
Previous interface{} `json:"previous"`
|
||||||
Results []struct {
|
Results []Platform `json:"results"`
|
||||||
ID int `json:"id"`
|
}
|
||||||
URL string `json:"url"`
|
|
||||||
Display string `json:"display"`
|
type Platform struct {
|
||||||
Name string `json:"name"`
|
ID int `json:"id"`
|
||||||
Slug string `json:"slug"`
|
URL string `json:"url"`
|
||||||
Manufacturer struct {
|
Display string `json:"display"`
|
||||||
ID int `json:"id"`
|
Name string `json:"name"`
|
||||||
URL string `json:"url"`
|
Slug string `json:"slug"`
|
||||||
Display string `json:"display"`
|
Manufacturer struct {
|
||||||
Name string `json:"name"`
|
ID int `json:"id"`
|
||||||
Slug string `json:"slug"`
|
URL string `json:"url"`
|
||||||
} `json:"manufacturer"`
|
Display string `json:"display"`
|
||||||
NapalmDriver string `json:"napalm_driver"`
|
Name string `json:"name"`
|
||||||
NapalmArgs interface{} `json:"napalm_args"`
|
Slug string `json:"slug"`
|
||||||
Description string `json:"description"`
|
DevicetypeCount int `json:"devicetype_count"`
|
||||||
Tags []interface{} `json:"tags"`
|
} `json:"manufacturer"`
|
||||||
CustomFields struct{} `json:"custom_fields"`
|
NapalmDriver string `json:"napalm_driver"`
|
||||||
Created string `json:"created"`
|
NapalmArgs string `json:"napalm_args"`
|
||||||
LastUpdated time.Time `json:"last_updated"`
|
Description string `json:"description"`
|
||||||
DeviceCount int `json:"device_count"`
|
Tags []struct {
|
||||||
VirtualmachineCount int `json:"virtualmachine_count"`
|
ID int `json:"id"`
|
||||||
} `json:"results"`
|
URL string `json:"url"`
|
||||||
|
Display string `json:"display"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
Color string `json:"color"`
|
||||||
|
} `json:"tags"`
|
||||||
|
CustomFields struct{} `json:"custom_fields"`
|
||||||
|
Created string `json:"created"`
|
||||||
|
LastUpdated time.Time `json:"last_updated"`
|
||||||
|
DeviceCount int `json:"device_count"`
|
||||||
|
VirtualmachineCount int `json:"virtualmachine_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlatformFilter is used to filter out platforms
|
// PlatformFilter is used to filter out platforms
|
||||||
|
@ -61,7 +71,7 @@ type PlatformFilter struct {
|
||||||
Limit int64 `schema:"limit,omitempty"`
|
Limit int64 `schema:"limit,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const platformsPath = "/platforms/"
|
const platformsPath = dcimPath + "/platforms/"
|
||||||
|
|
||||||
// List platforms. PlatformFilter is used to list based on filter queries.
|
// List platforms. PlatformFilter is used to list based on filter queries.
|
||||||
func (s *PlatformsService) List(ctx context.Context, f *PlatformFilter) (*Platforms, error) {
|
func (s *PlatformsService) List(ctx context.Context, f *PlatformFilter) (*Platforms, error) {
|
||||||
|
|
Loading…
Reference in a new issue