netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Build out writable API

Open netman2048 opened this issue 10 years ago • 19 comments

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.

netman2048 avatar Jun 29 '16 16:06 netman2048

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.

malaiam avatar Jul 27 '16 14:07 malaiam

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

acortina-git avatar Aug 04 '16 05:08 acortina-git

@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.

dqminh avatar Oct 05 '16 12:10 dqminh

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.

Zanthras avatar Nov 18 '16 02:11 Zanthras

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

koenbud avatar Nov 22 '16 15:11 koenbud

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

axlroden avatar Nov 28 '16 13:11 axlroden

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?

hwinkel avatar Nov 30 '16 14:11 hwinkel

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

maradwan avatar Dec 16 '16 14:12 maradwan

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.

jsenecal avatar Jan 11 '17 04:01 jsenecal

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...

InsaneSplash avatar Jan 12 '17 15:01 InsaneSplash

@jsenecal For me jsonapi would be perfect.

koenbud avatar Jan 12 '17 15:01 koenbud

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.

jeremystretch avatar Jan 27 '17 19:01 jeremystretch

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

jbnance avatar Feb 06 '17 23:02 jbnance

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

  • /api/dcim/devices/ - List devices (GET) or create a new device (POST)
  • /api/dcim/devices/123/ - Retrieve (GET), update (PUT/PATCH), or delete (DELETE) the device with ID 123

jeremystretch avatar Feb 07 '17 16:02 jeremystretch

@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.

bwks avatar Feb 15 '17 02:02 bwks

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

axlroden avatar Mar 01 '17 09:03 axlroden

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

xbeaudouin avatar Mar 07 '17 09:03 xbeaudouin

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 avatar Mar 22 '17 14:03 jeremystretch

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

jeremystretch avatar Mar 23 '17 17:03 jeremystretch