Hello,
I was wondering if you would consider moving netbox' constants.py into a separate dependency required by both netbox and pynetbox or maybe making an API endpoint for them.
Handling them is not much of an hassle, but It might feel more comforting to have them right away when using pynetbox.
Thank you for your interest in NetBox. It looks like your feature request is missing some information. Per the contributing guidelines, please ensure that you have provided all of the following:
Please update the issue so that it meets all of these requirements. If no response is received within a week, this issue will be closed. Thanks!
In pynetbox, I'd like to do the following without maintaining the constants by myself or using the hardcoded values :
nb.dcim.interfaces.create(device="somedevice", name="eth0", form_factor=IFACE_FF_1GE_FIXED)
I guess It would ease the use of pynetbox a bit and prevent some possible regressions in case of modifications on the constants part.
Adding special endpoints in the netbox API to expose the constants might be the way to go, since it would not be language dependent.
GET /api/dcim/constants/
{
"dcim:constants": [
{
"IFACE_FF_100ME_FIXED": 800,
},
{
"IFACE_FF_1GE_FIXED": 1000,
},
...
]
}
That would require some work in the client libraries to cache this constants and make them reusable.
Adding special endpoints in the netbox API to expose the constants might be the way to go, since it would not be language dependent.
The interface form factors are available at /api/dcim/_choices/:
{
"interface:form_factor": [
{
"value": 0,
"label": "Virtual"
},
{
"value": 200,
"label": "Link Aggregation Group (LAG)"
},
{
"value": 800,
"label": "100BASE-TX (10/100ME)"
},
{
"value": 1000,
"label": "1000BASE-T (1GE)"
},
...
}
Do you need the name of the constant itself exposed as well?
Wonder how I missed that. :)
Labels should be enough for now. In the long run constants might be cleaner though (If you ever wish to localize the app maybe, or to enable some readable filtering /api/dcim/_choices/interface:form_factor/?label=100BASE-TX%20%2810/100ME%29).
Do wish me open an issue on the pynetbox project to discuss the retrieval part in it ? Even if writing a custom function isn't hard, a reusable builtin method would be nicer.
@dsanader Feel free to open an FR against pynetbox for it. I haven't kept up much with pynetbox lately.
Most helpful comment
In
pynetbox, I'd like to do the following without maintaining the constants by myself or using the hardcoded values :I guess It would ease the use of
pynetboxa bit and prevent some possible regressions in case of modifications on the constants part.Adding special endpoints in the
netboxAPI to expose the constants might be the way to go, since it would not be language dependent.GET /api/dcim/constants/That would require some work in the client libraries to cache this constants and make them reusable.