Add subscriptions API to GVNFM
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / serializers / lccn_filter_data.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 vnf_instance_subscription_filter import VnfInstanceSubscriptionFilter
18
19
20 NOTIFICATION_TYPES = [
21     "VnfLcmOperationOccurrenceNotification",
22     "VnfIdentifierCreationNotification",
23     "VnfIdentifierDeletionNotification"]
24
25 LCM_OPERATION_TYPES = [
26     "INSTANTIATE",
27     "SCALE",
28     "SCALE_TO_LEVEL",
29     "CHANGE_FLAVOUR",
30     "TERMINATE",
31     "HEAL",
32     "OPERATE",
33     "CHANGE_EXT_CONN",
34     "MODIFY_INFO"
35 ]
36
37 LCM_OPERATION_STATE_TYPES = [
38     "STARTING",
39     "PROCESSING",
40     "COMPLETED",
41     "FAILED_TEMP",
42     "FAILED",
43     "ROLLING_BACK",
44     "ROLLED_BACK"
45 ]
46
47
48 class LifeCycleChangeNotificationsFilter(serializers.Serializer):
49     notificationTypes = serializers.ListField(
50         child=serializers.ChoiceField(required=True, choices=NOTIFICATION_TYPES),
51         help_text="Match particular notification types",
52         allow_null=False,
53         required=False)
54     operationTypes = serializers.ListField(
55         child=serializers.ChoiceField(required=True, choices=LCM_OPERATION_TYPES),
56         help_text="Match particular VNF lifecycle operation types for the " +
57         "notification of type VnfLcmOperationOccurrenceNotification.",
58         allow_null=False,
59         required=False)
60     operationStates = serializers.ListField(
61         child=serializers.ChoiceField(required=True, choices=LCM_OPERATION_STATE_TYPES),
62         help_text="Match particular LCM operation state values as reported " +
63         "in notifications of type VnfLcmOperationOccurrenceNotification.",
64         allow_null=False,
65         required=False)
66     vnfInstanceSubscriptionFilter = VnfInstanceSubscriptionFilter(
67         help_text="Filter criteria to select VNF instances about which to notify.",
68         required=False,
69         allow_null=False)