mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from rest_framework import generics
|
|
|
|
from tenancy.models import Tenant, TenantGroup
|
|
from tenancy.filters import TenantFilter
|
|
|
|
from extras.api.views import CustomFieldModelAPIView
|
|
from . import serializers
|
|
|
|
|
|
class TenantGroupListView(generics.ListAPIView):
|
|
"""
|
|
List all tenant groups
|
|
"""
|
|
queryset = TenantGroup.objects.all()
|
|
serializer_class = serializers.TenantGroupSerializer
|
|
|
|
|
|
class TenantGroupDetailView(generics.RetrieveAPIView):
|
|
"""
|
|
Retrieve a single circuit type
|
|
"""
|
|
queryset = TenantGroup.objects.all()
|
|
serializer_class = serializers.TenantGroupSerializer
|
|
|
|
|
|
class TenantListView(CustomFieldModelAPIView, generics.ListAPIView):
|
|
"""
|
|
List tenants (filterable)
|
|
"""
|
|
queryset = Tenant.objects.select_related('group').prefetch_related('custom_field_values__field')
|
|
serializer_class = serializers.TenantSerializer
|
|
filter_class = TenantFilter
|
|
|
|
|
|
class TenantDetailView(CustomFieldModelAPIView, generics.RetrieveAPIView):
|
|
"""
|
|
Retrieve a single tenant
|
|
"""
|
|
queryset = Tenant.objects.select_related('group').prefetch_related('custom_field_values__field')
|
|
serializer_class = serializers.TenantSerializer
|