Swagger issue fixes from the Ericsson team
[modeling/etsicatalog.git] / catalog / packages / serializers / pnfd_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 UriLinkSerializer
18
19
20 class PnfdInfoLinksSerializer(serializers.Serializer):
21     self = UriLinkSerializer(
22         help_text='URI of this resource.',
23         required=True,
24         allow_null=False
25     )
26     pnfd_content = UriLinkSerializer(
27         help_text='Link to the PNFD content resource.',
28         required=True,
29         allow_null=False
30     )
31
32     class Meta:
33         ref_name = "PNFD_LinkSerializer"
34
35
36 class PnfdInfoSerializer(serializers.Serializer):
37     id = serializers.CharField(
38         help_text='Identifier of the onboarded individual PNF descriptor resource. \
39         This identifier is allocated by the NFVO.',
40         required=True,
41         allow_null=False,
42         allow_blank=False
43     )
44     pnfdId = serializers.CharField(
45         help_text='This identifier, which is allocated by the PNFD designer, \
46         identifies the PNFD in a globally unique way. \
47         It is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
48         required=False,
49         allow_null=True,
50         allow_blank=True
51     )
52     pnfdName = serializers.CharField(
53         help_text='Name of the onboarded PNFD. \
54         This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
55         required=False,
56         allow_null=True,
57         allow_blank=True
58     )
59     pnfdVersion = serializers.CharField(  # TODO: data type is version
60         help_text='Version of the on-boarded PNFD. \
61         This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
62         required=False,
63         allow_null=True,
64         allow_blank=True
65     )
66     pnfdProvider = serializers.CharField(
67         help_text='Provider of the on-boarded PNFD. \
68         This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.',
69         required=False,
70         allow_null=True,
71         allow_blank=True
72     )
73     pnfdInvariantId = serializers.CharField(
74         help_text='Identifies a PNFD in a version independent manner. \
75         This attribute is invariant across versions of PNFD.',
76         required=False,
77         allow_null=True,
78         allow_blank=True
79     )
80     pnfdOnboardingState = serializers.ChoiceField(
81         help_text='Onboarding state of the individual PNF descriptor resource.',
82         choices=['CREATED', 'UPLOADING', 'PROCESSING', 'ONBOARDED'],
83         required=True,
84         allow_null=False,
85         allow_blank=False
86     )
87     onboardingFailureDetails = ProblemDetailsSerializer(
88         help_text='Failure details of current onboarding procedure. \
89         It shall be present when the "pnfdOnboardingState" attribute is CREATED and the uploading or processing fails in NFVO.',
90         required=False,
91         allow_null=True,
92     )
93     pnfdUsageState = serializers.ChoiceField(
94         help_text='Usage state of the individual PNF descriptor resource.',
95         choices=['IN_USE', 'NOT_IN_USE'],
96         required=True,
97         allow_null=False,
98     )
99     userDefinedData = serializers.DictField(
100         help_text='User defined data for the individual PNF descriptor resource. \
101         This attribute can be modified with the PATCH method.',
102         child=serializers.CharField(help_text='Key Value Pairs', allow_blank=True),
103         required=False,
104         allow_null=True
105     )
106     _links = PnfdInfoLinksSerializer(
107         help_text='Links to resources related to this resource.',
108         required=True,
109         allow_null=True  # TODO: supposed to be False
110     )