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 {
|
||||
var encoder = schema.NewEncoder()
|
||||
|
||||
form := url.Values{}
|
||||
err := encoder.Encode(f, form)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
query := form.Encode()
|
||||
|
||||
transport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: n.InsecureSkipVerify},
|
||||
}
|
||||
|
@ -203,11 +196,18 @@ func (n *NetBox) ListDevices(d *Dcim_Devices_List, f *DeviceFilter) error {
|
|||
Timeout: timeout,
|
||||
Transport: transport,
|
||||
}
|
||||
deviceurl := n.RootURL + "/api/dcim/devices/"
|
||||
var request *http.Request
|
||||
if len(query) > 0 {
|
||||
deviceurl := n.RootURL + "/api/devices/"
|
||||
if (&DeviceFilter{} != f) {
|
||||
form := url.Values{}
|
||||
err := encoder.Encode(f, form)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
query := form.Encode()
|
||||
deviceurl = deviceurl + "?" + query
|
||||
}
|
||||
var request *http.Request
|
||||
var err error
|
||||
request, err = http.NewRequest("GET", deviceurl, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue