genericparser seed code
[modeling/etsicatalog.git] / genericparser / 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     class Meta:
33         ref_name = "NSD_LinkSerializer"
34
35
36 class NsdInfoSerializer(serializers.Serializer):
37     id = serializers.CharField(
38         help_text="Identifier of the onboarded individual NS descriptor resource."
39         "This identifier is allocated by the NFVO.",
40         required=True,
41         allow_null=False,
42         allow_blank=False
43     )
44     nsdId = serializers.CharField(
45         help_text="This identifier, which is allocated by the NSD designer,"
46         "identifies the NSD in a globally unique way."
47         "It is copied from the NSD content and shall be present after the "
48         "NSD content is on-boarded.",
49         required=False,
50         allow_null=True,
51         allow_blank=True
52     )
53     nsdName = serializers.CharField(
54         help_text="Name of the onboarded NSD."
55         "This information is copied from the NSD content and shall be present "
56         "after the NSD content is on-boarded.",
57         required=False,
58         allow_null=True,
59         allow_blank=True
60     )
61     nsdVersion = serializers.CharField(  # TODO: data type is version
62         help_text="Version of the on-boarded NSD."
63         "This information is copied from the NSD content and shall be "
64         "present after the NSD content is on-boarded.",
65         required=False,
66         allow_null=True,
67         allow_blank=True
68     )
69     nsdDesigner = serializers.CharField(
70         help_text="Designer of the on-boarded NSD."
71         "This information is copied from the NSD content and shall be "
72         "present after the NSD content is on-boarded.",
73         required=False,
74         allow_null=True,
75         allow_blank=True
76     )
77     nsdInvariantId = serializers.CharField(
78         help_text="This identifier, which is allocated by the NSD designer,"
79         "identifies an NSD in a version independent manner."
80         "This information is copied from the NSD content and shall be "
81         "present after the NSD content is on-boarded.",
82         required=False,
83         allow_null=True,
84         allow_blank=True
85     )
86     vnfPkgIds = serializers.ListSerializer(
87         help_text="Identifies the VNF package for the VNFD referenced "
88         "by the on-boarded NS descriptor resource.",
89         child=serializers.CharField(
90             help_text="Identifier of the VNF package",
91             allow_blank=True
92         ),
93         required=False,
94         allow_null=True,
95         allow_empty=True
96     )
97     pnfdInfoIds = serializers.ListSerializer(
98         help_text="Identifies the PnfdInfo element for the PNFD referenced "
99         "by the on-boarded NS descriptor resource.",
100         child=serializers.CharField(
101             help_text="Identifier of the PnfdInfo element",
102             allow_blank=True
103         ),
104         required=False,
105         allow_null=True,
106         allow_empty=True
107     )
108     nestedNsdInfoIds = serializers.ListSerializer(
109         help_text="Identifies the NsdInfo element for the nested NSD referenced "
110         "by the on-boarded NS descriptor resource.",
111         child=serializers.CharField(
112             help_text="Identifier of the NsdInfo element",
113             allow_blank=True
114         ),
115         required=False,
116         allow_null=True,
117         allow_empty=True
118     )
119     nsdOnboardingState = serializers.ChoiceField(
120         help_text="Onboarding state of the individual NS descriptor resource.",
121         choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"],
122         required=True,
123         allow_null=False,
124         allow_blank=False
125     )
126     onboardingFailureDetails = ProblemDetailsSerializer(
127         help_text="Failure details of current onboarding procedure."
128         "It shall be present when the nsdOnboardingState attribute is CREATED "
129         "and the uploading or processing fails in NFVO.",
130         required=False,
131         allow_null=True,
132     )
133     nsdOperationalState = serializers.ChoiceField(
134         help_text="Operational state of the individual NS descriptor resource."
135         "This attribute can be modified with the PATCH method.",
136         choices=["ENABLED", "DISABLED"],
137         required=True,
138         allow_null=False,
139         allow_blank=False
140     )
141     nsdUsageState = serializers.ChoiceField(
142         help_text="Usage state of the individual NS descriptor resource.",
143         choices=["IN_USE", "NOT_IN_USE"],
144         required=True,
145         allow_null=False,
146     )
147     userDefinedData = serializers.DictField(
148         help_text="User defined data for the individual NS descriptor resource."
149         "This attribute can be modified with the PATCH method.",
150         child=serializers.CharField(
151             help_text="Key Value Pairs",
152             allow_blank=True
153         ),
154         required=False,
155         allow_null=True
156     )
157     _links = _LinkSerializer(
158         help_text="Links to resources related to this resource.",
159         required=True,
160         allow_null=True  # TODO: supposed to be False
161     )