Permission constraints key object

104 views
Skip to first unread message

Aof

unread,
Aug 25, 2020, 7:40:31 AM8/25/20
to netbox
Hi all,

I'm still new to Netbox, so pardon my lack of information.

I just tried Netbox v.2.9.1 to try on the new permissions feature. Still struck on how to properly design permission constraints.

My question is how do I find the dict key of each field? e.g. If I were to add custom fields 'Team owner' on dcim > devices section, what json key I have to specify?

Right now, I only tried with tenant__group__name and it worked well. But how will I know what key value I have to put if I were to use another field?

Regards,

Brian Candler

unread,
Aug 25, 2020, 8:00:43 AM8/25/20
to NetBox
As I understand it, these constraints are Django query filters.

Custom fields are odd beasts in Netbox.  If you are working via the ORM you can access them (read-only) as cf_fieldname properties, but I'm pretty sure that won't work here.  At the database query level you have to do a nasty join onto customfieldvalue / customfieldchoice / customfield.

There is a proposal to overhaul custom fields by representing them as a JSON column, which should fix this:

hyudra

unread,
Aug 25, 2020, 9:39:52 AM8/25/20
to NetBox

Hi Brian,

Thanks for information.
Is there a instruction for me to query them? Either from GUI or from the OS. I'm just a simple user who don't have much knowledge about django and coding.

Jeremy Stretch

unread,
Aug 25, 2020, 9:45:42 AM8/25/20
to hyudra, NetBox
The built-in REST API documentation is a good place to start. It's not 100% consistent with the ORM (intentionally), but it should help you determine how to craft constraints for common use cases.

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/c1a99c40-4545-42a0-a5a2-df1cfb1b409dn%40googlegroups.com.


--
Jeremy Stretch
Sr. Network Automation Engineer
Network to Code, LLC

Aof

unread,
Aug 25, 2020, 10:05:17 AM8/25/20
to Jeremy Stretch, NetBox
Hello,

Thanks again.  Seems like I can guess from the name and data from the api following https://netbox.readthedocs.io/en/stable/rest-api/filtering/ .
Still, can I query with some commands on NetBox Python Shell? https://netbox.readthedocs.io/en/stable/administration/netbox-shell/ this docs only contains existing objects. I'd like to find how to get query filter keys.

Thanks again for your help.

Reply all
Reply to author
Forward
0 new messages