Add metadata id check for vnf/pnf pkg
[vfc/nfvo/catalog.git] / catalog / packages / serializers / nsd_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 problem_details import ProblemDetailsSerializer
17 from link import LinkSerializer
18
19
20 class _LinkSerializer(serializers.Serializer):
21     self = LinkSerializer(
22         help_text='URI of this resource.',
23         required=True,
24         allow_null=False
25     )
26     nsd_content = LinkSerializer(
27         help_text='Link to the NSD content resource.',
28         required=True,
29         allow_null=False
30     )
31
32
33 class NsdInfoSerializer(serializers.Serializer):
34     id = serializers.CharField(
35         help_text='Identifier of the onboarded individual NS descriptor resource. \
36         This identifier is allocated by the NFVO.',
37         required=True,
38         allow_null=False,
39         allow_blank=False
40     )
41     nsdId = serializers.CharField(
42         help_text='This identifier, which is allocated by the NSD designer, \
43         identifies the NSD in a globally unique way. \
44         It is copied from the NSD content and shall be present after the NSD content is on-boarded.',
45         required=False,
46         allow_null=True,
47         allow_blank=True
48     )
49     nsdName = serializers.CharField(
50         help_text='Name of the onboarded NSD. \
51         This information is copied from the NSD content and shall be present after the NSD content is on-boarded.',
52         required=False,
53         allow_null=True,
54         allow_blank=True
55     )
56     nsdVersion = serializers.CharField(  # TODO: data type is version
57         help_text='Version of the on-boarded NSD. \
58         This information is copied from the NSD content and shall be present after the NSD content is on-boarded.',
59         required=False,
60         allow_null=True,
61         allow_blank=True
62     )
63     nsdDesigner = serializers.CharField(
64         help_text='Designer of the on-boarded NSD. \
65         This information is copied from the NSD content and shall be present after the NSD content is on-boarded.',
66         required=False,
67         allow_null=True,
68         allow_blank=True
69     )
70     nsdInvariantId = serializers.CharField(
71         help_text='This identifier, which is allocated by the NSD designer, \
72         identifies an NSD in a version independent manner. \
73         This information is copied from the NSD content and shall be present after the NSD content is on-boarded.',
74         required=False,
75         allow_null=True,
76         allow_blank=True
77     )
78     vnfPkgIds = serializers.ListSerializer(
79         help_text='Identifies the VNF package for the VNFD referenced by the on-boarded NS descriptor resource.',
80         child=serializers.CharField(help_text="Identifier of the VNF package", allow_blank=True),
81         required=False,
82         allow_null=True,
83         allow_empty=True
84     )
85     pnfdInfoIds = serializers.ListSerializer(
86         help_text='Identifies the PnfdInfo element for the PNFD referenced by the on-boarded NS descriptor resource.',
87         child=serializers.CharField(help_text="Identifier of the PnfdInfo element", allow_blank=True),
88         required=False,
89         allow_null=True,
90         allow_empty=True
91     )
92     nestedNsdInfoIds = serializers.ListSerializer(
93         help_text='Identifies the NsdInfo element for the nested NSD referenced by the on-boarded NS descriptor resource.',
94         child=serializers.CharField(help_text="Identifier of the NsdInfo element", allow_blank=True),
95         required=False,
96         allow_null=True,
97         allow_empty=True
98     )
99     nsdOnboardingState = serializers.ChoiceField(
100         help_text='Onboarding state of the individual NS descriptor resource.',
101         choices=['CREATED', 'UPLOADING', 'PROCESSING', 'ONBOARDED'],
102         required=True,
103         allow_null=False,
104         allow_blank=False
105     )
106     onboardingFailureDetails = ProblemDetailsSerializer(
107         help_text='Failure details of current onboarding procedure. \
108         It shall be present when the "nsdOnboardingState" attribute is CREATED and the uploading or processing fails in NFVO.',
109         required=False,
110         allow_null=True,
111     )
112     nsdOperationalState = serializers.ChoiceField(
113         help_text='Operational state of the individual NS descriptor resource. \
114         This attribute can be modified with the PATCH method.',
115         choices=['ENABLED', 'DISABLED'],
116         required=True,
117         allow_null=False,
118         allow_blank=False
119     )
120     nsdUsageState = serializers.ChoiceField(
121         help_text='Usage state of the individual NS descriptor resource.',
122         choices=['IN_USE', 'NOT_IN_USE'],
123         required=True,
124         allow_null=False,
125     )
126     userDefinedData = serializers.DictField(
127         help_text='User defined data for the individual NS descriptor resource. \
128         This attribute can be modified with the PATCH method.',
129         child=serializers.CharField(help_text='Key Value Pairs', allow_blank=True),
130         required=False,
131         allow_null=True
132     )
133     _links = _LinkSerializer(
134         help_text='Links to resources related to this resource.',
135         required=True,
136         allow_null=True  # TODO: supposed to be False
137     )