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.',
28 vnfd = LinkSerializer(
29 help_text='Link to the VNFD resource.',
33 packageContent = LinkSerializer(
34 help_text='Link to the "VNF package content resource.',
40 ref_name = 'VNF_PKGM_Link_Serializer'
43 class VnfPkgInfoSerializer(serializers.Serializer):
44 id = serializers.CharField(
45 help_text="Identifier of the on-boarded VNF package.",
50 vnfdId = serializers.CharField(
51 help_text="This identifier, which is managed by the VNF provider, "
52 "identifies the VNF package and the VNFD in a globally unique way.",
57 vnfProvider = serializers.CharField(
58 help_text="Provider of the VNF package and the VNFD.",
63 vnfProductName = serializers.CharField(
64 help_text="Name to identify the VNF product.",
69 vnfSoftwareVersion = serializers.CharField(
70 help_text="Software version of the VNF.",
75 vnfdVersion = serializers.CharField(
76 help_text="The version of the VNvFD.",
81 checksum = ChecksumSerializer(
82 help_text="Checksum of the on-boarded VNF package.",
86 softwareImages = VnfPackageSoftwareImageInfoSerializer(
87 help_text="Information about VNF package artifacts that are software images.",
92 additionalArtifacts = VnfPackageArtifactInfoSerializer(
93 help_text="Information about VNF package artifacts contained in "
94 "the VNF package that are not software images.",
99 onboardingState = serializers.ChoiceField(
100 help_text="On-boarding state of the VNF package.",
101 choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"],
105 operationalState = serializers.ChoiceField(
106 help_text="Operational state of the VNF package.",
107 choices=["ENABLED", "DISABLED"],
111 usageState = serializers.ChoiceField(
112 help_text="Usage state of the VNF package.",
113 choices=["IN_USE", "NOT_IN_USE"],
117 userDefinedData = serializers.DictField(
118 help_text="User defined data for the VNF package.",
119 child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
123 _links = _LinkSerializer(
124 help_text='Links to resources related to this resource.',
126 allow_null=True # TODO supposed to be False