I'm working with Nautobot 2.0 and due to the fact that the REST API doesn't resolve related objects has pushed me into the GraphQL world. The code I'm working on needs to review a set of objects and possibly update them. Since I'm already getting all the data back from GraphQL I need, and I know exactly which fields need updating (thanks to diffsync), I'd like to update the objects without adding the unnecessary HTTP GET into the mix.
For example, the way to do it today:
Query data from GraphQL
Determine updates
Load object using o = nb.dcim.devices.get(device_id) which results in another GET
Make a o.update(...) call to call PATCH
This results in an unnecessary GET of every object I want to update. A work-around today is to manually construct a Request to PATCH the object, but this is likely error-prone. I think pynautobot can provide a better API.
Example use of such an API:
# Add a method to class Endpoint.update() that resembles Record.update()
nb.dcim.devices.update(id=..., data={"field1": "value1"})
The call would return True if the PATCH was successful and False if unsuccessful.
I'm working with Nautobot 2.0 and due to the fact that the REST API doesn't resolve related objects has pushed me into the GraphQL world. The code I'm working on needs to review a set of objects and possibly update them. Since I'm already getting all the data back from GraphQL I need, and I know exactly which fields need updating (thanks to diffsync), I'd like to update the objects without adding the unnecessary HTTP GET into the mix.
For example, the way to do it today:
o = nb.dcim.devices.get(device_id)
which results in another GETo.update(...)
call to call PATCHThis results in an unnecessary GET of every object I want to update. A work-around today is to manually construct a Request to PATCH the object, but this is likely error-prone. I think pynautobot can provide a better API.
Example use of such an API:
The call would return True if the PATCH was successful and False if unsuccessful.
References: