From 470b02be940391242dd2d4a6e161b66306b2a2ba Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Sat, 4 Aug 2018 10:53:34 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9pare=20l'API=20pour=20les=20Ports=20en?= =?UTF-8?q?=20ajoutant=20la=20s=C3=A9rialisation=20des=20PortProfile.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/serializers.py | 16 ++++++++++++++-- api/urls.py | 3 ++- api/views.py | 8 +++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/api/serializers.py b/api/serializers.py index 23a2b15e..d4e50702 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -470,10 +470,10 @@ class SwitchPortSerializer(NamespacedHMSerializer): class Meta: model = topologie.Port fields = ('switch', 'port', 'room', 'machine_interface', 'related', - 'radius', 'vlan_force', 'details', 'api_url') + 'custom_profile', 'state', 'details', 'api_url') extra_kwargs = { 'related': {'view_name': 'switchport-detail'}, - 'api_url': {'view_name': 'switchport-detail'} + 'api_url': {'view_name': 'switchport-detail'}, } @@ -485,6 +485,18 @@ class RoomSerializer(NamespacedHMSerializer): fields = ('name', 'details', 'api_url') +class PortProfileSerializer(NamespacedHMSerializer): + vlan_untagged = VlanSerializer(read_only=True) + + class Meta: + model = topologie.PortProfile + fields = ('name', 'profil_default', 'vlan_untagged', 'vlan_tagged', + 'radius_type', 'radius_mode', 'speed', 'mac_limit', + 'flow_control', 'dhcp_snooping', 'dhcpv6_snooping', + 'arp_protect', 'ra_guard', 'loop_protect', 'vlan_untagged', + 'vlan_tagged') + + # USERS diff --git a/api/urls.py b/api/urls.py index 37580db2..15a19d59 100644 --- a/api/urls.py +++ b/api/urls.py @@ -81,8 +81,9 @@ router.register_viewset(r'topologie/modelswitch', views.ModelSwitchViewSet) router.register_viewset(r'topologie/constructorswitch', views.ConstructorSwitchViewSet) router.register_viewset(r'topologie/switchbay', views.SwitchBayViewSet) router.register_viewset(r'topologie/building', views.BuildingViewSet) -router.register_viewset(r'topologie/switchport', views.SwitchPortViewSet, base_name='switchport') +router.register(r'topologie/switchport', views.SwitchPortViewSet, base_name='switchport') router.register_viewset(r'topologie/room', views.RoomViewSet) +router.register(r'topologie/portprofile', views.PortProfileViewSet) # USERS router.register_viewset(r'users/user', views.UserViewSet) router.register_viewset(r'users/club', views.ClubViewSet) diff --git a/api/views.py b/api/views.py index 715a31ac..f84903e6 100644 --- a/api/views.py +++ b/api/views.py @@ -403,6 +403,12 @@ class RoomViewSet(viewsets.ReadOnlyModelViewSet): serializer_class = serializers.RoomSerializer +class PortProfileViewSet(viewsets.ReadOnlyModelViewSet): + """Exposes list and details of `topologie.models.PortProfile` objects. + """ + queryset = topologie.PortProfile.objects.all() + serializer_class = serializers.PortProfileSerializer + # USER @@ -542,7 +548,7 @@ class SubnetPortsOpenView(generics.ListAPIView): class DNSZonesView(generics.ListAPIView): - """Exposes the detailed information about each extension (hostnames, + """Exposes the detailed information about each extension (hostnames, IPs, DNS records, etc.) in order to build the DNS zone files. """ queryset = (machines.Extension.objects