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 LinkSerializer
20 class _LinkSerializer(serializers.Serializer):
21 self = LinkSerializer(
22 help_text='URI of this resource.',
26 pnfd_content = LinkSerializer(
27 help_text='Link to the PNFD content resource.',
33 class PnfdInfoSerializer(serializers.Serializer):
34 id = serializers.CharField(
35 help_text='Identifier of the onboarded individual PNF descriptor resource. \
36 This identifier is allocated by the NFVO.',
41 pnfdId = serializers.CharField(
42 help_text='This identifier, which is allocated by the PNFD designer, \
43 identifies the PNFD in a globally unique way. \
44 It is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
49 pnfdName = serializers.CharField(
50 help_text='Name of the onboarded PNFD. \
51 This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
56 pnfdVersion = serializers.CharField( # TODO: data type is version
57 help_text='Version of the on-boarded PNFD. \
58 This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
63 pnfdProvider = serializers.CharField(
64 help_text='Provider of the on-boarded PNFD. \
65 This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
70 pnfdInvariantId = serializers.CharField(
71 help_text='Identifies a PNFD in a version independent manner. \
72 This attribute is invariant across versions of PNFD.',
77 pnfdOnboardingState = serializers.ChoiceField(
78 help_text='Onboarding state of the individual PNF descriptor resource.',
79 choices=['CREATED', 'UPLOADING', 'PROCESSING', 'ONBOARDED'],
84 onboardingFailureDetails = ProblemDetailsSerializer(
85 help_text='Failure details of current onboarding procedure. \
86 It shall be present when the "pnfdOnboardingState" attribute is CREATED and the uploading or processing fails in NFVO.',
90 pnfdUsageState = serializers.ChoiceField(
91 help_text='Usage state of the individual PNF descriptor resource.',
92 choices=['IN_USE', 'NOT_IN_USE'],
96 userDefinedData = serializers.DictField(
97 help_text='User defined data for the individual PNF descriptor resource. \
98 This attribute can be modified with the PATCH method.',
99 child=serializers.CharField(help_text='Key Value Pairs', allow_blank=True),
103 _links = _LinkSerializer(
104 help_text='Links to resources related to this resource.',
106 allow_null=True # TODO: supposed to be False