1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2 # Copyright (c) 2019, ZTE Corporation.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 from rest_framework import serializers
16 from lcm.ns.enum import AFFINITY_OR_ANTIAFFIINTY, AFFINITY_OR_ANTIAFFIINTY_SCOPE
17 from lcm.pub.utils.enumutil import enum_to_list
20 class ProblemDetailsSerializer(serializers.Serializer):
21 type = serializers.CharField(
22 help_text="A URI reference according to IETF RFC 3986 [5] that identifies the problem type.",
27 title = serializers.CharField(
28 help_text="A short, human-readable summary of the problem type.",
33 status = serializers.IntegerField(
34 help_text="The HTTP status code for this occurrence of the problem.",
37 detail = serializers.CharField(
38 help_text="A human-readable explanation specific to this occurrence of the problem.",
41 instance = serializers.CharField(
42 help_text="A URI reference that identifies the specific occurrence of the problem.",
47 additional_details = serializers.ListField(
48 help_text="Any number of additional attributes, as defined in a specification or by an"
55 class LinkSerializer(serializers.Serializer):
56 href = serializers.CharField(
57 help_text="URI of the referenced resource.",
63 class AffinityOrAntiAffinityRuleSerializer(serializers.Serializer):
64 vnfdId = serializers.ListField(
65 child=serializers.CharField(),
66 help_text="Identifier of the VNFD on which the VNF instance is based.",
69 vnfProfileId = serializers.ListField(
70 child=serializers.CharField(),
71 help_text="Identifier of (Reference to) a vnfProfile defined in the NSD which the existing VNF instance shall be matched with.",
74 vnfInstanceId = serializers.ListField(
75 child=serializers.CharField(),
76 help_text="Identifier of the existing VNF instance to be used in the NS.",
79 affinityOrAntiAffiinty = serializers.ChoiceField(
80 help_text="The type of the constraint.",
81 choices=enum_to_list(AFFINITY_OR_ANTIAFFIINTY),
85 scope = serializers.ChoiceField(
86 help_text="Specifies the scope of the rule where the placement constraint applies.",
87 choices=enum_to_list(AFFINITY_OR_ANTIAFFIINTY_SCOPE),