mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Introduce the wireless app and SSID model
This commit is contained in:
0
netbox/wireless/api/__init__.py
Normal file
0
netbox/wireless/api/__init__.py
Normal file
16
netbox/wireless/api/nested_serializers.py
Normal file
16
netbox/wireless/api/nested_serializers.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from netbox.api import WritableNestedSerializer
|
||||
from wireless.models import *
|
||||
|
||||
__all__ = (
|
||||
'NestedSSIDSerializer',
|
||||
)
|
||||
|
||||
|
||||
class NestedSSIDSerializer(WritableNestedSerializer):
|
||||
url = serializers.HyperlinkedIdentityField(view_name='wireless-api:ssid-detail')
|
||||
|
||||
class Meta:
|
||||
model = SSID
|
||||
fields = ['id', 'url', 'display', 'name']
|
||||
21
netbox/wireless/api/serializers.py
Normal file
21
netbox/wireless/api/serializers.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from dcim.api.serializers import NestedInterfaceSerializer
|
||||
from ipam.api.serializers import NestedVLANSerializer
|
||||
from netbox.api.serializers import PrimaryModelSerializer
|
||||
from wireless.models import *
|
||||
|
||||
__all__ = (
|
||||
'SSIDSerializer',
|
||||
)
|
||||
|
||||
|
||||
class SSIDSerializer(PrimaryModelSerializer):
|
||||
url = serializers.HyperlinkedIdentityField(view_name='wireless-api:ssid-detail')
|
||||
vlan = NestedVLANSerializer(required=False, allow_null=True)
|
||||
|
||||
class Meta:
|
||||
model = SSID
|
||||
fields = [
|
||||
'id', 'url', 'display', 'name', 'description', 'vlan',
|
||||
]
|
||||
12
netbox/wireless/api/urls.py
Normal file
12
netbox/wireless/api/urls.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from netbox.api import OrderedDefaultRouter
|
||||
from . import views
|
||||
|
||||
|
||||
router = OrderedDefaultRouter()
|
||||
router.APIRootView = views.WirelessRootView
|
||||
|
||||
# SSIDs
|
||||
router.register('ssids', views.SSIDViewSet)
|
||||
|
||||
app_name = 'wireless-api'
|
||||
urlpatterns = router.urls
|
||||
24
netbox/wireless/api/views.py
Normal file
24
netbox/wireless/api/views.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from rest_framework.routers import APIRootView
|
||||
|
||||
from extras.api.views import CustomFieldModelViewSet
|
||||
from wireless import filtersets
|
||||
from wireless.models import *
|
||||
from . import serializers
|
||||
|
||||
|
||||
class WirelessRootView(APIRootView):
|
||||
"""
|
||||
Wireless API root view
|
||||
"""
|
||||
def get_view_name(self):
|
||||
return 'Wireless'
|
||||
|
||||
|
||||
#
|
||||
# Providers
|
||||
#
|
||||
|
||||
class SSIDViewSet(CustomFieldModelViewSet):
|
||||
queryset = SSID.objects.prefetch_related('tags')
|
||||
serializer_class = serializers.SSIDSerializer
|
||||
filterset_class = filtersets.SSIDFilterSet
|
||||
Reference in New Issue
Block a user