netbox-community / go-netbox

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

Support vor netbox v3.3? #136

Closed christophbrejla closed 1 year ago

christophbrejla commented 1 year ago

Hello, we are using netbox version v3.3.4 at this point. I tried to use the netbox client with release "netbox_v3.2" and the prerelease "netbox_v3.4". I am facing several incompatibility issues.

json: cannot unmarshal number 35.0 into Go struct field DeviceWithConfigContext.results.position of type int64 json: cannot unmarshal number into Go struct field IPAddress.results.assigned_object of type string cannot unmarshal array into Go struct field IPAddress.results.nat_outside of type models.NestedIPAddress

There are also several unmarshalling problems where referenced objects cannot be unmarshalled to the type "map[string]*string". if its changed to "map[string]any" then its working.

are you planning to release a compatible version vor version 3.3. any time soon?

maybe you can consider the changes i made in my fork and merge them

https://github.com/christophbrejla/go-netbox/compare/master...feature/netbox_v3.3

vwbusguy commented 1 year ago

I can replicate this with v3.3.6 on both the v3.2 and v3.4 versions. For example, getting a device list returns:

FATA[0000] Cannot get devices list: json: cannot unmarshal number 24.0 into Go struct field DeviceWithConfigContext.results.position of type int64 
exit status 1
vwbusguy commented 1 year ago

I used replace ( in the go.mod to use your fork instead and it's working for me so far!

vwbusguy commented 1 year ago

I didn't see a PR for yours but it looks like someone else submitted a PR in the meantime: https://github.com/netbox-community/go-netbox/pull/137

tao-sj commented 1 year ago

this issue can be closed - I've verified #137 fixed it.

christophbrejla commented 1 year ago

Hello, i have tested the lastest version from "master" branch. i am still getting errors when calling "dcim.NewDcimConsolePortsListParams()", for example

cannot unmarshal object into Go struct field ConsolePort.results.link_peers of type string

in the current implementation this property is

LinkPeers []*stringjson:"link_peers"``

and earlier (when it worked) it was

LinkPeer map[string]*stringjson:"link_peer,omitempty"``

Is there some kind of config for the serializer to make this work? how come others dont have those serialization problems?

Thank you

tao-sj commented 1 year ago

Hello, i have tested the lastest version from "master" branch. i am still getting errors when calling "dcim.NewDcimConsolePortsListParams()", for example

cannot unmarshal object into Go struct field ConsolePort.results.link_peers of type string

in the current implementation this property is

LinkPeers []*stringjson:"link_peers"``

and earlier (when it worked) it was

LinkPeer map[string]*stringjson:"link_peer,omitempty"``

Is there some kind of config for the serializer to make this work? how come others dont have those serialization problems?

Thank you

I didn't try this one.

v0ctor commented 1 year ago

Support added by release v3.3.10-0.