From 189d775690532a69c882902116d6f5572b157f0e Mon Sep 17 00:00:00 2001 From: fujinhua Date: Sat, 23 Mar 2019 15:44:06 +0800 Subject: Add serializer for Subscribe Change-Id: Iea14a6d0852bef83959499160b8e22f7403e0228 Issue-ID: VFC-1307 Signed-off-by: fujinhua --- zte/vmanager/driver/interfaces/serializers.py | 35 +++++++++++++++++++++++++++ zte/vmanager/driver/interfaces/views.py | 8 +++++- 2 files changed, 42 insertions(+), 1 deletion(-) (limited to 'zte/vmanager') diff --git a/zte/vmanager/driver/interfaces/serializers.py b/zte/vmanager/driver/interfaces/serializers.py index eafe0939..2e7cbae7 100644 --- a/zte/vmanager/driver/interfaces/serializers.py +++ b/zte/vmanager/driver/interfaces/serializers.py @@ -433,3 +433,38 @@ class InstScaleHealRespSerializer(serializers.Serializer): max_length=255, required=True, allow_null=True) + + +class SubscribeFilterSerializer(serializers.Serializer): + vendor = serializers.CharField( + help_text="vendor", + max_length=255, + required=True, + allow_null=True) + type = serializers.CharField( + help_text="type", + max_length=255, + required=True, + allow_null=True) + + +class SubscribeSerializer(serializers.Serializer): + subscribeid = serializers.CharField( + help_text="subscribeid", + max_length=255, + required=True, + allow_null=True) + notificationuri = serializers.CharField( + help_text="notificationuri", + max_length=255, + required=True, + allow_null=True) + filter = SubscribeFilterSerializer( + help_text="filter", + many=True, + required=False, + allow_null=True) + + +class SubscribesRespSerializer(serializers.Serializer): + child = SubscribeSerializer() diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index 54325b39..579da8d0 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -27,7 +27,7 @@ from django.http import StreamingHttpResponse from driver.interfaces.serializers import HealReqSerializer, InstScaleHealRespSerializer, ScaleReqSerializer, \ NotifyReqSerializer, GrantRespSerializer, GrantReqSerializer, JobQueryRespSerializer, TerminateVnfRequestSerializer, \ - InstantiateVnfRequestSerializer, QueryVnfResponseSerializer + InstantiateVnfRequestSerializer, QueryVnfResponseSerializer, SubscribesRespSerializer from driver.pub.config.config import VNF_FTP from driver.pub.utils import restcall from driver.pub.utils.restcall import req_by_msb @@ -628,6 +628,12 @@ class SampleList(APIView): class Subscribe(APIView): + @swagger_auto_schema( + responses={ + status.HTTP_200_OK: SubscribesRespSerializer(), + status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + } + ) def get(self, request): logger.debug("====Subscribe get====") resp_data = { -- cgit 1.2.3-korg