From dc8cf8dbccaebe6d9da81c63e3669012a835cb44 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 5 Aug 2018 14:36:32 +0200 Subject: [PATCH] Serialisation des ouvertures de ports individuelles --- api/serializers.py | 9 +++++++++ api/urls.py | 1 + api/views.py | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/api/serializers.py b/api/serializers.py index 05075606..9c0531ca 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -675,6 +675,15 @@ class SubnetPortsOpenSerializer(serializers.ModelSerializer): model = machines.IpType fields = ('type', 'domaine_ip_start', 'domaine_ip_stop', 'complete_prefixv6', 'ouverture_ports') +class InterfacePortsOpenSerializer(serializers.ModelSerializer): + port_lists = FirewallOuverturePortListSerializer(read_only=True, many=True) + ipv4 = serializers.CharField(source='ipv4.ipv4', read_only=True) + ipv6 = Ipv6ListSerializer(many=True, read_only=True) + + class Meta: + model = machines.Interface + fields = ('port_lists', 'ipv4', 'ipv6') + # DHCP diff --git a/api/urls.py b/api/urls.py index 3bcaee0e..19757c1d 100644 --- a/api/urls.py +++ b/api/urls.py @@ -103,6 +103,7 @@ router.register_view(r'dhcp/hostmacip', views.HostMacIpView), router.register_view(r'localemail/users', views.LocalEmailUsersView), # Firewall router.register_view(r'firewall/subnet-ports', views.SubnetPortsOpenView), +router.register_view(r'firewall/interface-ports', views.InterfacePortsOpenView), # DNS router.register_view(r'dns/zones', views.DNSZonesView), router.register_view(r'dns/reverse-zones', views.DNSReverseZonesView), diff --git a/api/views.py b/api/views.py index f284abbe..fae55d1e 100644 --- a/api/views.py +++ b/api/views.py @@ -544,6 +544,10 @@ class SubnetPortsOpenView(generics.ListAPIView): queryset = machines.IpType.objects.all() serializer_class = serializers.SubnetPortsOpenSerializer +class InterfacePortsOpenView(generics.ListAPIView): + queryset = machines.Interface.objects.filter(port_lists__isnull=False).distinct() + serializer_class = serializers.InterfacePortsOpenSerializer + # DNS