Docs: Update all API docs with example
[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 o2common.views.flask_restx_fields import Json2Dict
18 from o2ims.views.api_ns import api_ims_monitoring as api_monitoring_v1
19
20
21 class MonitoringApiV1DTO:
22
23     api_version = api_monitoring_v1.model(
24         'MonitoringV1ApiVersionStructure',
25         {
26             'version': fields.String(
27                 required=True,
28                 example='1.0.0',
29                 description='Identifies a supported version.'
30             )
31         },
32         mask='{version,}'
33     )
34
35     api_version_info_get = api_monitoring_v1.model(
36         "MonitoringV1APIVersion",
37         {
38             'uriPrefix': fields.String(
39                 required=True,
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.'),
48         },
49         mask='{uriPrefix,apiVersions}'
50     )
51
52
53 class AlarmDTO:
54
55     alarm_event_record_get = api_monitoring_v1.model(
56         "AlarmGetDto",
57         {
58             'alarmEventRecordId': fields.String(
59                 required=True,
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 ' +
65                 'caused the alarm.'),
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 ' +
74                 'caused the alarm.'),
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 ' +
84                 'Resource Type.'),
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(
104                 example='',
105                 description='Date/Time stamp value when any value of ' +
106                 'the AlarmEventRecord has been modified.'),
107             'alarmAcknowledgeTime': fields.String(
108                 example='',
109                 description='Date/Time stamp value when the alarm ' +
110                 'condition is acknowledged.'),
111             'alarmAcknowledged': fields.Boolean(
112                 example=False,
113                 description='Boolean value indicating of a management ' +
114                 'system has acknowledged the alarm.'),
115             'perceivedSeverity': fields.String(
116                 example='1',
117                 description='One of the following values: \n ' +
118                 '0 for "CRITICAL" \n' +
119                 '1 for "MAJOR" \n' +
120                 '2 for "MINOR" \n' +
121                 '3 for "WARNING" \n' +
122                 '4 for "INDETERMINATE" \n' +
123                 '5 for "CLEARED"'),
124             'extensions': Json2Dict(attribute='extensions')
125         }
126         # mask='{alarmEventRecordId,resourceTypeID,resourceID,' +
127         # 'alarmDefinitionID,probableCauseID,' +
128         # 'alarmRaisedTime,perceivedSeverity,alarmChangedTime,' +
129         # 'alarmAcknowledgeTime,alarmAcknowledged,extensions}'
130     )
131
132
133 class SubscriptionDTO:
134
135     subscription_get = api_monitoring_v1.model(
136         "AlarmSubscriptionGetDto",
137         {
138             'alarmSubscriptionId': fields.String(
139                 required=True,
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(
153                 example='',
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.'),
158         },
159         mask='{alarmSubscriptionId,callback}'
160     )
161
162     subscription_create = api_monitoring_v1.model(
163         "AlarmSubscriptionCreateDto",
164         {
165             'callback': fields.String(
166                 required=True,
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(
177                 example='',
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.'),
182         }
183     )