seperate sol and deprecated serializers
[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.", required=True, allow_null=False, allow_blank=False)
55
56
57 class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
58     vnfdId = serializers.ListField(
59         child=serializers.CharField(),
60         help_text="Identifier of the VNFD on which the VNF instance is based.",
61         required=False,
62         allow_null=True)
63     vnfProfileId = serializers.ListField(
64         child=serializers.CharField(),
65         help_text="Identifier of (Reference to) a vnfProfile defined in the NSD which the existing VNF instance shall be matched with.",
66         required=False,
67         allow_null=True)
68     vnfInstanceId = serializers.ListField(
69         child=serializers.CharField(),
70         help_text="Identifier of the existing VNF instance to be used in the NS.",
71         required=True,
72         allow_null=False)
73     affinityOrAntiAffiinty = serializers.ChoiceField(
74         help_text="The type of the constraint.",
75         choices=["AFFINITY", "ANTI_AFFINITY"],
76         required=True,
77         allow_null=False,
78         allow_blank=False)
79     scope = serializers.ChoiceField(
80         help_text="Specifies the scope of the rule where the placement constraint applies.",
81         choices=["NFVI_POP", "ZONE", "ZONE_GROUP", "NFVI_NODE"],
82         required=True,
83         allow_null=False,
84         allow_blank=False)