mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-17 20:46:30 -06:00
REST API optimizations
This commit is contained in:
parent
2cb53a0f7e
commit
264652f2c3
@ -98,12 +98,13 @@ class AggregateSerializer(PrimaryModelSerializer):
|
|||||||
|
|
||||||
class FHRPGroupSerializer(PrimaryModelSerializer):
|
class FHRPGroupSerializer(PrimaryModelSerializer):
|
||||||
url = serializers.HyperlinkedIdentityField(view_name='ipam-api:fhrpgroup-detail')
|
url = serializers.HyperlinkedIdentityField(view_name='ipam-api:fhrpgroup-detail')
|
||||||
|
ip_addresses = NestedIPAddressSerializer(many=True, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = FHRPGroup
|
model = FHRPGroup
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'url', 'display', 'protocol', 'group_id', 'auth_type', 'auth_key', 'description', 'tags',
|
'id', 'url', 'display', 'protocol', 'group_id', 'auth_type', 'auth_key', 'description', 'ip_addresses',
|
||||||
'custom_fields', 'created', 'last_updated',
|
'tags', 'custom_fields', 'created', 'last_updated',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,13 +124,13 @@ class IPAddressViewSet(CustomFieldModelViewSet):
|
|||||||
#
|
#
|
||||||
|
|
||||||
class FHRPGroupViewSet(CustomFieldModelViewSet):
|
class FHRPGroupViewSet(CustomFieldModelViewSet):
|
||||||
queryset = FHRPGroup.objects.prefetch_related('tags')
|
queryset = FHRPGroup.objects.prefetch_related('ip_addresses', 'tags')
|
||||||
serializer_class = serializers.FHRPGroupSerializer
|
serializer_class = serializers.FHRPGroupSerializer
|
||||||
filterset_class = filtersets.FHRPGroupFilterSet
|
filterset_class = filtersets.FHRPGroupFilterSet
|
||||||
|
|
||||||
|
|
||||||
class FHRPGroupAssignmentViewSet(CustomFieldModelViewSet):
|
class FHRPGroupAssignmentViewSet(CustomFieldModelViewSet):
|
||||||
queryset = FHRPGroupAssignment.objects.prefetch_related('group')
|
queryset = FHRPGroupAssignment.objects.prefetch_related('group', 'object')
|
||||||
serializer_class = serializers.FHRPGroupAssignmentSerializer
|
serializer_class = serializers.FHRPGroupAssignmentSerializer
|
||||||
filterset_class = filtersets.FHRPGroupAssignmentFilterSet
|
filterset_class = filtersets.FHRPGroupAssignmentFilterSet
|
||||||
|
|
||||||
|
@ -95,3 +95,6 @@ class FHRPGroupAssignment(ChangeLoggedModel):
|
|||||||
ordering = ('priority', 'pk')
|
ordering = ('priority', 'pk')
|
||||||
unique_together = ('content_type', 'object_id', 'group')
|
unique_together = ('content_type', 'object_id', 'group')
|
||||||
verbose_name = 'FHRP group assignment'
|
verbose_name = 'FHRP group assignment'
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f'{self.object}: {self.group} ({self.priority})'
|
||||||
|
Loading…
Reference in New Issue
Block a user