Skip to content

Commit 516841e

Browse files
committed
feat(serializer): ACLStandardRule: Adding new Source Fields to serializer
1 parent c512099 commit 516841e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

netbox_acls/api/serializers.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from django.contrib.contenttypes.models import ContentType
77
from drf_spectacular.utils import extend_schema_field
8-
from ipam.api.serializers import PrefixSerializer
8+
from ipam.api.serializers import PrefixSerializer, IPRangeSerializer, IPAddressSerializer, AggregateSerializer, ServiceSerializer
99
from netbox.api.fields import ContentTypeField
1010
from netbox.api.serializers import NetBoxModelSerializer
1111
from rest_framework import serializers
@@ -27,6 +27,7 @@
2727
"ACLExtendedRuleSerializer",
2828
]
2929

30+
3031
# Sets a standard error message for ACL rules with an action of remark, but no remark set.
3132
error_message_no_remark = "Action is set to remark, you MUST add a remark."
3233
# Sets a standard error message for ACL rules with an action of remark, but no source_prefix is set.
@@ -190,6 +191,30 @@ class ACLStandardRuleSerializer(NetBoxModelSerializer):
190191
default=None,
191192
nested=True
192193
)
194+
source_iprange = IPRangeSerializer(
195+
required=False,
196+
allow_null=True,
197+
default=None,
198+
nested=True
199+
)
200+
source_ipaddress = IPAddressSerializer(
201+
required=False,
202+
allow_null=True,
203+
default=None,
204+
nested=True
205+
)
206+
source_aggregate = AggregateSerializer(
207+
required=False,
208+
allow_null=True,
209+
default=None,
210+
nested=True
211+
)
212+
source_service = ServiceSerializer(
213+
required=False,
214+
allow_null=True,
215+
default=None,
216+
nested=True
217+
)
193218

194219
class Meta:
195220
"""
@@ -211,6 +236,10 @@ class Meta:
211236
"custom_fields",
212237
"last_updated",
213238
"source_prefix",
239+
"source_iprange",
240+
"source_ipaddress",
241+
"source_aggregate",
242+
"source_service",
214243
)
215244
brief_fields = ("id", "url", "display")
216245

0 commit comments

Comments
 (0)