question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecate the _choices API endpoints

See original GitHub issue

Environment

  • Python version: 3.5.2
  • NetBox version: 2.6.2

Proposed Change

The NetBox REST API provides a _choices endpoint under each app (e.g. /api/circuits/_choices/) which lists the available values and labels for each choice field within the app. As @lampwins recently pointed out, the Django REST Framework exposes these choices (as well as other useful field attributes) via an OPTIONS HTTP request.

More investigation is needed, however it is likely that we can ditch the statically defined _choices endpoints in favor of using the built-in OPTIONS behavior.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
markkuleiniocommented, Nov 12, 2019

FYI, the new Endpoint.choices() has been merged in master branch of pynetbox:

https://pynetbox.readthedocs.io/en/latest/endpoint.html#pynetbox.core.endpoint.Endpoint.choices

>>> from pprint import pprint
>>> pprint(netbox.ipam.ip_addresses.choices())
{'role': [{'display_name': 'Secondary', 'value': 20},
          {'display_name': 'VIP', 'value': 40},
          {'display_name': 'VRRP', 'value': 41},
          {'display_name': 'Loopback', 'value': 10},
          {'display_name': 'GLBP', 'value': 43},
          {'display_name': 'CARP', 'value': 44},
          {'display_name': 'HSRP', 'value': 42},
          {'display_name': 'Anycast', 'value': 30}],
 'status': [{'display_name': 'Active', 'value': 1},
            {'display_name': 'Reserved', 'value': 2},
            {'display_name': 'Deprecated', 'value': 3},
            {'display_name': 'DHCP', 'value': 5}]}
>>>
1reaction
markkuleiniocommented, Dec 15, 2019

Just to show an example of Endpoint.choices() with the string values in 2.7-beta1, works fine:

>>> pynetbox.__version__
'4.2.2'
>>> netbox.version
'2.7'
>>> pprint(netbox.ipam.ip_addresses.choices())
{'role': [{'display_name': 'Loopback', 'value': 'loopback'},
          {'display_name': 'Secondary', 'value': 'secondary'},
          {'display_name': 'Anycast', 'value': 'anycast'},
          {'display_name': 'VIP', 'value': 'vip'},
          {'display_name': 'VRRP', 'value': 'vrrp'},
          {'display_name': 'HSRP', 'value': 'hsrp'},
          {'display_name': 'GLBP', 'value': 'glbp'},
          {'display_name': 'CARP', 'value': 'carp'}],
 'status': [{'display_name': 'Active', 'value': 'active'},
            {'display_name': 'Reserved', 'value': 'reserved'},
            {'display_name': 'Deprecated', 'value': 'deprecated'},
            {'display_name': 'DHCP', 'value': 'dhcp'}]}
>>>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Deprecating API Endpoints
If global API versions are used, then every API end point inside that version is deprecated at the same time: /v1/foo and /v1/bar...
Read more >
How to Smartly Sunset and Deprecate APIs
When an API is deprecated, this means an API is not usable in its current form for the purpose intended. This usually means...
Read more >
Can I deprecate this endpoint? - Pixie Labs Blog
Now that you know how your API is being used, you can create a deprecation plan. Developers don't appreciate surprise deprecations, so it's...
Read more >
What Organizations Need to Know When Deprecating APIs
How to efficiently deprecate an API · Communicate honestly · Provide a long enough sunset period · Version effectively · Provide alternatives.
Read more >
API Lifecycle, Versioning, and Deprecation
API Geriatrics—or old age care—comes into play here. At some point, the site or service who owns the API endpoints may need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found