Update pm subscription request serializer in vnflcm
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf_pm / serializers / pm_subscription_request.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
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 from lcm.nf_pm.counst import NOTIFICATION_TYPE, AUTH_TYPE
17
18
19 class VnfInstanceSubscriptionFilterSerializer(serializers.Serializer):
20     vnfdIds = serializers.ListSerializer(help_text="If present, match VNF instances that were created based"
21                                                    " on aVNFD identified by one of the vnfdId values listed"
22                                                    " in this attribute.",
23                                          required=False, allow_null=True, many=True)
24     vnfProductsFromProviders = serializers.ListSerializer(help_text="If present, match VNF instances that "
25                                                                     "belong to VNF products from certain"
26                                                                     " providers.",
27                                                           required=False, allow_null=True, many=True)
28     vnfInstanceIds = serializers.ListSerializer(help_text="If present, match VNF instances with an instance "
29                                                           "identifier listed in this attribute.",
30                                                 required=False, allow_null=True, many=True)
31     vnfInstanceNames = serializers.ListSerializer(help_text="If present, match VNF instances with a VNF "
32                                                             "Instance Name listed in this attribute.",
33                                                   required=False, allow_null=True, many=True)
34
35
36 class PmNotificationsFilterSerializer(serializers.Serializer):
37     vnfInstanceSubscriptionFilter = VnfInstanceSubscriptionFilterSerializer(
38         help_text="Filter criteria to select VNF instances about which to notify.",
39         required=False, allow_null=True)
40     notificationTypes = serializers.ChoiceField(
41         help_text="Match particular notification types.",
42         required=False, allow_null=True,
43         choices=NOTIFICATION_TYPE
44     )
45
46
47 class SubscriptionAuthenticationSerializer(serializers.Serializer):
48     authType = serializers.ChoiceField(help_text="Defines the types of Authentication / Authorization which"
49                                                  " the API consumer is willing to accept when "
50                                                  "receiving a notification.", required=True, allow_null=False,
51                                        choices=AUTH_TYPE)
52     paramsBasic = serializers.CharField(help_text="Parameters for authentication/authorization using BASIC.",
53                                         required=False, allow_null=True)
54     paramsOauth2ClientCredentials = serializers.CharField(help_text="Parameters for authentication/"
55                                                                     "authorization using OAUTH2_CLIENT_"
56                                                                     "CREDENTIALS.",
57                                                           required=False, allow_null=True)
58
59
60 class PmSubscriptionRequestSerializer(serializers.Serializer):
61     filter = PmNotificationsFilterSerializer(help_text="Filter settings for this subscription, to define the "
62                                                        "subset of all notifications this"
63                                                        " subscription relates to.",
64                                              required=False, allow_null=True)
65     callbackUri = serializers.CharField(help_text="The URI of the endpoint to send the notification to.",
66                                         required=True, allow_null=False)
67     authentication = SubscriptionAuthenticationSerializer(help_text="Authentication parameters to configure"
68                                                                     " the use of Authorization when sending"
69                                                                     " notifications corresponding to this"
70                                                                     " subscription,",
71                                                           required=False, allow_null=True)