netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.93k stars 2.56k forks source link

Build out writable API #113

Closed netman2048 closed 7 years ago

netman2048 commented 8 years ago

I would like to put in a formal request for writable APIs for the IPAM portion of Netbox. I would love to consider swinging IPAM over to Netbox from Bluecat Address Manager but I have some provisioning scripts that obtain IP's from our existing IPAM when provisioning customers but without that functionality, it won't work for me.

malaiam commented 8 years ago

I would also like to see this feature implemented sooner rather than later. I'm considering changing the IPAM we use in preparation for network automation and this is kind of a crucial element.

alejojo commented 8 years ago

Writable api would be awesome, specially when using with packer/ansible/jenkins

dqminh commented 8 years ago

@jeremystretch is there any ongoing work on this ? is this something that you would like contributions as we would also want to implement IPAM with writeable APIs.

Zanthras commented 7 years ago

I've been working on a extending out the api to support full write operations on a private branch.

Generally speaking ive been following the url scheme of:

post to /module/resource/add/ put/patch to /module/resource/pk/edit/ delete to /module/resource/pk/delete/

If this fits and is desired I can work on a pull request to merge it back upstream. One thing I havent figured out how to do yet is handle custom fields, so ignoring that for now in favor of making progress.

koenbud commented 7 years ago

I am really looking forward to full POST/PUT support too.

axlroden commented 7 years ago

@Zanthras nice!, although I really need custom fields as well so hoping it wont be forgotten.

hwinkel commented 7 years ago

We have a use case where netbox should hold the own IP prefixes but a external IPAM Client is asking for registering a new IP or Prefix in netbox. is this covered by writable API?

maradwan commented 7 years ago

writable API is important to integrate it with configuration management tools.

jsenecal commented 7 years ago

Would the jsonapi format be suitable for our needs?

I contributed to "djangorestframework-jsonapi" and would be available to contribute into netbox as well if the future functionality is in line with that format.

Let me know if you welcome contributions on that topic.

InsaneSplash commented 7 years ago

I'd be interested in the updating of fields of a device using the put/patch methods through the API. One field I would like to update in particular is the "Status" field which I want to use as a tie in to the success/failure of a connection to the device's primary IP. I'm all ready but just found that the PUT/PATCH wasn't supported...

koenbud commented 7 years ago

@jsenecal For me jsonapi would be perfect.

jeremystretch commented 7 years ago

Good news! I've started work on API v2.0 and it's going very well. I can't provide an ETA for the beta just yet, but you can keep an eye on the progress by watching the api2 branch.

This is by far the most-requested feature for NetBox, and I realize everyone is eager to try it out. However, I want to make sure we're investing a prudent amount of thought and effort into the new API up front so that we can avoid too many changes down the road.

jbnance commented 7 years ago

I would like to see this follow the CRUD principle. An example of this can be seen here:

http://www.restapitutorial.com/lessons/httpmethods.html

Basically, you don't have to say, for example, "/something/create", the fact that you are POSTing is an indication that you want to create.

A working example of this can be seen in the Foreman API.

https://theforeman.org/api/1.14/index.html

jeremystretch commented 7 years ago

@jbnance Yep, that's the plan. Each object type will generally have two URL endpoints.

bwks commented 7 years ago

@jeremystretch are you looking for any contributors for this feature ? This would be really helpful for us and there is a possibility to get some engineering time allocated if so.

axlroden commented 7 years ago

Is the branch in any state to be tested/used yet ? Or you still doing breaking changes ?

xbeaudouin commented 7 years ago

Hello, The company who I am working for have some python developpers and may help you to build the RW API. How can we be in sync (seem that irc channel is more or less idle for that). Regards

jeremystretch commented 7 years ago

Released the first beta of v2.0 today: https://github.com/digitalocean/netbox/releases/tag/v2.0-beta1

Please kick the tires and post to the mailing list or open a bug report for any issues.

jeremystretch commented 7 years ago

Closing this out as the new API is essentially done. Further development and bug fixes will be handled as part of the beta process.