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}'
133 class SubscriptionDTO:
135 subscription_get = api_monitoring_v1.model(
136 "AlarmSubscriptionGetDto",
138 'alarmSubscriptionId': fields.String(
140 example='e320da6d-27a8-4948-8b52-3bf3355b45f3',
141 description='Identifier for the Alarm Subscription.'),
142 'callback': fields.String(
143 example='https://128.224.115.15:1081/smo/v1/' +
144 'o2ims_alarm_observer',
145 description='The fully qualified URI to a consumer ' +
146 'procedure which can process a Post of the ' +
147 'InventoryEventNotification.'),
148 'consumerSubscriptionId': fields.String(
149 example='3F20D850-AF4F-A84F-FB5A-0AD585410361',
150 description='Identifier for the consumer of events sent ' +
151 'due to the Subscription.'),
152 'filter': fields.String(
154 description='Criteria for events which do not need to be ' +
155 'reported or will be filtered by the subscription ' +
156 'notification service. Therefore, if a filter is not ' +
157 'provided then all events are reported.'),
159 mask='{alarmSubscriptionId,callback}'
162 subscription_create = api_monitoring_v1.model(
163 "AlarmSubscriptionCreateDto",
165 'callback': fields.String(
167 example='https://128.224.115.15:1081/smo/v1/' +
168 'o2ims_alarm_observer',
169 description='The fully qualified URI to a consumer ' +
170 'procedure which can process a Post of the ' +
171 'InventoryEventNotification.'),
172 'consumerSubscriptionId': fields.String(
173 example='3F20D850-AF4F-A84F-FB5A-0AD585410361',
174 description='Identifier for the consumer of events sent ' +
175 'due to the Subscription.'),
176 'filter': fields.String(
178 description='Criteria for events which do not need to be ' +
179 'reported or will be filtered by the subscription ' +
180 'notification service. Therefore, if a filter is not ' +
181 'provided then all events are reported.'),