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
|
||||||
|
|
|
@ -15,7 +15,11 @@ type ClusterTypesService service
|
||||||
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"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClusterType struct {
|
||||||
CustomFields struct{} `json:"custom_fields"`
|
CustomFields struct{} `json:"custom_fields"`
|
||||||
LastUpdated time.Time `json:"last_updated"`
|
LastUpdated time.Time `json:"last_updated"`
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
|
@ -24,11 +28,16 @@ type ClusterTypes struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Created string `json:"created"`
|
Created string `json:"created"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Tags []interface{} `json:"tags"`
|
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"`
|
ID int `json:"id"`
|
||||||
ClusterCount int `json:"cluster_count"`
|
ClusterCount int `json:"cluster_count"`
|
||||||
} `json:"results"`
|
|
||||||
Count int `json:"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"`
|
||||||
|
CustomFields struct{} `json:"custom_fields"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
|
Display string `json:"display"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
Color string `json:"color"`
|
||||||
|
Created string `json:"created"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Tags []struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Display string `json:"display"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
VMRole bool `json:"vm_role"`
|
ID int `json:"id"`
|
||||||
Description string `json:"description"`
|
} `json:"tags"`
|
||||||
|
ID int `json:"id"`
|
||||||
DeviceCount int `json:"device_count"`
|
DeviceCount int `json:"device_count"`
|
||||||
VirtualmachineCount int `json:"virtualmachine_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"
|
||||||
|
|
20
platforms.go
20
platforms.go
|
@ -15,7 +15,10 @@ 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"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Platform struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
|
@ -27,17 +30,24 @@ type Platforms struct {
|
||||||
Display string `json:"display"`
|
Display string `json:"display"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
|
DevicetypeCount int `json:"devicetype_count"`
|
||||||
} `json:"manufacturer"`
|
} `json:"manufacturer"`
|
||||||
NapalmDriver string `json:"napalm_driver"`
|
NapalmDriver string `json:"napalm_driver"`
|
||||||
NapalmArgs interface{} `json:"napalm_args"`
|
NapalmArgs string `json:"napalm_args"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Tags []interface{} `json:"tags"`
|
Tags []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
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"`
|
CustomFields struct{} `json:"custom_fields"`
|
||||||
Created string `json:"created"`
|
Created string `json:"created"`
|
||||||
LastUpdated time.Time `json:"last_updated"`
|
LastUpdated time.Time `json:"last_updated"`
|
||||||
DeviceCount int `json:"device_count"`
|
DeviceCount int `json:"device_count"`
|
||||||
VirtualmachineCount int `json:"virtualmachine_count"`
|
VirtualmachineCount int `json:"virtualmachine_count"`
|
||||||
} `json:"results"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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