# 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
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
class CreateQuerySubscriptionView(APIView):
+ """
+ This resource represents subscriptions.
+ The client can use this resource to subscribe to notifications related to NS lifecycle management,
+ and to query its subscriptions.
+ """
@swagger_auto_schema(
tags=[TAG_VNF_PACKAGE_API],
)
@view_safe_call_with_log(logger=logger)
def post(self, request):
+ """
+ The POST method creates a new subscription
+ :param request:
+ :return:
+ """
logger.debug("Create VNF package Subscription> %s" % request.data)
vnf_pkg_subscription_request = validate_req_data(request.data, PkgmSubscriptionRequestSerializer)
data = CreateSubscription(vnf_pkg_subscription_request.data).do_biz()
)
@view_safe_call_with_log(logger=logger)
def get(self, request):
+ """
+ The GET method queries the list of active subscriptions of the functional block that invokes the method.
+ It can be used e.g. for resynchronization after error situations.
+ :param request:
+ :return:
+ """
logger.debug("SubscribeNotification--get::> %s" % request.query_params)
if request.query_params and not set(request.query_params).issubset(set(VALID_FILTERS)):
class QueryTerminateSubscriptionView(APIView):
+ """
+ This resource represents an individual subscription.
+ It can be used by the client to read and to terminate a subscription to Notifications related to NS lifecycle management.
+ """
@swagger_auto_schema(
tags=[TAG_VNF_PACKAGE_API],
)
@view_safe_call_with_log(logger=logger)
def get(self, request, subscriptionId):
+ """
+ The GET method retrieves information about a subscription by reading an individual subscription resource.
+ :param request:
+ :param subscriptionId:
+ :return:
+ """
logger.debug("SubscribeNotification--get::> %s" % subscriptionId)
resp_data = QuerySubscription().query_single_subscription(subscriptionId)
)
@view_safe_call_with_log(logger=logger)
def delete(self, request, subscriptionId):
+ """
+ The DELETE method terminates an individual subscription.
+ :param request:
+ :param subscriptionId:
+ :return:
+ """
logger.debug("SubscribeNotification--get::> %s" % subscriptionId)
TerminateSubscription().terminate(subscriptionId)
return Response(status=status.HTTP_204_NO_CONTENT)
-class PkgnotifyView(APIView):
+class PkgOnboardingNotificationView(APIView):
+ """
+ This resource represents a notification endpoint about package onboarding
+ """
+
@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):
+ """
+ This resource represents a notification endpoint about package change
+ """
+
+ @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