1 # Copyright (C) 2019 Verizon. All Rights Reserved
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from rest_framework import serializers
16 from catalog.packages.const import NOTIFICATION_TYPES
18 PackageOperationalStateType = ["ENABLED", "DISABLED"]
19 PackageUsageStateType = ["IN_USE", "NOT_IN_USE"]
20 PackageChangeType = ["OP_STATE_CHANGE", "PKG_DELETE"]
23 class VersionSerializer(serializers.Serializer):
24 vnfSoftwareVersion = serializers.CharField(
25 help_text="VNF software version to match.",
30 vnfdVersions = serializers.ListField(
31 child=serializers.CharField(),
32 help_text="Match VNF packages that contain "
33 "VNF products with certain VNFD versions",
39 class vnfProductsSerializer(serializers.Serializer):
40 vnfProductName = serializers.CharField(
41 help_text="Name of the VNF product to match.",
46 versions = VersionSerializer(
47 help_text="match VNF packages that contain "
48 "VNF products with certain versions",
54 class vnfProductsProvidersSerializer(serializers.Serializer):
55 vnfProvider = serializers.CharField(
56 help_text="Name of the VNFprovider to match.",
61 vnfProducts = vnfProductsSerializer(
62 help_text="match VNF packages that contain "
63 "VNF products with certain product names, "
64 "from one particular provider",
70 class PkgmNotificationsFilter(serializers.Serializer):
71 notificationTypes = serializers.ListField(
72 child=serializers.ChoiceField(
74 choices=NOTIFICATION_TYPES
76 help_text="Match particular notification types",
80 vnfProductsFromProviders = serializers.ListField(
81 child=vnfProductsProvidersSerializer(),
82 help_text="Match VNF packages that contain "
83 "VNF products from certain providers.",
87 vnfdId = serializers.ListField(
88 child=serializers.UUIDField(),
89 help_text="Match VNF packages with a VNFD identifier"
90 "listed in the attribute",
94 vnfPkgId = serializers.ListField(
95 child=serializers.UUIDField(),
96 help_text="Match VNF packages with a VNFD identifier"
97 "listed in the attribute",
101 operationalState = serializers.ListField(
102 child=serializers.ChoiceField(
104 choices=PackageOperationalStateType
106 help_text="Operational state of the VNF package.",
110 usageState = serializers.ListField(
111 child=serializers.ChoiceField(
113 choices=PackageUsageStateType
115 help_text="Operational state of the VNF package.",
121 class LinkSerializer(serializers.Serializer):
122 href = serializers.CharField(
123 help_text="URI of the referenced resource.",
130 ref_name = 'NOTIFICATION_LINKSERIALIZER'
133 class PkgmLinksSerializer(serializers.Serializer):
134 vnfPackage = LinkSerializer(
135 help_text="Link to the resource representing the VNF package to which the notified change applies.",
139 subscription = LinkSerializer(
140 help_text="Link to the related subscription.",
146 class PkgChangeNotificationSerializer(serializers.Serializer):
147 id = serializers.CharField(
148 help_text="Identifier of this notification.",
152 notificationTypes = serializers.ChoiceField(
153 help_text="Discriminator for the different notification types.",
154 choices=["VnfPackageChangeNotification"],
158 subscriptionId = serializers.CharField(
159 help_text="Identifier of the subscription that this notification relates to.",
163 vnfPkgId = serializers.UUIDField(
164 help_text="Identifier of the VNF package.",
168 vnfdId = serializers.UUIDField(
169 help_text="This identifier, which is managed by the VNF provider, "
170 "identifies the VNF package and the VNFD in a globally unique way.",
174 changeType = serializers.ChoiceField(
175 help_text="The type of change of the VNF package.",
176 choices=PackageChangeType,
180 operationalState = serializers.ChoiceField(
181 help_text="New operational state of the VNF package.",
182 choices=PackageOperationalStateType,
186 vnfdId = serializers.CharField(
187 help_text="This identifier, which is managed by the VNF provider, "
188 "identifies the VNF package and the VNFD in a globally unique way.",
192 _links = PkgmLinksSerializer(
193 help_text="Links to resources related to this resource.",
199 class PkgOnboardingNotificationSerializer(serializers.Serializer):
200 id = serializers.CharField(
201 help_text="Identifier of this notification.",
205 notificationTypes = serializers.ChoiceField(
206 help_text="Discriminator for the different notification types.",
207 choices=["VnfPackageOnboardingNotification"],
211 subscriptionId = serializers.CharField(
212 help_text="Identifier of the subscription that this notification relates to.",
216 vnfPkgId = serializers.UUIDField(
217 help_text="Identifier of the VNF package.",
221 vnfdId = serializers.UUIDField(
222 help_text="This identifier, which is managed by the VNF provider, "
223 "identifies the VNF package and the VNFD in a globally unique way.",
227 _links = PkgmLinksSerializer(
228 help_text="Links to resources related to this resource.",