improve enum and list in serializers
[vfc/nfvo/lcm.git] / lcm / ns / serializers / sol / affected_vnffgs.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2 # Copyright (c) 2019, ZTE Corporation.
3
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
7
8 # http://www.apache.org/licenses/LICENSE-2.0
9
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
16
17 from rest_framework import serializers
18 from lcm.ns.enum import CHANGE_TYPE, CHANGE_RESULT
19 from lcm.pub.utils.enumutil import enum_to_list
20
21
22 class AffectedVnffgsSerializer(serializers.Serializer):
23     vnffgInstanceId = serializers.UUIDField(
24         help_text="Identifier of the VNFFG instance.",
25         required=True
26     )
27     vnffgdId = serializers.UUIDField(
28         help_text="Identifier of the VNFFGD of the VNFFG instance.",
29         required=True
30     )
31     changeType = serializers.ChoiceField(
32         help_text="Signals the type of lifecycle change.",
33         required=True,
34         choices=enum_to_list(CHANGE_TYPE)
35     )
36     changeResult = serializers.ChoiceField(
37         help_text="Signals the result of change identified by the 'changeType' attribute.",
38         required=True,
39         choices=enum_to_list(CHANGE_RESULT)
40     )