Rename to nbclient.
This commit is contained in:
parent
44968a9d6f
commit
0f32a49e83
2 changed files with 67 additions and 60 deletions
10
netbox.go
10
netbox.go
|
@ -1,5 +1,13 @@
|
||||||
package netboxclient
|
package nbclient
|
||||||
|
|
||||||
type NetBox struct {
|
type NetBox struct {
|
||||||
RootURL string
|
RootURL string
|
||||||
|
Token string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *NetBox) new(root, token string) error {
|
||||||
|
n.RootURL = root
|
||||||
|
n.Token = token
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package netboxclient
|
package nbclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -11,72 +11,72 @@ import (
|
||||||
type dcim_interfaces_create struct {
|
type dcim_interfaces_create struct {
|
||||||
Device int `json:"device"`
|
Device int `json:"device"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type int `json:"type"`
|
Type int `json:"type,omitempty"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled,omitempty"`
|
||||||
Lag int `json:"lag"`
|
Lag int `json:"lag,omitempty"`
|
||||||
Mtu int `json:"mtu"`
|
Mtu int `json:"mtu,omitempty"`
|
||||||
MacAddress string `json:"mac_address"`
|
MacAddress string `json:"mac_address,omitempty"`
|
||||||
MgmtOnly bool `json:"mgmt_only"`
|
MgmtOnly bool `json:"mgmt_only,omitempty"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description,omitempty"`
|
||||||
ConnectionStatus bool `json:"connection_status"`
|
ConnectionStatus bool `json:"connection_status,omitempty"`
|
||||||
Cable struct {
|
Cable struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label,omitempty"`
|
||||||
} `json:"cable"`
|
} `json:"cable,omitempty"`
|
||||||
Mode int `json:"mode"`
|
Mode int `json:"mode,omitempty"`
|
||||||
UntaggedVlan int `json:"untagged_vlan"`
|
UntaggedVlan int `json:"untagged_vlan,omitempty"`
|
||||||
TaggedVlans []int `json:"tagged_vlans"`
|
TaggedVlans []int `json:"tagged_vlans,omitempty"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type dcim_interfaces_list struct {
|
type dcim_interfaces_list struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count,omitempty"`
|
||||||
Next interface{} `json:"next"`
|
Next interface{} `json:"next,omitempty"`
|
||||||
Previous interface{} `json:"previous"`
|
Previous interface{} `json:"previous,omitempty"`
|
||||||
Results []struct {
|
Results []struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id,omitempty"`
|
||||||
Device struct {
|
Device struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id,omitempty"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name,omitempty"`
|
||||||
DisplayName string `json:"display_name"`
|
DisplayName string `json:"display_name,omitempty"`
|
||||||
} `json:"device"`
|
} `json:"device,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name,omitempty"`
|
||||||
Type struct {
|
Type struct {
|
||||||
Value int `json:"value"`
|
Value int `json:"value,omitempty"`
|
||||||
Label string `json:"label"`
|
Label string `json:"label,omitempty"`
|
||||||
} `json:"type"`
|
} `json:"type,omitempty"`
|
||||||
FormFactor struct {
|
FormFactor struct {
|
||||||
Value int `json:"value"`
|
Value int `json:"value,omitempty"`
|
||||||
Label string `json:"label"`
|
Label string `json:"label,omitempty"`
|
||||||
} `json:"form_factor"`
|
} `json:"form_factor,omitempty"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled,omitempty"`
|
||||||
Lag struct {
|
Lag struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id,omitempty"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url,omitempty"`
|
||||||
Device struct {
|
Device struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id,omitempty"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name,omitempty"`
|
||||||
DisplayName string `json:"display_name"`
|
DisplayName string `json:"display_name,omitempty"`
|
||||||
} `json:"device"`
|
} `json:"device,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name,omitempty"`
|
||||||
Cable interface{} `json:"cable"`
|
Cable interface{} `json:"cable,omitempty"`
|
||||||
ConnectionStatus interface{} `json:"connection_status"`
|
ConnectionStatus interface{} `json:"connection_status,omitempty"`
|
||||||
} `json:"lag"`
|
} `json:"lag,omitempty"`
|
||||||
Mtu interface{} `json:"mtu"`
|
Mtu interface{} `json:"mtu,omitempty"`
|
||||||
MacAddress interface{} `json:"mac_address"`
|
MacAddress interface{} `json:"mac_address,omitempty"`
|
||||||
MgmtOnly bool `json:"mgmt_only"`
|
MgmtOnly bool `json:"mgmt_only,omitempty"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description,omitempty"`
|
||||||
ConnectedEndpointType interface{} `json:"connected_endpoint_type"`
|
ConnectedEndpointType interface{} `json:"connected_endpoint_type,omitempty"`
|
||||||
ConnectedEndpoint interface{} `json:"connected_endpoint"`
|
ConnectedEndpoint interface{} `json:"connected_endpoint,omitempty"`
|
||||||
ConnectionStatus interface{} `json:"connection_status"`
|
ConnectionStatus interface{} `json:"connection_status,omitempty"`
|
||||||
Cable interface{} `json:"cable"`
|
Cable interface{} `json:"cable,omitempty"`
|
||||||
Mode interface{} `json:"mode"`
|
Mode interface{} `json:"mode,omitempty"`
|
||||||
UntaggedVlan interface{} `json:"untagged_vlan"`
|
UntaggedVlan interface{} `json:"untagged_vlan,omitempty"`
|
||||||
TaggedVlans []interface{} `json:"tagged_vlans"`
|
TaggedVlans []interface{} `json:"tagged_vlans,omitempty"`
|
||||||
Tags []interface{} `json:"tags"`
|
Tags []interface{} `json:"tags,omitempty"`
|
||||||
CountIpaddresses int `json:"count_ipaddresses"`
|
CountIpaddresses int `json:"count_ipaddresses,omitempty"`
|
||||||
} `json:"results"`
|
} `json:"results,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *dcim_interfaces_create) CreateInterface(n *NetBox) error {
|
func (i *dcim_interfaces_create) CreateInterface(n *NetBox) error {
|
||||||
|
@ -93,6 +93,7 @@ func (i *dcim_interfaces_create) CreateInterface(n *NetBox) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
request.Header.Add("Content-Type", "application/json")
|
request.Header.Add("Content-Type", "application/json")
|
||||||
|
request.Header.Add("Authorization", "Token "+n.Token)
|
||||||
response, err := client.Do(request)
|
response, err := client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -105,5 +106,3 @@ func (i *dcim_interfaces_create) CreateInterface(n *NetBox) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *dcim_interface_list) ListInterface(n *NetBox) error {
|
|
||||||
|
|
Loading…
Reference in a new issue