Skip to content

Commit 29b75c0

Browse files
committed
add with_mask query parameter
1 parent 7a093a2 commit 29b75c0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

netbox_scripthelper/api/serializers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ class AvailableIPSerializer(serializers.Serializer):
3030
Representation of an IP address which does not exist in the database.
3131
"""
3232
def to_representation(self, instance):
33+
with_mask = self.context['request'].query_params.get('with_mask', 'True')
34+
35+
value = f"{instance}/{self.context['parent'].mask_length}"
36+
if with_mask == 'False':
37+
value = str(instance)
38+
3339
return {
34-
'id': f"{instance}/{self.context['parent'].mask_length}",
35-
'display': f"{instance}/{self.context['parent'].mask_length}",
40+
'id': value,
41+
'display': value,
3642
}

0 commit comments

Comments
 (0)