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 .problem_details import ProblemDetailsSerializer
17 from .link import UriLinkSerializer
20 class _LinkSerializer(serializers.Serializer):
21 self = UriLinkSerializer(
22 help_text="URI of this resource.",
26 nsd_content = UriLinkSerializer(
27 help_text="Link to the NSD content resource.",
33 ref_name = "NSD_LinkSerializer"
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.",
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.",
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.",
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.",
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.",
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.",
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",
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",
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",
119 nsdOnboardingState = serializers.ChoiceField(
120 help_text="Onboarding state of the individual NS descriptor resource.",
121 choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"],
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.",
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"],
141 nsdUsageState = serializers.ChoiceField(
142 help_text="Usage state of the individual NS descriptor resource.",
143 choices=["IN_USE", "NOT_IN_USE"],
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",
157 _links = _LinkSerializer(
158 help_text="Links to resources related to this resource.",
160 allow_null=True # TODO: supposed to be False