-
Hey! So Im trying to create a python automation to pull the Vlan of one site and the prefix of the vlan, I though about pulling all the information from the Prefixes but there are vlans which doesn't have prefixes so it is problematic. Is there a way to do it without complicating it ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
What are you using: REST API direct? REST API via Pynetbox? Django ORM (e.g. from custom scripts or reports)? Webhook? Something else? From the Django ORM (which you can examine interactively using nbshell) there's a relation:
From the REST API, you can query Note that in general, a single VLAN could have multiple prefixes: e.g. a v4 and a v6 prefix, or a primary and secondary v4 prefix. I observe that |
Beta Was this translation helpful? Give feedback.
If what you have is the vlan ID, and what you want is the prefix(es) associated with that VLAN, then you need to make an extra request. You can avoid making that extra request if the VLAN shows
"prefix_count": 0
of course.You might be able to get what you want in a single request using the GraphQL API instead of the REST API.