X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog%2Fpackages%2Fserializers%2Fvnf_pkg_notifications.py;h=c1dab6a6fbdd9305febd46e1306727678dd9833e;hb=a40cb469e3aa364fb2a0f016632bc642b4ecbdb7;hp=5e023af06b26c6946180819c384c263a41c54369;hpb=a32c2b20207885d895bd96204cc166fca14db97b;p=modeling%2Fetsicatalog.git diff --git a/catalog/packages/serializers/vnf_pkg_notifications.py b/catalog/packages/serializers/vnf_pkg_notifications.py index 5e023af..c1dab6a 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): @@ -43,7 +43,8 @@ class vnfProductsSerializer(serializers.Serializer): required=True, allow_null=False ) - versions = VersionSerializer( + versions = serializers.ListField( + child=VersionSerializer(), help_text="match VNF packages that contain " "VNF products with certain versions", required=False, @@ -58,7 +59,8 @@ class vnfProductsProvidersSerializer(serializers.Serializer): required=True, allow_null=False ) - vnfProducts = vnfProductsSerializer( + vnfProducts = serializers.ListField( + child=vnfProductsSerializer(), help_text="match VNF packages that contain " "VNF products with certain product names, " "from one particular provider", @@ -77,21 +79,22 @@ class PkgmNotificationsFilter(serializers.Serializer): allow_null=False, required=False ) - vnfProductsFromProviders = vnfProductsProvidersSerializer( + vnfProductsFromProviders = serializers.ListField( + child=vnfProductsProvidersSerializer(), help_text="Match VNF packages that contain " "VNF products from certain providers.", allow_null=False, required=False ) vnfdId = serializers.ListField( - child=serializers.UUIDField(), + child=serializers.CharField(), help_text="Match VNF packages with a VNFD identifier" "listed in the attribute", required=False, allow_null=False ) vnfPkgId = serializers.ListField( - child=serializers.UUIDField(), + child=serializers.CharField(), help_text="Match VNF packages with a VNFD identifier" "listed in the attribute", required=False, @@ -115,3 +118,128 @@ 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 PkgChangeNotificationSerializer(serializers.Serializer): + id = serializers.CharField( + help_text="Identifier of this notification.", + required=True, + allow_null=False + ) + notificationType = serializers.ChoiceField( + help_text="Discriminator for the different notification types.", + choices=["VnfPackageChangeNotification"], + required=True, + allow_null=False + ) + timeStamp = serializers.DateTimeField( + help_text="Date-time of the generation of the notification.", + format="%Y-%m-%d %H:%M:%S", + 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.CharField( + help_text="Identifier of the VNF package.", + required=True, + 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 + ) + changeType = serializers.ChoiceField( + help_text="The type of change of the VNF package.", + choices=PackageChangeType, + required=True, + 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 + ) + + +class PkgOnboardingNotificationSerializer(serializers.Serializer): + id = serializers.CharField( + help_text="Identifier of this notification.", + required=True, + allow_null=False + ) + notificationType = 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 + ) + timeStamp = serializers.DateTimeField( + help_text="Date-time of the generation of the notification.", + format="%Y-%m-%d %H:%M:%S", + required=True, + allow_null=False + ) + vnfPkgId = serializers.CharField( + help_text="Identifier of the VNF package.", + required=True, + 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 + )