mirror of
https://github.com/lucaspalomodevelop/netbox-acls.git
synced 2026-03-19 10:14:39 +00:00
* Associates hosts (devices, VMs, & virtual chassis) to each ACL * Add a card to the object page for each of the above * Update API & GraphQL * Add a bulk delete button for ACL models
63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
"""
|
|
Serializers control the translation of client data to and from Python objects,
|
|
while Django itself handles the database abstraction.
|
|
"""
|
|
|
|
from netbox.api.serializers import WritableNestedSerializer
|
|
from rest_framework import serializers
|
|
|
|
from ..models import AccessList, ACLExtendedRule, ACLStandardRule
|
|
|
|
__all__ = [
|
|
'NestedAccessListSerializer',
|
|
'NestedACLStandardRuleSerializer',
|
|
'NestedACLExtendedRuleSerializer'
|
|
]
|
|
|
|
class NestedAccessListSerializer(WritableNestedSerializer):
|
|
"""
|
|
Defines the nested serializer for the django AccessList model & associates it to a view.
|
|
"""
|
|
url = serializers.HyperlinkedIdentityField(
|
|
view_name='plugins-api:netbox_access_lists-api:accesslist-detail'
|
|
)
|
|
|
|
class Meta:
|
|
"""
|
|
Associates the django model ACLStandardRule & fields to the nested serializer.
|
|
"""
|
|
model = AccessList
|
|
fields = ('id', 'url', 'display', 'name')
|
|
|
|
|
|
class NestedACLStandardRuleSerializer(WritableNestedSerializer):
|
|
"""
|
|
Defines the nested serializer for the django ACLStandardRule model & associates it to a view.
|
|
"""
|
|
url = serializers.HyperlinkedIdentityField(
|
|
view_name='plugins-api:netbox_access_lists-api:aclstandardrule-detail'
|
|
)
|
|
|
|
class Meta:
|
|
"""
|
|
Associates the django model ACLStandardRule & fields to the nested serializer.
|
|
"""
|
|
model = ACLStandardRule
|
|
fields = ('id', 'url', 'display', 'index')
|
|
|
|
|
|
class NestedACLExtendedRuleSerializer(WritableNestedSerializer):
|
|
"""
|
|
Defines the nested serializer for the django ACLExtendedRule model & associates it to a view.
|
|
"""
|
|
url = serializers.HyperlinkedIdentityField(
|
|
view_name='plugins-api:netbox_access_lists-api:aclextendedrule-detail'
|
|
)
|
|
|
|
class Meta:
|
|
"""
|
|
Associates the django model ACLExtendedRule & fields to the nested serializer.
|
|
"""
|
|
model = ACLExtendedRule
|
|
fields = ('id', 'url', 'display', 'index')
|