Replies: 1 comment 3 replies
-
The Python API isn't really documented, but if you look at the 'models' directories in the source code it should give you a good head start.
dcim and ipam are directories, where the models are split over several files:
Another good source of reference is the scripts and reports repo which uses the Django ORM API. I don't know exactly what you mean by "But those imports are definitely missing". If you want help you'll have to say what version of Netbox you're running (the API has changed significantly between versions, especially for things like Choices) and show the actual complete code, how you're running it, and what error message you're getting. Are you running your code within Netbox as a custom script, triggered from the GUI? Or are you trying to run it standalone? Running it standalone will certainly have problems, as you would need to set a few things up first (*). Normally for standalone scripts you'd use nbshell for that, and then you don't need to import anything. (*) It is possible to run completely standalone scripts without nbshell, but it involves several lines of Django setup, and I'd have to dig around to find the code to do that. The problem goes away if you run CLI scripts using nbshell, or deploy 'custom scripts' inside Netbox itself. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Heya
i've tried to create some scripts, to automate imports from other services via their respective web api.
While i may be able to write a powershell script to get the Data via API, remap the data and post it on netbox's api, this was not the goal.
I examined the example custom script and tried to create a script which fetches Network-Container and Network Prefixes from an Infoblox API and imports them into Netbox.
This shouldve been an fairly easy task.
But in the end I struggled with the Imports and some Namings.
Although they are pretty obvious if you get the scheme on which those are created, it still might be worth a small part in the custom Script Doc Part, to explain what is needed.
For example:
Actually I dont even know what else i couldve Imported, those are the things i figured out with the example script.
But those imports are definitely missing, or is there somewhere a python doc regarding those things, i did not find yet ?
I have no idea on how to write a good Doc entry, but I just guessed this was missing.
Pls tell me your thoughts.
Ebiko
Beta Was this translation helpful? Give feedback.
All reactions