netbox-community / go-netbox

The official Go API client for Netbox IPAM and DCIM service.
Other
194 stars 144 forks source link

update device `config_context` #78

Closed TimSimmons closed 2 years ago

TimSimmons commented 4 years ago

change device "config_context" type we've seen this field looking like

"config_context": {
  "ntp_servers": ["0.us.pool", ...

Which was not compatible with the map[string]string it was trying to parse with. So I've changed it to be an map[string]interface{} so that it can be arbitrary json.

allow ?exclude=config_context URL parameter for device listing This is mentioned in the v2.6 release netbox-community/netbox#3271

"API Device/VM Config Context Included by Default (#2350)"

imports style changes this happened when I generated, shouldn't change anything in practice

awlx commented 3 years ago

This seems to be obsolete with merge of? #92

TimSimmons commented 3 years ago

I'd have to test to be sure! I don't see some of the analogous changes, I can try and do that and get back to you though!

awlx commented 3 years ago

That would be awesome thank you!

awlx commented 3 years ago

Any updates or do we close it for now? :)

TimSimmons commented 3 years ago

sorry for the delay here, shameful of me. looks like ive still got my primary issue

 $ cat go.mod | grep netbox
    github.com/netbox-community/go-netbox v0.0.0-20201002085217-91e5d561efe4

...

 56     params := dcim.NewDcimDevicesListParamsWithTimeout(30 * time.Second)
 57     params.Limit = &limit
 58     params.Q = &r.query.Rack
 59     params.Role = &r.query.Role
 60     params.Site = &r.query.Region
 61     configContext := "config_context"
 62     params.Exclude = &configContext
discovery/netbox.go:62:8: params.Exclude undefined (type *dcim.DcimDevicesListParams has no field or method Exclude)
michaelquong commented 3 years ago

Hello,

I am running on Netbox 2.9.0 and working with the latest netbox-community/go-netbox version;

cat go.mod | grep netbox
github.com/netbox-community/go-netbox v0.0.0-20201107160141-927b38be4340

I think I am also having this problem? As like OP, I have a similar config_context structure which results in the following error when attempting to unmarshall the data:

cannot unmarshal object into Go struct field VirtualMachineWithConfigContext.results.config_context of type string

My implementation:

params := virtualization.NewVirtualizationVirtualMachinesListParams()
l, err := client.Virtualization.VirtualizationVirtualMachinesList(params, nil)