nautobot / pynautobot

Nautobot Python SDK
https://pynautobot.readthedocs.io/en/latest/index.html
Apache License 2.0
38 stars 32 forks source link

Support add_params in EndPoint #24

Closed jvanderaa closed 3 years ago

jvanderaa commented 3 years ago

There are a few params that would be nice to be able to pass through on the endpoints, for filter() and all() if possible. We should add the ability to exclude config contexts and to include computed fields.

On the config contexts part, it is known that this is an expensive query to make. The nornir-nautobot inventory with REST API is using pynautobot to make this call. This is causing some timeouts at times on larger instances. Would like to have this capability to remove the call to get config contexts.

On the computed fields front, a new parameter was added. This would be good to add into the capabilities as long as params are being edited and looked at in the same light as excluding config contexts.

jmcgill298 commented 3 years ago

Does this not already work by passing kwargs with exclude="config_context"?

jvanderaa commented 3 years ago

We are not able to do that on the filter, nor the all() endpoints if I'm not mistaken.

jvanderaa commented 3 years ago

Filtered that does work, but all() does not.

In [4]: nb.dcim.devices.all(exclude="config_context")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-f085f07e5fed> in <module>
----> 1 nb.dcim.devices.all(exclude="config_context")

TypeError: all() got an unexpected keyword argument 'exclude'

With that, I can move the inventory to use filter everywhere with exclude.

jmcgill298 commented 3 years ago

ya, I wouldn't expect it to work on all(), but was pretty sure that it would for filter(); can this be closed?