Rename to nbclient.

This commit is contained in:
Kalle Carlbark 2019-09-11 09:19:24 +02:00
parent 44968a9d6f
commit 0f32a49e83
No known key found for this signature in database
GPG key ID: 3FC0C93C5A5A0670
2 changed files with 67 additions and 60 deletions

View file

@ -1,5 +1,13 @@
package netboxclient
package nbclient
type NetBox struct {
RootURL string
Token string
}
func (n *NetBox) new(root, token string) error {
n.RootURL = root
n.Token = token
return nil
}

View file

@ -1,4 +1,4 @@
package netboxclient
package nbclient
import (
"bytes"
@ -11,72 +11,72 @@ import (
type dcim_interfaces_create struct {
Device int `json:"device"`
Name string `json:"name"`
Type int `json:"type"`
Enabled bool `json:"enabled"`
Lag int `json:"lag"`
Mtu int `json:"mtu"`
MacAddress string `json:"mac_address"`
MgmtOnly bool `json:"mgmt_only"`
Description string `json:"description"`
ConnectionStatus bool `json:"connection_status"`
Type int `json:"type,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Lag int `json:"lag,omitempty"`
Mtu int `json:"mtu,omitempty"`
MacAddress string `json:"mac_address,omitempty"`
MgmtOnly bool `json:"mgmt_only,omitempty"`
Description string `json:"description,omitempty"`
ConnectionStatus bool `json:"connection_status,omitempty"`
Cable struct {
Label string `json:"label"`
} `json:"cable"`
Mode int `json:"mode"`
UntaggedVlan int `json:"untagged_vlan"`
TaggedVlans []int `json:"tagged_vlans"`
Tags []string `json:"tags"`
Label string `json:"label,omitempty"`
} `json:"cable,omitempty"`
Mode int `json:"mode,omitempty"`
UntaggedVlan int `json:"untagged_vlan,omitempty"`
TaggedVlans []int `json:"tagged_vlans,omitempty"`
Tags []string `json:"tags,omitempty"`
}
type dcim_interfaces_list struct {
Count int `json:"count"`
Next interface{} `json:"next"`
Previous interface{} `json:"previous"`
Count int `json:"count,omitempty"`
Next interface{} `json:"next,omitempty"`
Previous interface{} `json:"previous,omitempty"`
Results []struct {
ID int `json:"id"`
ID int `json:"id,omitempty"`
Device struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
} `json:"device"`
Name string `json:"name"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
DisplayName string `json:"display_name,omitempty"`
} `json:"device,omitempty"`
Name string `json:"name,omitempty"`
Type struct {
Value int `json:"value"`
Label string `json:"label"`
} `json:"type"`
Value int `json:"value,omitempty"`
Label string `json:"label,omitempty"`
} `json:"type,omitempty"`
FormFactor struct {
Value int `json:"value"`
Label string `json:"label"`
} `json:"form_factor"`
Enabled bool `json:"enabled"`
Value int `json:"value,omitempty"`
Label string `json:"label,omitempty"`
} `json:"form_factor,omitempty"`
Enabled bool `json:"enabled,omitempty"`
Lag struct {
ID int `json:"id"`
URL string `json:"url"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
Device struct {
ID int `json:"id"`
URL string `json:"url"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
} `json:"device"`
Name string `json:"name"`
Cable interface{} `json:"cable"`
ConnectionStatus interface{} `json:"connection_status"`
} `json:"lag"`
Mtu interface{} `json:"mtu"`
MacAddress interface{} `json:"mac_address"`
MgmtOnly bool `json:"mgmt_only"`
Description string `json:"description"`
ConnectedEndpointType interface{} `json:"connected_endpoint_type"`
ConnectedEndpoint interface{} `json:"connected_endpoint"`
ConnectionStatus interface{} `json:"connection_status"`
Cable interface{} `json:"cable"`
Mode interface{} `json:"mode"`
UntaggedVlan interface{} `json:"untagged_vlan"`
TaggedVlans []interface{} `json:"tagged_vlans"`
Tags []interface{} `json:"tags"`
CountIpaddresses int `json:"count_ipaddresses"`
} `json:"results"`
ID int `json:"id,omitempty"`
URL string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
DisplayName string `json:"display_name,omitempty"`
} `json:"device,omitempty"`
Name string `json:"name,omitempty"`
Cable interface{} `json:"cable,omitempty"`
ConnectionStatus interface{} `json:"connection_status,omitempty"`
} `json:"lag,omitempty"`
Mtu interface{} `json:"mtu,omitempty"`
MacAddress interface{} `json:"mac_address,omitempty"`
MgmtOnly bool `json:"mgmt_only,omitempty"`
Description string `json:"description,omitempty"`
ConnectedEndpointType interface{} `json:"connected_endpoint_type,omitempty"`
ConnectedEndpoint interface{} `json:"connected_endpoint,omitempty"`
ConnectionStatus interface{} `json:"connection_status,omitempty"`
Cable interface{} `json:"cable,omitempty"`
Mode interface{} `json:"mode,omitempty"`
UntaggedVlan interface{} `json:"untagged_vlan,omitempty"`
TaggedVlans []interface{} `json:"tagged_vlans,omitempty"`
Tags []interface{} `json:"tags,omitempty"`
CountIpaddresses int `json:"count_ipaddresses,omitempty"`
} `json:"results,omitempty"`
}
func (i *dcim_interfaces_create) CreateInterface(n *NetBox) error {
@ -93,6 +93,7 @@ func (i *dcim_interfaces_create) CreateInterface(n *NetBox) error {
return err
}
request.Header.Add("Content-Type", "application/json")
request.Header.Add("Authorization", "Token "+n.Token)
response, err := client.Do(request)
if err != nil {
return err
@ -105,5 +106,3 @@ func (i *dcim_interfaces_create) CreateInterface(n *NetBox) error {
}
return nil
}
func (i *dcim_interface_list) ListInterface(n *NetBox) error {