1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2 # Copyright 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.
16 from rest_framework import serializers
18 from ns_instance_subscription_filter import NsInstanceSubscriptionFilter
19 from lcm.ns.enum import NOTIFICATION_TYPE, OPERATION_TYPE, OPERATION_STATE_TYPE, NS_COMPOMENT_TYPE, OPNAME_FOR_CHANGE_NOTIFICATION_TYPE, OPOCC_STATUS_FOR_CHANGENOTIFICATION_TYPE
20 from lcm.pub.utils.enumutil import enum_to_list
23 class LifeCycleChangeNotificationsFilter(serializers.Serializer):
24 nsInstanceSubscriptionFilter = NsInstanceSubscriptionFilter(
25 help_text="Filter criteria to select NS instances about which to notify.",
28 notificationTypes = serializers.ListField(
29 help_text="Match particular notification types.",
30 child=serializers.ChoiceField(required=True, choices=enum_to_list(NOTIFICATION_TYPE)),
33 operationTypes = serializers.ListField(
34 help_text="Match particular NS lifecycle operation types for the notification of type NsLcmOperationOccurrenceNotification.",
35 child=serializers.ChoiceField(required=True, choices=enum_to_list(OPERATION_TYPE)),
38 operationStates = serializers.ListField(
39 help_text="Match particular LCM operation state values as reported in notifications of type NsLcmOperationOccurrenceNotification.",
40 child=serializers.ChoiceField(required=True, choices=enum_to_list(OPERATION_STATE_TYPE)),
43 nsComponentTypes = serializers.ListField(
44 help_text="Match particular NS component types for the notification of type NsChangeNotification. ",
45 child=serializers.ChoiceField(required=True, choices=enum_to_list(NS_COMPOMENT_TYPE)),
48 lcmOpNameImpactingNsComponent = serializers.ListField(
49 help_text="Match particular LCM operation names for the notification of type NsChangeNotification.",
50 child=serializers.ChoiceField(required=True, choices=enum_to_list(OPNAME_FOR_CHANGE_NOTIFICATION_TYPE)),
53 lcmOpOccStatusImpactingNsComponent = serializers.ListField(
54 help_text="Match particular LCM operation status values as reported in notifications of type NsChangeNotification.",
55 child=serializers.ChoiceField(required=True, choices=enum_to_list(OPOCC_STATUS_FOR_CHANGENOTIFICATION_TYPE)),