Modify notification endpoint interface definition in swagger 45/99545/1
authorhongyuzhao <zhao.hongyu@zte.com.cn>
Thu, 12 Dec 2019 03:41:20 +0000 (11:41 +0800)
committerhongyuzhao <zhao.hongyu@zte.com.cn>
Thu, 12 Dec 2019 03:44:07 +0000 (11:44 +0800)
Change-Id: I8b5bae05d5983dee0bb0ae01f7438094768b3def
Issue-ID: MODELING-288
Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
catalog/packages/serializers/vnf_pkg_notifications.py
catalog/packages/urls.py
catalog/packages/views/vnf_package_subscription_views.py

index ee2b99c..0c1b395 100644 (file)
@@ -142,20 +142,17 @@ class PkgmLinksSerializer(serializers.Serializer):
     )
 
 
-class PkgNotificationSerializer(serializers.Serializer):
+class PkgChangeNotificationSerializer(serializers.Serializer):
     id = serializers.CharField(
         help_text="Identifier of this notification.",
         required=True,
         allow_null=False
     )
-    notificationTypes = serializers.ListField(
-        child=serializers.ChoiceField(
-            required=True,
-            choices=NOTIFICATION_TYPES
-        ),
+    notificationTypes = serializers.ChoiceField(
         help_text="Discriminator for the different notification types.",
-        allow_null=True,
-        required=False
+        choices=["VnfPackageChangeNotification"],
+        required=True,
+        allow_null=False
     )
     subscriptionId = serializers.CharField(
         help_text="Identifier of the subscription that this notification relates to.",
@@ -176,7 +173,7 @@ class PkgNotificationSerializer(serializers.Serializer):
     changeType = serializers.ChoiceField(
         help_text="The type of change of the VNF package.",
         choices=PackageChangeType,
-        required=False,
+        required=True,
         allow_null=False
     )
     operationalState = serializers.ChoiceField(
@@ -196,3 +193,38 @@ class PkgNotificationSerializer(serializers.Serializer):
         required=True,
         allow_null=False
     )
+
+
+class PkgOnboardingNotificationSerializer(serializers.Serializer):
+    id = serializers.CharField(
+        help_text="Identifier of this notification.",
+        required=True,
+        allow_null=False
+    )
+    notificationTypes = serializers.ChoiceField(
+        help_text="Discriminator for the different notification types.",
+        choices=["VnfPackageOnboardingNotification"],
+        required=True,
+        allow_null=False
+    )
+    subscriptionId = serializers.CharField(
+        help_text="Identifier of the subscription that this notification relates to.",
+        required=True,
+        allow_null=False
+    )
+    vnfPkgId = serializers.UUIDField(
+        help_text="Identifier of the VNF package.",
+        required=True,
+        allow_null=False
+    )
+    vnfdId = serializers.UUIDField(
+        help_text="This identifier, which is managed by the VNF provider, "
+                  "identifies the VNF package and the VNFD in a globally unique way.",
+        required=True,
+        allow_null=False
+    )
+    _links = PkgmLinksSerializer(
+        help_text="Links to resources related to this resource.",
+        required=True,
+        allow_null=False
+    )
index 6b3ea7a..26a5fa9 100644 (file)
@@ -16,7 +16,7 @@ from django.conf.urls import url
 
 from catalog.packages.views import vnf_package_views
 from catalog.packages.views.vnf_package_subscription_views import CreateQuerySubscriptionView,\
-    QueryTerminateSubscriptionView, PkgnotifyView
+    QueryTerminateSubscriptionView, PkgChangeNotificationView, PkgOnboardingNotificationView
 from catalog.packages.views.vnf_package_artifact_views import FetchVnfPkgmArtifactsView
 from catalog.packages.views import catalog_views, ns_descriptor_views, pnf_descriptor_views, nsdm_subscription_views
 from catalog.packages.views.health_check_views import HealthCheckView
@@ -61,7 +61,8 @@ urlpatterns = [
     url(r'^api/vnfpkgm/v1/subscriptions$', CreateQuerySubscriptionView.as_view(), name='subscriptions_create_query'),
     url(r'^api/vnfpkgm/v1/subscriptions/(?P<subscriptionId>[0-9a-zA-Z\-\_]+)$', QueryTerminateSubscriptionView.as_view(), name='subscriptions_query_terminate'),
     url(r'^api/vnfpkgm/v1/vnf_packages/(?P<vnfPkgId>[0-9a-zA-Z\-\_]+)/artifacts/(?P<artifactPath>[0-9a-zA-Z\-\_]+)$', FetchVnfPkgmArtifactsView.as_view(), name="fetch_vnf_artifacts"),
-    url(r'^callbackUri$', PkgnotifyView.as_view()),
+    url(r'^URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageOnboardingNotification$', PkgOnboardingNotificationView.as_view()),
+    url(r'^URI-is-provided-by-the-client-when-creating-the-sbuscription-VnfPackageChangeNotification$', PkgChangeNotificationView.as_view()),
 
     # health check
     url(r'^api/vnfpkgm/v1/health_check$', HealthCheckView.as_view()),
index 94977c3..6698429 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 import logging
-
+from drf_yasg import openapi
 from drf_yasg.utils import swagger_auto_schema
 from rest_framework import status
 from rest_framework.response import Response
@@ -27,7 +27,8 @@ from catalog.packages.serializers.response import ProblemDetailsSerializer
 from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionRequestSerializer
 from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionSerializer
 from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionsSerializer
-from catalog.packages.serializers.vnf_pkg_notifications import PkgNotificationSerializer
+from catalog.packages.serializers.vnf_pkg_notifications import PkgOnboardingNotificationSerializer
+from catalog.packages.serializers.vnf_pkg_notifications import PkgChangeNotificationSerializer
 from catalog.packages.views.common import validate_data, validate_req_data
 from catalog.pub.exceptions import BadRequestException
 from catalog.pub.exceptions import VnfPkgSubscriptionException
@@ -126,13 +127,45 @@ class QueryTerminateSubscriptionView(APIView):
         return Response(status=status.HTTP_204_NO_CONTENT)
 
 
-class PkgnotifyView(APIView):
+class PkgOnboardingNotificationView(APIView):
     @swagger_auto_schema(
         tags=[TAG_VNF_PACKAGE_API],
-        request_body=PkgNotificationSerializer,
+        request_body=PkgOnboardingNotificationSerializer,
         responses={
             status.HTTP_204_NO_CONTENT: ""
         }
     )
     def post(self):
         pass
+
+    @swagger_auto_schema(
+        tags=[TAG_VNF_PACKAGE_API],
+        responses={
+            status.HTTP_204_NO_CONTENT: "",
+            status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response('error message',
+                                                                    openapi.Schema(type=openapi.TYPE_STRING))}
+    )
+    def get(self):
+        pass
+
+
+class PkgChangeNotificationView(APIView):
+    @swagger_auto_schema(
+        tags=[TAG_VNF_PACKAGE_API],
+        request_body=PkgChangeNotificationSerializer,
+        responses={
+            status.HTTP_204_NO_CONTENT: ""
+        }
+    )
+    def post(self):
+        pass
+
+    @swagger_auto_schema(
+        tags=[TAG_VNF_PACKAGE_API],
+        responses={
+            status.HTTP_204_NO_CONTENT: "",
+            status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response('error message',
+                                                                    openapi.Schema(type=openapi.TYPE_STRING))}
+    )
+    def get(self):
+        pass