781bfb04cb386c47f817f3ed9faad1f6d853c5b8
[pti/o2.git] / o2ims / views / alarm_dto.py
1 # Copyright (C) 2021 Wind River Systems, Inc.
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 flask_restx import fields
16
17 from o2ims.views.api_ns import api_ims_monitoring as api_monitoring_v1
18
19
20 class AlarmDTO:
21
22     alarm_event_record_get = api_monitoring_v1.model(
23         "AlarmGetDto",
24         {
25             'alarmEventRecordId': fields.String(
26                 required=True,
27                 description='Alarm Event Record ID'),
28             'resourceTypeId': fields.String,
29             'resourceTypeID': fields.String(attribute='resourceTypeId'),
30             'resourceId': fields.String,
31             'resourceID': fields.String(attribute='resourceId'),
32             'alarmDefinitionId': fields.String,
33             'alarmDefinitionID': fields.String(attribute='alarmDefinitionId'),
34             'probableCauseId': fields.String,
35             'probableCauseID': fields.String(attribute='probableCauseId'),
36             'alarmRaisedTime': fields.String,
37             'alarmChangedTime': fields.String,
38             'alarmAcknowledgeTime': fields.String,
39             'alarmAcknowledged': fields.Boolean,
40             'perceivedSeverity': fields.String,
41             'extensions': fields.Raw(attribute='extensions'),
42         },
43         mask='{alarmEventRecordId,resourceTypeID,resourceID,' +
44         'alarmDefinitionID,probableCauseID,' +
45         'alarmRaisedTime,perceivedSeverity,alarmChangedTime,' +
46         'alarmAcknowledgeTime,alarmAcknowledged,extensions}'
47     )
48
49
50 class SubscriptionDTO:
51
52     subscription_get = api_monitoring_v1.model(
53         "AlarmSubscriptionGetDto",
54         {
55             'alarmSubscriptionId': fields.String(
56                 required=True,
57                 description='Alarm Subscription ID'),
58             'callback': fields.String,
59             'consumerSubscriptionId': fields.String,
60             'filter': fields.String,
61         },
62         mask='{alarmSubscriptionId,callback}'
63     )
64
65     subscription_create = api_monitoring_v1.model(
66         "AlarmSubscriptionCreateDto",
67         {
68             'callback': fields.String(
69                 required=True,
70                 description='Alarm Subscription callback address'),
71             'consumerSubscriptionId': fields.String,
72             'filter': fields.String,
73         }
74     )