aboutsummaryrefslogtreecommitdiffstats
path: root/lcm/ns/serializers/sol/ns_performance_anagement_interface.py
blob: 844b5db0d3b4f91b7228b0f8208967fb312fcf34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# 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


# PmSubscriptionRequest
from lcm.ns.enum import CROSSINGDIRECTION_Type, threshold_Type
from lcm.pub.utils.enumutil import enum_to_list


class NsInstanceSubscriptionFilterSerializer(serializers.Serializer):
    nsdIds = serializers.CharField(help_text="If present, match NS instances that were created based on a"
                                             " NSD identified by one of the nsdId values listed in this"
                                             " attribute.", required=False, allow_null=True, many=True)
    vnfdIds = serializers.CharField(help_text="If present, match NS instances that contain VNF instances that"
                                              " were created based on a VNFD identified by one of the vnfdId "
                                              "values listed in this attribute.", required=False,
                                    allow_null=True, many=True)
    pnfdIds = serializers.CharField(help_text="If present, match NS instances that contain PNFs that are "
                                              "represented by a PNFD identified by one of the pnfdId values "
                                              "listed in this attribute", required=False,
                                    allow_null=True, many=True)
    nsInstanceIds = serializers.CharField(help_text="If present, match NS instances with an instance "
                                                    "identifier listed in this attribute.",
                                          required=False, allow_null=True, many=True)
    nsInstanceNames = serializers.CharField(help_text="If present, match NS instances with a NS Instance Name"
                                                      " listed in this attribute",
                                            required=False, allow_null=True, many=True)


class PmNotificationsFilterSerializer(serializers.Serializer):
    nsInstanceSubscriptionFilter = NsInstanceSubscriptionFilterSerializer(help_text="Filter criteria to"
                                                                                    " select NS instances "
                                                                                    "about which to notify",
                                                                          required=False, allow_null=True,
                                                                          allow_blank=True)
    notificationTypes = serializers.ChoiceField(help_text="Match particular notification types.",
                                                choices=["ThresholdCrossedNotification",
                                                         "PerformanceInformationAvailableNotification"],
                                                required=False, allow_null=True, many=True)


class SubscriptionAuthenticationSerializer(serializers.Serializer):
    authType = serializers.ChoiceField(help_text="Defines the types of Authentication Authorization the API"
                                                 " consumer is willing to accept when receiving a"
                                                 " notification.", choices=["BASIC",
                                                                            "OAUTH2_CLIENT_CREDENTIALS",
                                                                            "TLS_CERT"], required=True,
                                       allow_null=False, many=True)
    paramsBasic = serializers.CharField(help_text="Parameters for authentication authorization using BASIC",
                                        required=False, allow_null=True, allow_blank=True)
    paramsOauth2ClientCredentials = serializers.CharField(help_text="Parameters for authentication "
                                                                    "authorization using OAUTH2"
                                                                    "_CLIENT_CREDENTIALS.",
                                                          required=False, allow_null=True, allow_blank=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,
                                             allow_blank=True)
    callbackUri = serializers.CharField(help_text="The URI of the endpoint to send the notification to",
                                        required=True, allow_null=False, allow_blank=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, allow_blank=True)


# PmSubscription
class PmSubscriptionSerializer(serializers.Serializer):
    id = serializers.CharField(help_text="Identifier that identifies the subscription.",
                               required=True, allow_null=False)
    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)
    _links = serializers.CharField(help_text="Links to resources related to this resource.",
                                   required=True, allow_null=False)


#  ThresholdCrossedNotification
class ThresholdCrossedNotificationSerializer(serializers.Serializer):
    id = serializers.CharField(help_text="Identifier of this notification. If a notification is sent multiple"
                                         " times due to multiple subscriptions",
                               required=True, allow_null=False)
    notificationType = serializers.CharField(help_text="Discriminator for the different notification types.",
                                             required=True, allow_null=False)
    subscriptionId = serializers.CharField(help_text="Identifier of the subscription that this notification "
                                                     "relates to.", required=True, allow_null=False)
    timeStamp = serializers.CharField(help_text="Date and time of the generation of the notification.",
                                      required=True, allow_null=False)
    thresholdId = serializers.CharField(help_text="Identifier of the threshold which has been crossed.",
                                        required=True, allow_null=False)
    crossingDirection = serializers.ListField(help_text="An indication of whether the threshold was crossed "
                                                        "in upward or downward direction.",
                                              child=serializers.ChoiceField(
                                                  required=True,
                                                  choices=enum_to_list(CROSSINGDIRECTION_Type)),
                                              required=True, allow_null=False)
    objectInstanceId = serializers.CharField(help_text="Identifier that identifies a NS instance.",
                                             required=True, allow_null=False)
    performanceMetric = serializers.CharField(help_text="Performance metric associated with the "
                                                        "threshold", required=True, allow_null=False)
    performanceValue = serializers.CharField(help_text="Value of the metric that resulted in threshold "
                                                       "crossing.", required=True, allow_null=False)
    _links = serializers.CharField(help_text="Links to resources related to this notification",
                                   required=True, allow_null=False)


