Add metadata id check for vnf/pnf pkg
[vfc/nfvo/catalog.git] / catalog / packages / serializers / vnf_pkg_info.py
1 # Copyright 2018 ZTE Corporation.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
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
20
21
22 class _LinkSerializer(serializers.Serializer):
23     self = LinkSerializer(
24         help_text='URI of this resource.',
25         required=True,
26         allow_null=False)
27     vnfd = LinkSerializer(
28         help_text='Link to the VNFD resource.',
29         required=False,
30         allow_null=False)
31     packageContent = LinkSerializer(
32         help_text='Link to the "VNF package content resource.',
33         required=True,
34         allow_null=False)
35
36
37 class VnfPkgInfoSerializer(serializers.Serializer):
38     id = serializers.CharField(
39         help_text="Identifier of the on-boarded VNF package.",
40         required=True,
41         allow_null=False,
42         allow_blank=False)
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.",
46         required=False,
47         allow_null=True,
48         allow_blank=True)
49     vnfProvider = serializers.CharField(
50         help_text="Provider of the VNF package and the VNFD.",
51         required=False,
52         allow_null=True,
53         allow_blank=True)
54     vnfProductName = serializers.CharField(
55         help_text="Name to identify the VNF product.",
56         required=False,
57         allow_null=True,
58         allow_blank=True)
59     vnfSoftwareVersion = serializers.CharField(
60         help_text="Software version of the VNF.",
61         required=False,
62         allow_null=True,
63         allow_blank=True)
64     vnfdVersion = serializers.CharField(
65         help_text="The version of the VNvFD.",
66         required=False,
67         allow_null=True,
68         allow_blank=True)
69     checksum = ChecksumSerializer(
70         help_text="Checksum of the on-boarded VNF package.",
71         required=False,
72         allow_null=True,)
73     softwareImages = VnfPackageSoftwareImageInfoSerializer(
74         help_text="Information about VNF package artifacts that are software images.",
75         required=False,
76         allow_null=True,
77         many=True)
78     additionalArtifacts = VnfPackageArtifactInfoSerializer(
79         help_text="Information about VNF package artifacts contained in the VNF package that are not software images.",
80         required=False,
81         allow_null=True,
82         many=True)
83     onboardingState = serializers.ChoiceField(
84         help_text="On-boarding state of the VNF package.",
85         choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"],
86         required=True,
87         allow_null=True)
88     operationalState = serializers.ChoiceField(
89         help_text="Operational state of the VNF package.",
90         choices=["ENABLED", "DISABLED"],
91         required=True,
92         allow_null=True)
93     usageState = serializers.ChoiceField(
94         help_text="Usage state of the VNF package.",
95         choices=["IN_USE", "NOT_IN_USE"],
96         required=True,
97         allow_null=True)
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),
101         required=False,
102         allow_null=True)
103     _links = _LinkSerializer(
104         help_text='Links to resources related to this resource.',
105         required=True,
106         allow_null=True  # TODO supposed to be False
107     )