fbreckle / go-netbox

Package netbox provides an API client for DigitalOcean's NetBox IPAM and DCIM service.
Other
1 stars 22 forks source link

u_height should not be int #16

Closed mifrost closed 1 year ago

mifrost commented 1 year ago

Hi,

As of https://github.com/netbox-community/netbox/pull/9571/files , the u_height field in netbox is no longer an integer. As such, when creating or reading device types with this library (and notably the terraform provider), we receive

Error: json: cannot unmarshal number 1.0 into Go struct field DeviceType.u_height of type int64

Hopefully this should be a minor change here https://github.com/fbreckle/go-netbox/blob/master/netbox/models/device_type.go#L117 , unless anyone is aware of anywhere else this needs changing?

I'll hopefully get a PR written and tested in the next few days

Mike

fbreckle commented 1 year ago

Hi!

Per the linked PR, this is a 3.3 feature. Did you check out the 3.3 branch already? https://github.com/fbreckle/go-netbox/tree/feature/netbox-3.3

mifrost commented 1 year ago

Ah, that does indeed look to be fixed in the 3.3 branch - I'll test that later today to confirm. Is there anything I can help with to get the 3.3 branch merged?

mifrost commented 1 year ago

One issue I found when checking the 3.3 branch out is that go pulled an older version of the openapi libraries which did not work - setting them to the latest version looks to get it working. I've raised https://github.com/fbreckle/go-netbox/pull/17 , do let me know if that's the right way to go about making the change

fbreckle commented 1 year ago

What exactly did not work for you? It works on our netbox 3.3 branch in the terraform provider, I guess it updates the deps automatically. The provider also has newer versions linked, but I dont remember ever updating them :sweat_smile:

mifrost commented 1 year ago

When I pulled the dependencies, there were a number of functions in go-openapi/validate and go-openapi/errors which couldn't be found, eg

../models/a_s_n.go:235:15: ce.ValidateName undefined (type *"github.com/go-openapi/errors".CompositeError has no field or method ValidateName)
../models/a_s_n.go:304:21: undefined: validate.ReadOnly

Updating to the latest version of both worked

fbreckle commented 1 year ago

I merged yours and updated many other deps as well with some go get -u magic :D

mifrost commented 1 year ago

That update does look to have fixed the problem for me, thanks (apologies for the delayed response!)