vfclcm upgrade from python2 to python3
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / serializers / notification_types.py
1 # Copyright (C) 2018 Verizon. All Rights Reserved
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
17 from .affected_vnfcs import AffectedVnfcsSerializer
18 from .affected_vls import AffectedVLsSerializer
19 from .affected_storages import AffectedStoragesSerializer
20 from lcm.nf.const import LCM_OPERATION_TYPES, LCM_OPERATION_STATE_TYPES
21 from .link import linkSerializer
22 from .response import ProblemDetailsSerializer
23 from .ext_virtual_link_info import ExtVirtualLinkInfoSerializer
24 from .vnf_info_modifications import VnfInfoModificationsSerializer
25
26
27 class LccnLinksSerializer(serializers.Serializer):
28     vnfInstance = linkSerializer(
29         help_text="Link to the resource representing the VNF instance to "
30         "which the notified change applies.",
31         required=True,
32         allow_null=False)
33     subscription = linkSerializer(
34         help_text="Link to the related subscription.",
35         required=True,
36         allow_null=False)
37     vnfLcmOpOcc = linkSerializer(
38         help_text="Link to the VNF lifecycle management operation"
39         "occurrence that this notification is related to. Shall be"
40         "present if there is a related lifecycle operation occurance.",
41         required=False,
42         allow_null=False)
43
44
45 class VnfLcmOperationOccurrenceNotification(serializers.Serializer):
46     id = serializers.CharField(
47         help_text="Identifier of this notification",
48         max_length=255,
49         required=True,
50         allow_null=False)
51     notificationType = serializers.CharField(
52         help_text="Type of the notification",
53         max_length=50,
54         required=True,
55         allow_null=False)
56     subscriptionId = serializers.CharField(
57         help_text="Identifier for the subscription",
58         required=False)
59     timeStamp = serializers.CharField(
60         help_text="Date-time of the generation of the notification.",
61         required=True)
62     notificationStatus = serializers.ChoiceField(
63         help_text="Indicates whether this notification reports about the start"
64         "of a lifecycle operation or the result of a lifecycle"
65         "operation",
66         choices=["START", "RESULT"],
67         required=True)
68     operationState = serializers.ChoiceField(
69         choices=LCM_OPERATION_STATE_TYPES,
70         help_text="The state of the VNF LCM operation occurrence. ",
71         required=True)
72     vnfInstanceId = serializers.CharField(
73         help_text="The identifier of the VNF instance affected. ",
74         required=True)
75     operation = serializers.ChoiceField(
76         help_text="The lifecycle management operation.",
77         required=True,
78         choices=LCM_OPERATION_TYPES)
79     isAutomaticInvocation = serializers.BooleanField(
80         help_text="Set to true if this VNF LCM operation occurrence has"
81         "been triggered by an automated procedure inside the"
82         "VNFM. Otherwise False",
83         required=True)
84     vnfLcmOpOccId = serializers.CharField(
85         help_text="The identifier of the VNF lifecycle management"
86         "operation occurrence associated to the notification.",
87         required=True)
88     affectedVnfcs = AffectedVnfcsSerializer(
89         help_text="Information about VNFC instances that were affected " +
90         "during the lifecycle operation.",
91         required=False,
92         many=True
93     )
94     affectedVirtualLinks = AffectedVLsSerializer(
95         help_text="Information about VL instances that were affected " +
96         "during the lifecycle operation. ",
97         required=False,
98         many=True
99     )
100     affectedVirtualStorages = AffectedStoragesSerializer(
101         help_text="Information about virtualised storage instances that " +
102         "were affected during the lifecycle operation",
103         required=False,
104         many=True
105     )
106     changedInfo = VnfInfoModificationsSerializer(
107         help_text="Information about the changed VNF instance information, " +
108         "including VNF configurable properties",
109         required=False,
110         allow_null=True)
111     changedExtConnectivity = ExtVirtualLinkInfoSerializer(
112         help_text="Information about changed external connectivity, if this " +
113         "notification represents the result of a lifecycle operation occurrence. " +
114         "Shall be present if the 'notificationStatus' is set to 'RESULT' and the " +
115         "'operation' is set to 'CHANGE_EXT_CONN'. Shall be absent otherwise.",
116         many=True,
117         required=False,
118         allow_null=True)
119     error = ProblemDetailsSerializer(
120         help_text="If 'operationState' is 'FAILED_TEMP' or 'FAILED' or " +
121         "'PROCESSING' or 'ROLLING_BACK' and previous value of 'operationState' " +
122         "was 'FAILED_TEMP'  this attribute shall be present ",
123         allow_null=True,
124         required=False
125     )
126     _links = LccnLinksSerializer(
127         help_text="Links to resources related to this resource.",
128         required=True)