#  PerformanceInformationAvailableNotification
class PerformanceInformationAvailableNotification(serializers.Serializer):
    id = serializers.CharField(help_text="Identifier of this notification.", required=True, allow_null=False)
    notificationType = serializers.CharField(help_text="Discriminator for the different notification types",
                                             required=True, allow_null=False)
    subscriptionId = serializers.CharField(help_text="Identifier of the subscription that this notification "
                                                     "relates to.", required=True, allow_null=False)
    timeStamp = serializers.DateField(help_text="Date and time of the generation of the notification.",
                                      required=True, allow_null=False)
    objectInstanceId = serializers.CharField(help_text="Identifier that identifies a NS instance.",
                                             required=True, allow_null=False)
    _links = serializers.CharField(help_text="Links to resources related to this notification",
                                   required=True, allow_null=False)


# CreatePmJobRequest
class PmJobCriteriaSerializer(serializers.Serializer):
    performanceMetric = serializers.CharField(help_text="This defines the types of performance metrics for"
                                                        " the specified object instances",
                                              required=False, allow_null=True, many=True)
    performanceMetricGroup = serializers.CharField(help_text="Group of performance metrics.",
                                                   required=False, allow_null=True, many=True)
    collectionPeriod = serializers.CharField(help_text="Specifies the periodicity at which the producer "
                                                       "will collect performance information",
                                             required=True, allow_null=False)
    reportingPeriod = serializers.CharField(help_text="Specifies the periodicity at which the producer "
                                                      "will report to the consumer",
                                            required=True, allow_null=False)
    reportingBoundary = serializers.DateField(help_text="Identifies a time boundary after which the "
                                                        "reporting will stop",
                                              required=False, allow_null=True)


class CreatePmJobRequestSerializer(serializers.Serializer):
    objectInstanceIds = serializers.CharField(help_text="Identifiers of the NS instances for which"
                                                        " performance information is requested to be"
                                                        " collected.",
                                              required=True, allow_null=False, many=True)
    criteria = PmJobCriteriaSerializer(help_text="Criteria of the collection of performance information.",
                                       required=True, allow_null=False)


# PmJob
class PmJobSerializer(serializers.Serializer):
    id = serializers.CharField(help_text="Identifier of this PM job.", required=True, allow_null=False)
    objectInstanceIds = serializers.CharField(help_text="Identifiers of the NS instances for which "
                                                        "performance information is collected.",
                                              required=True, allow_null=False, many=True)
    criteria = PmJobCriteriaSerializer(help_text="Criteria of the collection of performance "
                                                 "information.", required=True)
    reports = serializers.CharField(help_text="Information about available reports collected by this PM job",
                                    required=False, allow_null=True, many=True)
    _links = serializers.CharField(help_text="Links for this resource.", required=False, allow_null=True)


# CreateThresholdRequest
class ThresholdCriteriaSerializer(serializers.Serializer):
    performanceMetric = serializers.CharField(help_text="Defines the performance metric associated with the "
                                                        "threshold", required=True, allow_null=False)
    thresholdType = serializers.ListField(help_text="Type of threshold.",
                                          child=serializers.ChoiceField(
                                              required=True, choices=enum_to_list(threshold_Type)),
                                          required=True, allow_null=False)


class CreateThresholdRequestSerializer(serializers.Serializer):
    objectInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated with this "
                                                       "threshold", required=True, allow_null=False)
    criteria = ThresholdCriteriaSerializer(help_text="Criteria that define this threshold.",
                                           required=True, allow_null=False)


# Threshold
class ThresholdSerializer(serializers.Serializer):
    id = serializers.CharField(help_text="Identifier of this threshold resource.",
                               required=True, allow_null=False)
    objectInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated with the "
                                                       "threshold.", required=True, allow_null=False)
    criteria = serializers.CharField(help_text="Criteria that define this threshold.",
                                     required=True, allow_null=False)
    _links = serializers.CharField(help_text="Links for this resource.", required=True, allow_null=False)


# PerformanceReport
class PerformanceReportSerializer(serializers.Serializer):
    entries = serializers.CharField(help_text="List of performance information entries.",
                                    required=True, allow_null=False, many=True)