Over the years I’ve done quite much software, integration and business process development using NetBox. Still, when developing code and configurations in various contexts, I’m sometimes unsure about the object or model syntax I need to follow. Thus, this post.
When dealing with NetBox objects in various places, these are the syntaxes I’ve found (using IP address model as an example):
ipam.IPAddress
This is the syntax that is used in Django: ipam is the application and IPAddress is the model. This syntax is used in NetBox scripts and in FIELD_CHOICES configuration in NetBox.
ipam.ipaddress
This lowercase syntax is used in DEFAULT_DASHBOARD configuration when specifying models within the widgets. It is also used in some other configurations, at least in CUSTOM_VALIDATORS and PROTECTION_RULES.
ipam.ip_addresses
This is the syntax used in Pynetbox that is a Python wrapper around the NetBox REST API. In the API the endpoint syntax is /api/ipam/ip-addresses/, and since dash is not allowed in Python identifiers, Pynetbox converts them to underscores. Plural syntax is usually used in API endpoints when they are used for accessing collections of data.
Did I miss some other syntax?