mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Initial multitenancy implementation
This commit is contained in:
39
netbox/tenancy/api/views.py
Normal file
39
netbox/tenancy/api/views.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from rest_framework import generics
|
||||
|
||||
from tenancy.models import Tenant, TenantGroup
|
||||
from tenancy.filters import TenantFilter
|
||||
|
||||
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(generics.ListAPIView):
|
||||
"""
|
||||
List tenants (filterable)
|
||||
"""
|
||||
queryset = Tenant.objects.select_related('group')
|
||||
serializer_class = serializers.TenantSerializer
|
||||
filter_class = TenantFilter
|
||||
|
||||
|
||||
class TenantDetailView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Retrieve a single tenant
|
||||
"""
|
||||
queryset = Tenant.objects.select_related('group')
|
||||
serializer_class = serializers.TenantSerializer
|
Reference in New Issue
Block a user