Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

quakelee
Copy link

@quakelee quakelee commented Jan 6, 2020

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.

Use json.RawMessage as value type to accommodate different
type of value.
User can json.Unmarshal Value with proper type when using it.
This is the simplest way to support
Netbox _choice apis I think.
I can give a code example for this if needed
current value with Netbox saved value
@mraerino
Copy link
Collaborator

mraerino commented Jan 6, 2020

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:
#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
Copy link
Author

quakelee commented Jan 7, 2020

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
Copy link
Collaborator

mraerino commented Jan 7, 2020

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
Copy link
Contributor

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
Copy link
Contributor

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.

@kobayashi kobayashi closed this May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants