genericparser seed code
[modeling/etsicatalog.git] / genericparser / 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     )
28     vnfd = LinkSerializer(
29         help_text='Link to the VNFD resource.',
30         required=False,
31         allow_null=False
32     )
33     packageContent = LinkSerializer(
34         help_text='Link to the "VNF package content resource.',
35         required=True,
36         allow_null=False
37     )
38
39     class Meta:
40         ref_name = 'VNF_PKGM_Link_Serializer'
41
42
43 class VnfPkgInfoSerializer(serializers.Serializer):
44     id = serializers.CharField(
45         help_text="Identifier of the on-boarded VNF package.",
46         required=True,
47         allow_null=False,
48         allow_blank=False
49     )
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.",
53         required=False,
54         allow_null=True,
55         allow_blank=True
56     )
57     vnfProvider = serializers.CharField(
58         help_text="Provider of the VNF package and the VNFD.",
59         required=False,
60         allow_null=True,
61         allow_blank=True
62     )
63     vnfProductName = serializers.CharField(
64         help_text="Name to identify the VNF product.",
65         required=False,
66         allow_null=True,
67         allow_blank=True
68     )
69     vnfSoftwareVersion = serializers.CharField(
70         help_text="Software version of the VNF.",
71         required=False,
72         allow_null=True,
73         allow_blank=True
74     )
75     vnfdVersion = serializers.CharField(
76         help_text="The version of the VNvFD.",
77         required=False,
78         allow_null=True,
79         allow_blank=True
80     )
81     checksum = ChecksumSerializer(
82         help_text="Checksum of the on-boarded VNF package.",
83         required=False,
84         allow_null=True
85     )
86     softwareImages = VnfPackageSoftwareImageInfoSerializer(
87         help_text="Information about VNF package artifacts that are software images.",
88         required=False,
89         allow_null=True,
90         many=True
91     )
92     additionalArtifacts = VnfPackageArtifactInfoSerializer(
93         help_text="Information about VNF package artifacts contained in "
94         "the VNF package that are not software images.",
95         required=False,
96         allow_null=True,
97         many=True
98     )
99     onboardingState = serializers.ChoiceField(
100         help_text="On-boarding state of the VNF package.",
101         choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"],
102         required=True,
103         allow_null=True
104     )
105     operationalState = serializers.ChoiceField(
106         help_text="Operational state of the VNF package.",
107         choices=["ENABLED", "DISABLED"],
108         required=True,
109         allow_null=True
110     )
111     usageState = serializers.ChoiceField(
112         help_text="Usage state of the VNF package.",
113         choices=["IN_USE", "NOT_IN_USE"],
114         required=True,
115         allow_null=True
116     )
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),
120         required=False,
121         allow_null=True
122     )
123     _links = _LinkSerializer(
124         help_text='Links to resources related to this resource.',
125         required=True,
126         allow_null=True  # TODO supposed to be False
127     )