Fix NS Scale serializers error
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / pub_serializers.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
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 from rest_framework import serializers
15
16
17 class ProblemDetailsSerializer(serializers.Serializer):
18     type = serializers.CharField(
19         help_text="A URI reference according to IETF RFC 3986 [5] that identifies the problem type.",
20         required=False,
21         allow_null=True,
22         allow_blank=True
23     )
24     title = serializers.CharField(
25         help_text="A short, human-readable summary of the problem type.",
26         required=False,
27         allow_null=True,
28         allow_blank=True
29     )
30     status = serializers.IntegerField(
31         help_text="The HTTP status code for this occurrence of the problem.",
32         required=True
33     )
34     detail = serializers.CharField(
35         help_text="A human-readable explanation specific to this occurrence of the problem.",
36         required=True
37     )
38     instance = serializers.CharField(
39         help_text="A URI reference that identifies the specific occurrence of the problem.",
40         required=False,
41         allow_null=True,
42         allow_blank=True
43     )
44     additional_details = serializers.ListField(
45         help_text="Any number of additional attributes, as defined in a specification or by an"
46                   " implementation.",
47         required=False,
48         allow_null=True
49     )
50
51
52 class LinkSerializer(serializers.Serializer):
53     href = serializers.CharField(
54         help_text="URI of the referenced resource.",
55         required=True,
56         allow_null=False,
57         allow_blank=False)
58
59
60 class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
61     vnfdId = serializers.ListField(
62         child=serializers.CharField(),
63         help_text="Identifier of the VNFD on which the VNF instance is based.",
64         required=False,
65         allow_null=True)
66     vnfProfileId = serializers.ListField(
67         child=serializers.CharField(),
68         help_text="Identifier of (Reference to) a vnfProfile defined in the NSD which the existing VNF instance shall be matched with.",
69         required=False,
70         allow_null=True)
71     vnfInstanceId = serializers.ListField(
72         child=serializers.CharField(),
73         help_text="Identifier of the existing VNF instance to be used in the NS.",
74         required=True,
75         allow_null=False)
76     affinityOrAntiAffiinty = serializers.ChoiceField(
77         help_text="The type of the constraint.",
78         choices=["AFFINITY", "ANTI_AFFINITY"],
79         required=True,
80         allow_null=False,
81         allow_blank=False)
82     scope = serializers.ChoiceField(
83         help_text="Specifies the scope of the rule where the placement constraint applies.",
84         choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"],
85         required=True,
86         allow_null=False,
87         allow_blank=False)