Skip to content
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

Add API filters for all models #1203

Closed
mattburgess opened this issue May 18, 2017 · 3 comments
Closed

Add API filters for all models #1203

mattburgess opened this issue May 18, 2017 · 3 comments
Labels
type: feature Introduction of new functionality to the application
Milestone

Comments

@mattburgess
Copy link

Issue type: bug report

Python version: 2.7.13
NetBox version: 2.0.3

Given the following device-roles:

$ curl http://192.168.33.34/api/dcim/device-roles/

{"count":2,"next":null,"previous":null,"results":[{"id":1,"name":"Chassis","slug":"chassis","color":"ff0000"},{"id":2,"name":"OpenStack Node","slug":"openstacknode","color":"008000"}]}

I'd expect the following query to return just 1 device-role (as per other similar queries against other objects that work as expected):
$ curl http://192.168.33.34/api/dcim/device-roles/?name=Chassis

{"count":2,"next":null,"previous":null,"results":[{"id":1,"name":"Chassis","slug":"chassis","color":"ff0000"},{"id":2,"name":"OpenStack Node","slug":"openstacknode","color":"008000"}]}

@mattburgess mattburgess changed the title API: Query string not passed on to device-role searches API: Query string not passed on to device-role or manufacturer searches May 19, 2017
@mattburgess
Copy link
Author

Looking at the code, it seems these objects just need filters writing to enable querying. I'll see if I can have a go at this over the weekend unless there's particular reasons why these filters haven't already been implemented?

My use case is that I'm trying to fully populate our NetBox instance using the API and a bunch of YAML data.

When it comes to adding a device-type, it has a relationship with manufacturer so my code has to look up the manufacturer ID given its name so it can satisfy that relationship. Similarly, when adding a device then the device-role has to be looked up by name.

@jeremystretch jeremystretch changed the title API: Query string not passed on to device-role or manufacturer searches Add API filters for all models May 26, 2017
@jeremystretch jeremystretch added the type: feature Introduction of new functionality to the application label May 26, 2017
@DerekTBrown
Copy link

Am I correct in saying that query filters aren't implemented for any model?

@jeremystretch
Copy link
Member

Implemented query filters for all remaining models in 87e5687

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants