Getting all Device Data within a Custom Script #15398
Replies: 2 comments
-
Yes, this is of course possible. You need to add |
Beta Was this translation helpful? Give feedback.
-
When you say "API calls", if you mean REST API calls, then you should not be using them at all in a Custom Script - you should be using the Django ORM to access the data model. This gives you the transaction safety of the ORM, and the ability to rollback changes. There is no "getAllData", but extra database queries will be made automatically when you touch foreign key attributes that haven't yet been loaded. If you want to avoid the overhead of extra SQL queries then look at prefetch_related in the Django ORM documentation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I would like to receive all data for a device in my custom script without an API call.
The background is that I would like to pass this data within the code to other functions without having to make 5 individual API calls for them.
Is there a way to get all data for a specific device in a custom script. Not only the data that can be found under Device, but also the assigned plugin data.
Basically what you get via API: "/api/dcim/devices/{id}/" or "/api/plugins/"
Am I missing a way to easy access these values directly in the Custum script?
Maybe Device.getallData(Device1) xD
I would be very grateful for a hint.
Beta Was this translation helpful? Give feedback.
All reactions