mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-19 20:02:22 -06:00
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
23 lines
745 B
Python
23 lines
745 B
Python
from ipam.models import Role
|
|
from netbox.api.fields import RelatedObjectCountField
|
|
from netbox.api.serializers import OrganizationalModelSerializer
|
|
|
|
__all__ = (
|
|
'RoleSerializer',
|
|
)
|
|
|
|
|
|
class RoleSerializer(OrganizationalModelSerializer):
|
|
|
|
# Related object counts
|
|
prefix_count = RelatedObjectCountField('prefixes')
|
|
vlan_count = RelatedObjectCountField('vlans')
|
|
|
|
class Meta:
|
|
model = Role
|
|
fields = [
|
|
'id', 'url', 'display_url', 'display', 'name', 'slug', 'weight', 'description', 'owner', 'tags',
|
|
'custom_fields', 'created', 'last_updated', 'prefix_count', 'vlan_count',
|
|
]
|
|
brief_fields = ('id', 'url', 'display', 'name', 'slug', 'description', 'prefix_count', 'vlan_count')
|