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 = serializers.ListField(
47 child=VersionSerializer(),
48 help_text="match VNF packages that contain "
49 "VNF products with certain versions",
55 class vnfProductsProvidersSerializer(serializers.Serializer):
56 vnfProvider = serializers.CharField(
57 help_text="Name of the VNFprovider to match.",
62 vnfProducts = serializers.ListField(
63 child=vnfProductsSerializer(),
64 help_text="match VNF packages that contain "
65 "VNF products with certain product names, "
66 "from one particular provider",
72 class PkgmNotificationsFilter(serializers.Serializer):
73 notificationTypes = serializers.ListField(
74 child=serializers.ChoiceField(
76 choices=NOTIFICATION_TYPES
78 help_text="Match particular notification types",
82 vnfProductsFromProviders = serializers.ListField(
83 child=vnfProductsProvidersSerializer(),
84 help_text="Match VNF packages that contain "
85 "VNF products from certain providers.",
89 vnfdId = serializers.ListField(
90 child=serializers.CharField(),
91 help_text="Match VNF packages with a VNFD identifier"
92 "listed in the attribute",
96 vnfPkgId = serializers.ListField(
97 child=serializers.CharField(),
98 help_text="Match VNF packages with a VNFD identifier"
99 "listed in the attribute",
103 operationalState = serializers.ListField(
104 child=serializers.ChoiceField(
106 choices=PackageOperationalStateType
108 help_text="Operational state of the VNF package.",
112 usageState = serializers.ListField(
113 child=serializers.ChoiceField(
115 choices=PackageUsageStateType
117 help_text="Operational state of the VNF package.",
123 class LinkSerializer(serializers.Serializer):
124 href = serializers.CharField(
125 help_text="URI of the referenced resource.",
132 ref_name = 'NOTIFICATION_LINKSERIALIZER'
135 class PkgmLinksSerializer(serializers.Serializer):
136 vnfPackage = LinkSerializer(
137 help_text="Link to the resource representing the VNF package to which the notified change applies.",
141 subscription = LinkSerializer(
142 help_text="Link to the related subscription.",
148 class PkgChangeNotificationSerializer(serializers.Serializer):
149 id = serializers.CharField(
150 help_text="Identifier of this notification.",
154 notificationType = serializers.ChoiceField(
155 help_text="Discriminator for the different notification types.",
156 choices=["VnfPackageChangeNotification"],
160 timeStamp = serializers.DateTimeField(
161 help_text="Date-time of the generation of the notification.",
162 format="%Y-%m-%d %H:%M:%S",
166 subscriptionId = serializers.CharField(
167 help_text="Identifier of the subscription that this notification relates to.",
171 vnfPkgId = serializers.CharField(
172 help_text="Identifier of the VNF package.",
176 vnfdId = serializers.CharField(
177 help_text="This identifier, which is managed by the VNF provider, "
178 "identifies the VNF package and the VNFD in a globally unique way.",
182 changeType = serializers.ChoiceField(
183 help_text="The type of change of the VNF package.",
184 choices=PackageChangeType,
188 operationalState = serializers.ChoiceField(
189 help_text="New operational state of the VNF package.",
190 choices=PackageOperationalStateType,
194 vnfdId = serializers.CharField(
195 help_text="This identifier, which is managed by the VNF provider, "
196 "identifies the VNF package and the VNFD in a globally unique way.",
200 _links = PkgmLinksSerializer(
201 help_text="Links to resources related to this resource.",
207 class PkgOnboardingNotificationSerializer(serializers.Serializer):
208 id = serializers.CharField(
209 help_text="Identifier of this notification.",
213 notificationType = serializers.ChoiceField(
214 help_text="Discriminator for the different notification types.",
215 choices=["VnfPackageOnboardingNotification"],
219 subscriptionId = serializers.CharField(
220 help_text="Identifier of the subscription that this notification relates to.",
224 timeStamp = serializers.DateTimeField(
225 help_text="Date-time of the generation of the notification.",
226 format="%Y-%m-%d %H:%M:%S",
230 vnfPkgId = serializers.CharField(
231 help_text="Identifier of the VNF package.",
235 vnfdId = serializers.CharField(
236 help_text="This identifier, which is managed by the VNF provider, "
237 "identifies the VNF package and the VNFD in a globally unique way.",
241 _links = PkgmLinksSerializer(
242 help_text="Links to resources related to this resource.",