Debian Codegraph @

ansible_collections/cisco/meraki/plugins/modules/networks_sensor_alerts_profiles.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2021, Cisco Systems
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = r"""
8 module: networks_sensor_alerts_profiles
9 short_description: Resource module for networks _sensor _alerts _profiles
10 description:
11 - Manage operations create, update and delete of the resource networks _sensor _alerts
12 _profiles.
13 - Creates a sensor alert profile for a network.
14 - Deletes a sensor alert profile from a network.
15 - Updates a sensor alert profile for a network.
16 version_added: '1.0.0'
17 extends_documentation_fragment:
18 - cisco.meraki.module
19 author: Francisco Munoz (@fmunoz)
20 options:
21 conditions:
22 description: List of conditions that will cause the profile to send an alert.
23 elements: dict
24 suboptions:
25 direction:
26 description: If 'above', an alert will be sent when a sensor reads above the
27 threshold. If 'below', an alert will be sent when a sensor reads below the
28 threshold. Only applicable for temperature, humidity, realPower, apparentPower,
29 powerFactor, voltage, current, and frequency thresholds.
30 type: str
31 duration:
32 description: Length of time in seconds that the triggering state must persist
33 before an alert is sent. Available options are 0 seconds, 1 minute, 2 minutes,
34 3 minutes, 4 minutes, 5 minutes, 10 minutes, 15 minutes, 30 minutes, 1 hour,
35 1 hour and 30 minutes, 2 hours, 4 hours, and 8 hours. Default is 0.
36 type: int
37 metric:
38 description: The type of sensor metric that will be monitored for changes.
39 type: str
40 threshold:
41 description: Threshold for sensor readings that will cause an alert to be
42 sent. This object should contain a single property key matching the condition's
43 'metric' value.
44 suboptions:
45 apparentPower:
46 description: Apparent power threshold. 'draw' must be provided.
47 suboptions:
48 draw:
49 description: Alerting threshold in volt-amps. Must be between 0 and
50 3750.
51 type: float
52 type: dict
53 co2:
54 description: CO2 concentration threshold. One of 'concentration' or 'quality'
55 must be provided.
56 suboptions:
57 concentration:
58 description: Alerting threshold as CO2 parts per million.
59 type: int
60 quality:
61 description: Alerting threshold as a qualitative CO2 level.
62 type: str
63 type: dict
64 current:
65 description: Electrical current threshold. 'level' must be provided.
66 suboptions:
67 draw:
68 description: Alerting threshold in amps. Must be between 0 and 15.
69 type: float
70 type: dict
71 door:
72 description: Door open threshold. 'open' must be provided and set to true.
73 suboptions:
74 open:
75 description: Alerting threshold for a door open event. Must be set
76 to true.
77 type: bool
78 type: dict
79 frequency:
80 description: Electrical frequency threshold. 'level' must be provided.
81 suboptions:
82 level:
83 description: Alerting threshold in hertz. Must be between 0 and 60.
84 type: float
85 type: dict
86 humidity:
87 description: Humidity threshold. One of 'relativePercentage' or 'quality'
88 must be provided.
89 suboptions:
90 quality:
91 description: Alerting threshold as a qualitative humidity level.
92 type: str
93 relativePercentage:
94 description: Alerting threshold in %RH.
95 type: int
96 type: dict
97 indoorAirQuality:
98 description: Indoor air quality score threshold. One of 'score' or 'quality'
99 must be provided.
100 suboptions:
101 quality:
102 description: Alerting threshold as a qualitative indoor air quality
103 level.
104 type: str
105 score:
106 description: Alerting threshold as indoor air quality score.
107 type: int
108 type: dict
109 noise:
110 description: Noise threshold. 'ambient' must be provided.
111 suboptions:
112 ambient:
113 description: Ambient noise threshold. One of 'level' or 'quality'
114 must be provided.
115 suboptions:
116 level:
117 description: Alerting threshold as adjusted decibels.
118 type: int
119 quality:
120 description: Alerting threshold as a qualitative ambient noise
121 level.
122 type: str
123 type: dict
124 type: dict
125 pm25:
126 description: PM2.5 concentration threshold. One of 'concentration' or
127 'quality' must be provided.
128 suboptions:
129 concentration:
130 description: Alerting threshold as PM2.5 parts per million.
131 type: int
132 quality:
133 description: Alerting threshold as a qualitative PM2.5 level.
134 type: str
135 type: dict
136 powerFactor:
137 description: Power factor threshold. 'percentage' must be provided.
138 suboptions:
139 percentage:
140 description: Alerting threshold as the ratio of active power to apparent
141 power. Must be between 0 and 100.
142 type: int
143 type: dict
144 realPower:
145 description: Real power threshold. 'draw' must be provided.
146 suboptions:
147 draw:
148 description: Alerting threshold in watts. Must be between 0 and 3750.
149 type: float
150 type: dict
151 temperature:
152 description: Temperature threshold. One of 'celsius', 'fahrenheit', or
153 'quality' must be provided.
154 suboptions:
155 celsius:
156 description: Alerting threshold in degrees Celsius.
157 type: float
158 fahrenheit:
159 description: Alerting threshold in degrees Fahrenheit.
160 type: float
161 quality:
162 description: Alerting threshold as a qualitative temperature level.
163 type: str
164 type: dict
165 tvoc:
166 description: TVOC concentration threshold. One of 'concentration' or 'quality'
167 must be provided.
168 suboptions:
169 concentration:
170 description: Alerting threshold as TVOC micrograms per cubic meter.
171 type: int
172 quality:
173 description: Alerting threshold as a qualitative TVOC level.
174 type: str
175 type: dict
176 upstreamPower:
177 description: Upstream power threshold. 'outageDetected' must be provided
178 and set to true.
179 suboptions:
180 outageDetected:
181 description: Alerting threshold for an upstream power event. Must
182 be set to true.
183 type: bool
184 type: dict
185 voltage:
186 description: Voltage threshold. 'level' must be provided.
187 suboptions:
188 level:
189 description: Alerting threshold in volts. Must be between 0 and 250.
190 type: float
191 type: dict
192 water:
193 description: Water detection threshold. 'present' must be provided and
194 set to true.
195 suboptions:
196 present:
197 description: Alerting threshold for a water detection event. Must
198 be set to true.
199 type: bool
200 type: dict
201 type: dict
202 type: list
203 id:
204 description: Id path parameter.
205 type: str
206 includeSensorUrl:
207 description: Include dashboard link to sensor in messages (default true).
208 type: bool
209 message:
210 description: A custom message that will appear in email and text message alerts.
211 type: str
212 name:
213 description: Name of the sensor alert profile.
214 type: str
215 networkId:
216 description: NetworkId path parameter. Network ID.
217 type: str
218 recipients:
219 description: List of recipients that will receive the alert.
220 suboptions:
221 emails:
222 description: A list of emails that will receive information about the alert.
223 elements: str
224 type: list
225 httpServerIds:
226 description: A list of webhook endpoint IDs that will receive information
227 about the alert.
228 elements: str
229 type: list
230 smsNumbers:
231 description: A list of SMS numbers that will receive information about the
232 alert.
233 elements: str
234 type: list
235 type: dict
236 schedule:
237 description: The sensor schedule to use with the alert profile.
238 suboptions:
239 id:
240 description: ID of the sensor schedule to use with the alert profile. If not
241 defined, the alert profile will be active at all times.
242 type: str
243 type: dict
244 serials:
245 description: List of device serials assigned to this sensor alert profile.
246 elements: str
247 type: list
248 requirements:
249 - meraki >= 2.4.9
250 - python >= 3.5
251 seealso:
252 - name: Cisco Meraki documentation for sensor createNetworkSensorAlertsProfile
253 description: Complete reference of the createNetworkSensorAlertsProfile API.
254 link: https://developer.cisco.com/meraki/api-v1/#!create-network-sensor-alerts-profile
255 - name: Cisco Meraki documentation for sensor deleteNetworkSensorAlertsProfile
256 description: Complete reference of the deleteNetworkSensorAlertsProfile API.
257 link: https://developer.cisco.com/meraki/api-v1/#!delete-network-sensor-alerts-profile
258 - name: Cisco Meraki documentation for sensor updateNetworkSensorAlertsProfile
259 description: Complete reference of the updateNetworkSensorAlertsProfile API.
260 link: https://developer.cisco.com/meraki/api-v1/#!update-network-sensor-alerts-profile
261 notes:
262 - SDK Method used are
263 sensor.Sensor.create_network_sensor_alerts_profile,
264 sensor.Sensor.delete_network_sensor_alerts_profile,
265 sensor.Sensor.update_network_sensor_alerts_profile,
266 - Paths used are
267 post /networks/{networkId}/sensor/alerts/profiles,
268 delete /networks/{networkId}/sensor/alerts/profiles/{id},
269 put /networks/{networkId}/sensor/alerts/profiles/{id},
270 """
271
272 EXAMPLES = r"""
273 - name: Create
274 cisco.meraki.networks_sensor_alerts_profiles:
275 meraki_api_key: "{{ meraki_api_key }}"
276 meraki_base_url: "{{ meraki_base_url }}"
277 meraki_single_request_timeout: "{{ meraki_single_request_timeout }}"
278 meraki_certificate_path: "{{ meraki_certificate_path }}"
279 meraki_requests_proxy: "{{ meraki_requests_proxy }}"
280 meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}"
281 meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}"
282 meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}"
283 meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}"
284 meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}"
285 meraki_maximum_retries: "{{ meraki_maximum_retries }}"
286 meraki_output_log: "{{ meraki_output_log }}"
287 meraki_log_file_prefix: "{{ meraki_log_file_prefix }}"
288 meraki_log_path: "{{ meraki_log_path }}"
289 meraki_print_console: "{{ meraki_print_console }}"
290 meraki_suppress_logging: "{{ meraki_suppress_logging }}"
291 meraki_simulate: "{{ meraki_simulate }}"
292 meraki_be_geo_id: "{{ meraki_be_geo_id }}"
293 meraki_caller: "{{ meraki_caller }}"
294 meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}"
295 meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}"
296 state: present
297 conditions:
298 - direction: above
299 duration: 60
300 metric: temperature
301 threshold:
302 apparentPower:
303 draw: 17.2
304 co2:
305 concentration: 400
306 quality: poor
307 current:
308 draw: 0.14
309 door:
310 open: true
311 frequency:
312 level: 58.8
313 humidity:
314 quality: inadequate
315 relativePercentage: 65
316 indoorAirQuality:
317 quality: fair
318 score: 80
319 noise:
320 ambient:
321 level: 120
322 quality: poor
323 pm25:
324 concentration: 90
325 quality: fair
326 powerFactor:
327 percentage: 81
328 realPower:
329 draw: 14.1
330 temperature:
331 celsius: 20.5
332 fahrenheit: 70.0
333 quality: good
334 tvoc:
335 concentration: 400
336 quality: poor
337 upstreamPower:
338 outageDetected: true
339 voltage:
340 level: 119.5
341 water:
342 present: true
343 includeSensorUrl: true
344 message: Check with Miles on what to do.
345 name: My Sensor Alert Profile
346 networkId: string
347 recipients:
348 emails:
349 - [email protected]
350 httpServerIds:
351 - aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vd2ViaG9va3M=
352 smsNumbers:
353 - '+15555555555'
354 schedule:
355 id: '5'
356 serials:
357 - Q234-ABCD-0001
358 - Q234-ABCD-0002
359 - Q234-ABCD-0003
360 - name: Update by id
361 cisco.meraki.networks_sensor_alerts_profiles:
362 meraki_api_key: "{{ meraki_api_key }}"
363 meraki_base_url: "{{ meraki_base_url }}"
364 meraki_single_request_timeout: "{{ meraki_single_request_timeout }}"
365 meraki_certificate_path: "{{ meraki_certificate_path }}"
366 meraki_requests_proxy: "{{ meraki_requests_proxy }}"
367 meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}"
368 meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}"
369 meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}"
370 meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}"
371 meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}"
372 meraki_maximum_retries: "{{ meraki_maximum_retries }}"
373 meraki_output_log: "{{ meraki_output_log }}"
374 meraki_log_file_prefix: "{{ meraki_log_file_prefix }}"
375 meraki_log_path: "{{ meraki_log_path }}"
376 meraki_print_console: "{{ meraki_print_console }}"
377 meraki_suppress_logging: "{{ meraki_suppress_logging }}"
378 meraki_simulate: "{{ meraki_simulate }}"
379 meraki_be_geo_id: "{{ meraki_be_geo_id }}"
380 meraki_caller: "{{ meraki_caller }}"
381 meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}"
382 meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}"
383 state: present
384 conditions:
385 - direction: above
386 duration: 60
387 metric: temperature
388 threshold:
389 apparentPower:
390 draw: 17.2
391 co2:
392 concentration: 400
393 quality: poor
394 current:
395 draw: 0.14
396 door:
397 open: true
398 frequency:
399 level: 58.8
400 humidity:
401 quality: inadequate
402 relativePercentage: 65
403 indoorAirQuality:
404 quality: fair
405 score: 80
406 noise:
407 ambient:
408 level: 120
409 quality: poor
410 pm25:
411 concentration: 90
412 quality: fair
413 powerFactor:
414 percentage: 81
415 realPower:
416 draw: 14.1
417 temperature:
418 celsius: 20.5
419 fahrenheit: 70.0
420 quality: good
421 tvoc:
422 concentration: 400
423 quality: poor
424 upstreamPower:
425 outageDetected: true
426 voltage:
427 level: 119.5
428 water:
429 present: true
430 id: string
431 includeSensorUrl: true
432 message: Check with Miles on what to do.
433 name: My Sensor Alert Profile
434 networkId: string
435 recipients:
436 emails:
437 - [email protected]
438 httpServerIds:
439 - aHR0cHM6Ly93d3cuZXhhbXBsZS5jb20vd2ViaG9va3M=
440 smsNumbers:
441 - '+15555555555'
442 schedule:
443 id: '5'
444 serials:
445 - Q234-ABCD-0001
446 - Q234-ABCD-0002
447 - Q234-ABCD-0003
448 - name: Delete by id
449 cisco.meraki.networks_sensor_alerts_profiles:
450 meraki_api_key: "{{ meraki_api_key }}"
451 meraki_base_url: "{{ meraki_base_url }}"
452 meraki_single_request_timeout: "{{ meraki_single_request_timeout }}"
453 meraki_certificate_path: "{{ meraki_certificate_path }}"
454 meraki_requests_proxy: "{{ meraki_requests_proxy }}"
455 meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}"
456 meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}"
457 meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}"
458 meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}"
459 meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}"
460 meraki_maximum_retries: "{{ meraki_maximum_retries }}"
461 meraki_output_log: "{{ meraki_output_log }}"
462 meraki_log_file_prefix: "{{ meraki_log_file_prefix }}"
463 meraki_log_path: "{{ meraki_log_path }}"
464 meraki_print_console: "{{ meraki_print_console }}"
465 meraki_suppress_logging: "{{ meraki_suppress_logging }}"
466 meraki_simulate: "{{ meraki_simulate }}"
467 meraki_be_geo_id: "{{ meraki_be_geo_id }}"
468 meraki_caller: "{{ meraki_caller }}"
469 meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}"
470 meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}"
471 state: absent
472 id: string
473 networkId: string
474 """
475 RETURN = r"""
476 meraki_response:
477 description: A dictionary or list with the response returned by the Cisco Meraki Python SDK
478 returned: always
479 type: dict
480 sample: >
481 {
482 "profileId": "string",
483 "name": "string",
484 "schedule": {
485 "id": "string",
486 "name": "string"
487 },
488 "conditions": [
489 {
490 "metric": "string",
491 "threshold": {
492 "temperature": {
493 "celsius": 0,
494 "fahrenheit": 0,
495 "quality": "string"
496 },
497 "humidity": {
498 "relativePercentage": 0,
499 "quality": "string"
500 },
501 "water": {
502 "present": true
503 },
504 "door": {
505 "open": true
506 },
507 "tvoc": {
508 "concentration": 0,
509 "quality": "string"
510 },
511 "co2": {
512 "concentration": 0,
513 "quality": "string"
514 },
515 "pm25": {
516 "concentration": 0,
517 "quality": "string"
518 },
519 "noise": {
520 "ambient": {
521 "level": 0,
522 "quality": "string"
523 }
524 },
525 "indoorAirQuality": {
526 "score": 0,
527 "quality": "string"
528 },
529 "realPower": {
530 "draw": 0
531 },
532 "apparentPower": {
533 "draw": 0
534 },
535 "powerFactor": {
536 "percentage": 0
537 },
538 "current": {
539 "draw": 0
540 },
541 "voltage": {
542 "level": 0
543 },
544 "frequency": {
545 "level": 0
546 },
547 "upstreamPower": {
548 "outageDetected": true
549 }
550 },
551 "direction": "string",
552 "duration": 0
553 }
554 ],
555 "recipients": {
556 "emails": [
557 "string"
558 ],
559 "smsNumbers": [
560 "string"
561 ],
562 "httpServerIds": [
563 "string"
564 ]
565 },
566 "serials": [
567 "string"
568 ],
569 "includeSensorUrl": true,
570 "message": "string"
571 }
572 """