changed NetBoxAPI struct to directly import NetBoxAPI client

This commit is contained in:
Nils Stinnesbeck 2023-04-26 07:29:35 +02:00
parent b314297c97
commit cb4e104962
Signed by: nils
GPG Key ID: 9AEBF097A4042590
4 changed files with 11 additions and 11 deletions

View File

@ -11,9 +11,9 @@ import (
// NetBoxAPI is the type we use to add custom functions // NetBoxAPI is the type we use to add custom functions
type NetBoxAPI struct { type NetBoxAPI struct {
API client.NetBoxAPI client.NetBoxAPI // API of NetBox
Token string Token string // Token used to access the NetBox API
URL string URL string // URL of this NetBox instance
} }
// NewNetBoxClient returns a client to NetBox at the given url, // NewNetBoxClient returns a client to NetBox at the given url,
@ -32,7 +32,7 @@ func NewNetBoxClient(token string, url string) NetBoxAPI {
// create a new variable for our custom functions // create a new variable for our custom functions
nb := NetBoxAPI{ nb := NetBoxAPI{
API: *n, NetBoxAPI: *n,
Token: token, Token: token,
URL: url, URL: url,
} }

View File

@ -28,7 +28,7 @@ func (nb NetBoxAPI) GetDevices(param dcim.DcimDevicesListParams) ([]*models.Devi
} }
// get devices // get devices
devices, err := nb.API.Dcim.DcimDevicesList(&param, nil) devices, err := nb.Dcim.DcimDevicesList(&param, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -28,7 +28,7 @@ func (nb NetBoxAPI) GetPrefixes(param ipam.IpamPrefixesListParams) ([]*models.Pr
} }
// get prefixes // get prefixes
prefixes, err := nb.API.Ipam.IpamPrefixesList(&param, nil) prefixes, err := nb.Ipam.IpamPrefixesList(&param, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -81,7 +81,7 @@ func (nb NetBoxAPI) GetIPAddresses(param ipam.IpamIPAddressesListParams) ([]*mod
} }
// get addresses // get addresses
addresses, err := nb.API.Ipam.IpamIPAddressesList(&param, nil) addresses, err := nb.Ipam.IpamIPAddressesList(&param, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -28,7 +28,7 @@ func (nb NetBoxAPI) GetClusters(param virtualization.VirtualizationClustersListP
} }
// get clusters // get clusters
clusters, err := nb.API.Virtualization.VirtualizationClustersList(&param, nil) clusters, err := nb.Virtualization.VirtualizationClustersList(&param, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -80,7 +80,7 @@ func (nb NetBoxAPI) GetClusterGroups(param virtualization.VirtualizationClusterG
} }
// get clusterGroups // get clusterGroups
clusterGroups, err := nb.API.Virtualization.VirtualizationClusterGroupsList(&param, nil) clusterGroups, err := nb.Virtualization.VirtualizationClusterGroupsList(&param, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }