summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog/packages/serializers/vnf_pkg_notifications.py83
-rw-r--r--catalog/packages/urls.py3
-rw-r--r--catalog/packages/views/vnf_package_subscription_views.py21
3 files changed, 99 insertions, 8 deletions
diff --git a/catalog/packages/serializers/vnf_pkg_notifications.py b/catalog/packages/serializers/vnf_pkg_notifications.py
index 5e023af..ee2b99c 100644
--- a/catalog/packages/serializers/vnf_pkg_notifications.py
+++ b/catalog/packages/serializers/vnf_pkg_notifications.py
@@ -13,11 +13,11 @@
# limitations under the License.
from rest_framework import serializers
-
from catalog.packages.const import NOTIFICATION_TYPES
PackageOperationalStateType = ["ENABLED", "DISABLED"]
PackageUsageStateType = ["IN_USE", "NOT_IN_USE"]
+PackageChangeType = ["OP_STATE_CHANGE", "PKG_DELETE"]
class VersionSerializer(serializers.Serializer):
@@ -115,3 +115,84 @@ class PkgmNotificationsFilter(serializers.Serializer):
allow_null=False,
required=False
)
+
+
+class LinkSerializer(serializers.Serializer):
+ href = serializers.CharField(
+ help_text="URI of the referenced resource.",
+ required=True,
+ allow_null=False,
+ allow_blank=False
+ )
+
+ class Meta:
+ ref_name = 'NOTIFICATION_LINKSERIALIZER'
+
+
+class PkgmLinksSerializer(serializers.Serializer):
+ vnfPackage = LinkSerializer(
+ help_text="Link to the resource representing the VNF package to which the notified change applies.",
+ required=False,
+ allow_null=False
+ )
+ subscription = LinkSerializer(
+ help_text="Link to the related subscription.",
+ required=False,
+ allow_null=False
+ )
+
+
+class PkgNotificationSerializer(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
+ ),
+ help_text="Discriminator for the different notification types.",
+ allow_null=True,
+ required=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
+ )
+ changeType = serializers.ChoiceField(
+ help_text="The type of change of the VNF package.",
+ choices=PackageChangeType,
+ required=False,
+ allow_null=False
+ )
+ operationalState = serializers.ChoiceField(
+ help_text="New operational state of the VNF package.",
+ choices=PackageOperationalStateType,
+ required=False,
+ allow_null=False
+ )
+ vnfdId = serializers.CharField(
+ 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
+ )
diff --git a/catalog/packages/urls.py b/catalog/packages/urls.py
index aa11883..6b3ea7a 100644
--- a/catalog/packages/urls.py
+++ b/catalog/packages/urls.py
@@ -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
+ QueryTerminateSubscriptionView, PkgnotifyView
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,6 +61,7 @@ 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()),
# health check
url(r'^api/vnfpkgm/v1/health_check$', HealthCheckView.as_view()),
diff --git a/catalog/packages/views/vnf_package_subscription_views.py b/catalog/packages/views/vnf_package_subscription_views.py
index 8d66fa9..94977c3 100644
--- a/catalog/packages/views/vnf_package_subscription_views.py
+++ b/catalog/packages/views/vnf_package_subscription_views.py
@@ -27,6 +27,7 @@ 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.views.common import validate_data, validate_req_data
from catalog.pub.exceptions import BadRequestException
from catalog.pub.exceptions import VnfPkgSubscriptionException
@@ -57,12 +58,8 @@ class CreateQuerySubscriptionView(APIView):
)
@view_safe_call_with_log(logger=logger)
def post(self, request):
- mydata = request.data
- # if hasattr(request.data, "lists"):
- # mydata = dict(request.data.lists())
- logger.debug("Create VNF package Subscription> %s" % mydata)
-
- vnf_pkg_subscription_request = validate_req_data(mydata, PkgmSubscriptionRequestSerializer)
+ 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()
subscription_info = validate_data(data, PkgmSubscriptionSerializer)
return Response(data=subscription_info.data, status=status.HTTP_201_CREATED)
@@ -127,3 +124,15 @@ class QueryTerminateSubscriptionView(APIView):
TerminateSubscription().terminate(subscriptionId)
return Response(status=status.HTTP_204_NO_CONTENT)
+
+
+class PkgnotifyView(APIView):
+ @swagger_auto_schema(
+ tags=[TAG_VNF_PACKAGE_API],
+ request_body=PkgNotificationSerializer,
+ responses={
+ status.HTTP_204_NO_CONTENT: ""
+ }
+ )
+ def post(self):
+ pass