From 342b7c1173024afe4a485d262dc530c2c88a4224 Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Mon, 25 Jun 2018 17:35:40 +0200 Subject: [PATCH] serializers pour dnames --- api/serializers.py | 7 +++++++ api/urls.py | 1 + api/views.py | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/api/serializers.py b/api/serializers.py index 10d73349..bff1bd9c 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -191,6 +191,13 @@ class MxSerializer(NamespacedHMSerializer): fields = ('zone', 'priority', 'name', 'api_url') +class DNameSerializer(NamespacedHMSerializer): + """Serialize `machines.models.DName` objects. + """ + class Meta: + model = machines.DName + fields = ('zone', 'alias', 'api_url') + class NsSerializer(NamespacedHMSerializer): """Serialize `machines.models.Ns` objects. """ diff --git a/api/urls.py b/api/urls.py index 374436dc..2947850e 100644 --- a/api/urls.py +++ b/api/urls.py @@ -52,6 +52,7 @@ router.register_viewset(r'machines/extension', views.ExtensionViewSet) router.register_viewset(r'machines/mx', views.MxViewSet) router.register_viewset(r'machines/ns', views.NsViewSet) router.register_viewset(r'machines/txt', views.TxtViewSet) +router.register_viewset(r'machines/dname', views.DNameViewSet) router.register_viewset(r'machines/srv', views.SrvViewSet) router.register_viewset(r'machines/interface', views.InterfaceViewSet) router.register_viewset(r'machines/ipv6list', views.Ipv6ListViewSet) diff --git a/api/views.py b/api/views.py index 4b1b1246..45e083cc 100644 --- a/api/views.py +++ b/api/views.py @@ -163,6 +163,12 @@ class TxtViewSet(viewsets.ReadOnlyModelViewSet): queryset = machines.Txt.objects.all() serializer_class = serializers.TxtSerializer +class DNameViewSet(viewsets.ReadOnlyModelViewSet): + """Exposes list and details of `machines.models.DName` objects. + """ + queryset = machines.DName.objects.all() + serializer_class = serializers.DNameSerializer + class SrvViewSet(viewsets.ReadOnlyModelViewSet): """Exposes list and details of `machines.models.Srv` objects.