diff options
author | yangyan <yangyanyj@chinamobile.com> | 2019-11-22 16:49:47 +0800 |
---|---|---|
committer | yangyan <yangyanyj@chinamobile.com> | 2019-11-22 16:56:30 +0800 |
commit | 92a787ea2788c91670760cd33950d9a20f42be62 (patch) | |
tree | 28a296ea449582bc4f668beda8ab7ace18f7e46e /lcm | |
parent | 89f04ed122e180b45934c66e77f9f9eaca7a784e (diff) |
Update pm subscription request serializer in vnflcm
Change-Id: I93cf71b09d7b5199a8fc8c068967cabe9253a3fe
Issue-ID: VFC-1590
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf_pm/__init__.py | 0 | ||||
-rw-r--r-- | lcm/lcm/nf_pm/counst.py | 26 | ||||
-rw-r--r-- | lcm/lcm/nf_pm/serializers/__init__.py | 13 | ||||
-rw-r--r-- | lcm/lcm/nf_pm/serializers/pm_subscription_request.py | 71 |
4 files changed, 110 insertions, 0 deletions
diff --git a/lcm/lcm/nf_pm/__init__.py b/lcm/lcm/nf_pm/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/lcm/lcm/nf_pm/__init__.py diff --git a/lcm/lcm/nf_pm/counst.py b/lcm/lcm/nf_pm/counst.py new file mode 100644 index 00000000..3d3ce508 --- /dev/null +++ b/lcm/lcm/nf_pm/counst.py @@ -0,0 +1,26 @@ +# Copyright (c) 2019, CMCC Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License") +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from lcm.pub.utils.jobutil import enum + +NOTIFICATION_TYPE = enum( + ThresholdCrossedNotification="ThresholdCrossedNotification", + PerformanceInformationAvailableNotification="PerformanceInformationAvailableNotification" +) + +AUTH_TYPE = enum( + BASIC="BASIC", + OAUTH2_CLIENT_CREDENTIALS="OAUTH2_CLIENT_CREDENTIALS", + TLS_CERT="TLS_CERT" +) diff --git a/lcm/lcm/nf_pm/serializers/__init__.py b/lcm/lcm/nf_pm/serializers/__init__.py new file mode 100644 index 00000000..63a27508 --- /dev/null +++ b/lcm/lcm/nf_pm/serializers/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2019, CMCC Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License") +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/lcm/lcm/nf_pm/serializers/pm_subscription_request.py b/lcm/lcm/nf_pm/serializers/pm_subscription_request.py new file mode 100644 index 00000000..6a95ebf4 --- /dev/null +++ b/lcm/lcm/nf_pm/serializers/pm_subscription_request.py @@ -0,0 +1,71 @@ +# Copyright (c) 2019, CMCC Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License") +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from rest_framework import serializers +from lcm.nf_pm.counst import NOTIFICATION_TYPE, AUTH_TYPE + + +class VnfInstanceSubscriptionFilterSerializer(serializers.Serializer): + vnfdIds = serializers.ListSerializer(help_text="If present, match VNF instances that were created based" + " on aVNFD identified by one of the vnfdId values listed" + " in this attribute.", + required=False, allow_null=True, many=True) + vnfProductsFromProviders = serializers.ListSerializer(help_text="If present, match VNF instances that " + "belong to VNF products from certain" + " providers.", + required=False, allow_null=True, many=True) + vnfInstanceIds = serializers.ListSerializer(help_text="If present, match VNF instances with an instance " + "identifier listed in this attribute.", + required=False, allow_null=True, many=True) + vnfInstanceNames = serializers.ListSerializer(help_text="If present, match VNF instances with a VNF " + "Instance Name listed in this attribute.", + required=False, allow_null=True, many=True) + + +class PmNotificationsFilterSerializer(serializers.Serializer): + vnfInstanceSubscriptionFilter = VnfInstanceSubscriptionFilterSerializer( + help_text="Filter criteria to select VNF instances about which to notify.", + required=False, allow_null=True) + notificationTypes = serializers.ChoiceField( + help_text="Match particular notification types.", + required=False, allow_null=True, + choices=NOTIFICATION_TYPE + ) + + +class SubscriptionAuthenticationSerializer(serializers.Serializer): + authType = serializers.ChoiceField(help_text="Defines the types of Authentication / Authorization which" + " the API consumer is willing to accept when " + "receiving a notification.", required=True, allow_null=False, + choices=AUTH_TYPE) + paramsBasic = serializers.CharField(help_text="Parameters for authentication/authorization using BASIC.", + required=False, allow_null=True) + paramsOauth2ClientCredentials = serializers.CharField(help_text="Parameters for authentication/" + "authorization using OAUTH2_CLIENT_" + "CREDENTIALS.", + required=False, allow_null=True) + + +class PmSubscriptionRequestSerializer(serializers.Serializer): + filter = PmNotificationsFilterSerializer(help_text="Filter settings for this subscription, to define the " + "subset of all notifications this" + " subscription relates to.", + required=False, allow_null=True) + callbackUri = serializers.CharField(help_text="The URI of the endpoint to send the notification to.", + required=True, allow_null=False) + authentication = SubscriptionAuthenticationSerializer(help_text="Authentication parameters to configure" + " the use of Authorization when sending" + " notifications corresponding to this" + " subscription,", + required=False, allow_null=True) |