1 # Copyright (C) 2021 Wind River Systems, Inc.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 from flask_restx import fields
17 from o2common.views.flask_restx_fields import Json2Dict
18 from o2ims.views.api_ns import api_ims_monitoring as api_monitoring_v1
21 class MonitoringApiV1DTO:
23 api_version = api_monitoring_v1.model(
24 'MonitoringV1ApiVersionStructure',
26 'version': fields.String(
29 description='Identifies a supported version.'
35 api_version_info_get = api_monitoring_v1.model(
36 "MonitoringV1APIVersion",
38 'uriPrefix': fields.String(
40 example='https://128.224.115.36:30205/' +
41 'o2ims-infrastructureMonitoring/v1',
42 description='Specifies the URI prefix for the API'),
43 'apiVersions': fields.List(
44 fields.Nested(api_version),
45 example=[{'version': '1.0.0'}],
46 description='Version(s) supported for the API ' +
47 'signaled by the uriPrefix attribute.'),
49 mask='{uriPrefix,apiVersions}'
55 alarm_event_record_get = api_monitoring_v1.model(
58 'alarmEventRecordId': fields.String(
60 example='97cc2b01-0e71-4a93-a911-2e87f04d996f',
61 description='The identifier for the AlarmEventRecord Object.'),
62 'resourceTypeId': fields.String(
63 example='60cba7be-e2cd-3b8c-a7ff-16e0f10573f9',
64 description='A reference to the type of resource which ' +
66 'resourceTypeID': fields.String(
67 attribute='resourceTypeId',
68 example='60cba7be-e2cd-3b8c-a7ff-16e0f10573f9',
69 description='A reference to the type of resource which ' +
70 'caused the alarm.(Specification)'),
71 'resourceId': fields.String(
72 example='5b3a2da8-17da-466c-b5f7-972590c7baf2',
73 description='A reference to the resource instance which ' +
75 'resourceID': fields.String(
76 attribute='resourceId',
77 example='5b3a2da8-17da-466c-b5f7-972590c7baf2',
78 description='A reference to the resource instance which ' +
79 'caused the alarm.(Specification)'),
80 'alarmDefinitionId': fields.String(
81 example='1197f463-b3d4-3aa3-9c14-faa493baa069',
82 description='A reference to the Alarm Definition record ' +
83 'in the Alarm Dictionary associated with the referenced ' +
85 'alarmDefinitionID': fields.String(
86 attribute='alarmDefinitionId',
87 example='1197f463-b3d4-3aa3-9c14-faa493baa069',
88 description='A reference to the Alarm Definition record ' +
89 'in the Alarm Dictionary associated with the referenced ' +
90 'Resource Type.(Specification)'),
91 'probableCauseId': fields.String(
92 example='f52054c9-6f3c-39a0-aab8-e00e01d8c4d3',
93 description='A reference to the ProbableCause of the Alarm.'),
94 'probableCauseID': fields.String(
95 attribute='probableCauseId',
96 example='f52054c9-6f3c-39a0-aab8-e00e01d8c4d3',
97 description='A reference to the ProbableCause of the ' +
98 'Alarm.(Specification)'),
99 'alarmRaisedTime': fields.String(
100 example='2022-12-22 09:42:53',
101 description='Date/Time stamp value when the ' +
102 'AlarmEventRecord has been created.'),
103 'alarmChangedTime': fields.String(
105 description='Date/Time stamp value when any value of ' +
106 'the AlarmEventRecord has been modified.'),
107 'alarmAcknowledgeTime': fields.String(
109 description='Date/Time stamp value when the alarm ' +
110 'condition is acknowledged.'),
111 'alarmAcknowledged': fields.Boolean(
113 description='Boolean value indicating of a management ' +
114 'system has acknowledged the alarm.'),
115 'perceivedSeverity': fields.String(
117 description='One of the following values: \n ' +
118 '0 for "CRITICAL" \n' +
121 '3 for "WARNING" \n' +
122 '4 for "INDETERMINATE" \n' +
124 'extensions': Json2Dict(attribute='extensions')
126 # mask='{alarmEventRecordId,resourceTypeID,resourceID,' +
127 # 'alarmDefinitionID,probableCauseID,' +
128 # 'alarmRaisedTime,perceivedSeverity,alarmChangedTime,' +
129 # 'alarmAcknowledgeTime,alarmAcknowledged,extensions}'
132 alarm_event_record_patch = api_monitoring_v1.model(
135 'alarmAcknowledged': fields.Boolean(
137 description='Boolean value indication of a management ' +
138 'system has acknowledged the alarm.'),
139 'perceivedSeverity': fields.String(
141 description='indicate that the alarm record is requested ' +
142 'to be cleared. Only the value "5" for "CLEARED" is ' +
143 'permitted in a request message content. ')
145 mask='{alarmAcknowledged,}'
149 class SubscriptionDTO:
151 subscription_get = api_monitoring_v1.model(
152 "AlarmSubscriptionGetDto",
154 'alarmSubscriptionId': fields.String(
156 example='e320da6d-27a8-4948-8b52-3bf3355b45f3',
157 description='Identifier for the Alarm Subscription.'),
158 'callback': fields.String(
159 example='https://128.224.115.15:1081/smo/v1/' +
160 'o2ims_alarm_observer',
161 description='The fully qualified URI to a consumer ' +
162 'procedure which can process a Post of the ' +
163 'InventoryEventNotification.'),
164 'consumerSubscriptionId': fields.String(
165 example='3F20D850-AF4F-A84F-FB5A-0AD585410361',
166 description='Identifier for the consumer of events sent ' +
167 'due to the Subscription.'),
168 'filter': fields.String(
170 description='Criteria for events which do not need to be ' +
171 'reported or will be filtered by the subscription ' +
172 'notification service. Therefore, if a filter is not ' +
173 'provided then all events are reported.'),
175 mask='{alarmSubscriptionId,callback}'
178 subscription_create = api_monitoring_v1.model(
179 "AlarmSubscriptionCreateDto",
181 'callback': fields.String(
183 example='https://128.224.115.15:1081/smo/v1/' +
184 'o2ims_alarm_observer',
185 description='The fully qualified URI to a consumer ' +
186 'procedure which can process a Post of the ' +
187 'InventoryEventNotification.'),
188 'consumerSubscriptionId': fields.String(
189 example='3F20D850-AF4F-A84F-FB5A-0AD585410361',
190 description='Identifier for the consumer of events sent ' +
191 'due to the Subscription.'),
192 'filter': fields.String(
194 description='Criteria for events which do not need to be ' +
195 'reported or will be filtered by the subscription ' +
196 'notification service. Therefore, if a filter is not ' +
197 'provided then all events are reported.'),