Fix device_list when filter struct is empty..
This commit is contained in:
parent
69e732abcd
commit
dcf73c1daf
1 changed files with 10 additions and 10 deletions
|
@ -188,13 +188,6 @@ type DeviceFilter struct {
|
||||||
func (n *NetBox) ListDevices(d *Dcim_Devices_List, f *DeviceFilter) error {
|
func (n *NetBox) ListDevices(d *Dcim_Devices_List, f *DeviceFilter) error {
|
||||||
var encoder = schema.NewEncoder()
|
var encoder = schema.NewEncoder()
|
||||||
|
|
||||||
form := url.Values{}
|
|
||||||
err := encoder.Encode(f, form)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
query := form.Encode()
|
|
||||||
|
|
||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: n.InsecureSkipVerify},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: n.InsecureSkipVerify},
|
||||||
}
|
}
|
||||||
|
@ -203,11 +196,18 @@ func (n *NetBox) ListDevices(d *Dcim_Devices_List, f *DeviceFilter) error {
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
}
|
}
|
||||||
deviceurl := n.RootURL + "/api/dcim/devices/"
|
deviceurl := n.RootURL + "/api/devices/"
|
||||||
var request *http.Request
|
if (&DeviceFilter{} != f) {
|
||||||
if len(query) > 0 {
|
form := url.Values{}
|
||||||
|
err := encoder.Encode(f, form)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
query := form.Encode()
|
||||||
deviceurl = deviceurl + "?" + query
|
deviceurl = deviceurl + "?" + query
|
||||||
}
|
}
|
||||||
|
var request *http.Request
|
||||||
|
var err error
|
||||||
request, err = http.NewRequest("GET", deviceurl, nil)
|
request, err = http.NewRequest("GET", deviceurl, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue