netbox-community / go-netbox

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

Add support to Netbox _choice api for Circuits/DCIM/IPAM/Secrets/Tenancy/Virtualization #53

Closed quakelee closed 4 years ago

quakelee commented 4 years ago

This is code change to make go-netbox support Netbox 2.6+ _choice api. The Value type is using json.RawMessage, user can unmarshal it with proper type when using corresponding choice.

In this request also include a small fix in netbox/client/dcim/dcim_interfaces_list_parameters.go I changed the DeviceID type from float64 to int64, since DeviceID has no way to have a float64 value in Netbox, I don't know why it was generated as float.

and at last, I added more elements for ConnectedEndpoint struct to receive those values from API. My app need them.

mraerino commented 4 years ago

We are currently trying to get this project into a state where we can fully generate models and a low level client from a swagger definition: https://github.com/netbox-community/go-netbox/pull/52

Might it be possible to get your changes out of that effort?

We are also thinking about a higher level client that will provide the appropriate unmarshaling for those cases of polymorphism

quakelee commented 4 years ago

Sorry, I'm not very familiar with swagger, If you've already had a plan to do this part, I'm looking forward to that. My adoption's aim is making this part fully functional for my apps. If this part can automatically generated, that'd be better. I also agree with a higher level client, in my apps I need to write a bunch of higher level functions to wrap this lib as well, because using them directly is too redundant and quite inconvenient.

mraerino commented 4 years ago

Can you give me some example for high-level client methods that are useful to you? I'd like to get an idea of what we could build

kobayashi commented 4 years ago

Hi @quakelee,

I appreciate your work here and sorry for this late response. Could you check the current master branch which is for netbox v2.7? This may fix your request also.

kobayashi commented 4 years ago

This is opened for a long time. Please check the latest commit and let us know still need work for this. Thank you for your contribution.