1 # Copyright 2018 ZTE Corporation.
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 checksum import ChecksumSerializer
17 from vnf_pkg_software_image_info import VnfPackageSoftwareImageInfoSerializer
18 from vnf_pkg_artifact_info import VnfPackageArtifactInfoSerializer
19 from link import LinkSerializer
22 class _LinkSerializer(serializers.Serializer):
23 self = LinkSerializer(
24 help_text='URI of this resource.',
27 vnfd = LinkSerializer(
28 help_text='Link to the VNFD resource.',
31 packageContent = LinkSerializer(
32 help_text='Link to the "VNF package content resource.',
37 class VnfPkgInfoSerializer(serializers.Serializer):
38 id = serializers.CharField(
39 help_text="Identifier of the on-boarded VNF package.",
43 vnfdId = serializers.CharField(
44 help_text="This identifier, which is managed by the VNF provider, identifies the VNF package \
45 and the VNFD in a globally unique way.",
49 vnfProvider = serializers.CharField(
50 help_text="Provider of the VNF package and the VNFD.",
54 vnfProductName = serializers.CharField(
55 help_text="Name to identify the VNF product.",
59 vnfSoftwareVersion = serializers.CharField(
60 help_text="Software version of the VNF.",
64 vnfdVersion = serializers.CharField(
65 help_text="The version of the VNvFD.",
69 checksum = ChecksumSerializer(
70 help_text="Checksum of the on-boarded VNF package.",
73 softwareImages = VnfPackageSoftwareImageInfoSerializer(
74 help_text="Information about VNF package artifacts that are software images.",
78 additionalArtifacts = VnfPackageArtifactInfoSerializer(
79 help_text="Information about VNF package artifacts contained in the VNF package that are not software images.",
83 onboardingState = serializers.ChoiceField(
84 help_text="On-boarding state of the VNF package.",
85 choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"],
88 operationalState = serializers.ChoiceField(
89 help_text="Operational state of the VNF package.",
90 choices=["ENABLED", "DISABLED"],
93 usageState = serializers.ChoiceField(
94 help_text="Usage state of the VNF package.",
95 choices=["IN_USE", "NOT_IN_USE"],
98 userDefinedData = serializers.DictField(
99 help_text="User defined data for the VNF package.",
100 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
103 _links = _LinkSerializer(
104 help_text='Links to resources related to this resource.',
106 allow_null=True # TODO supposed to be False