-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathemail_alert_info.py
More file actions
121 lines (102 loc) · 3.15 KB
/
email_alert_info.py
File metadata and controls
121 lines (102 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2023, XLAB Steampunk <steampunk@xlab.si>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
__metaclass__ = type
# language=yaml
DOCUMENTATION = r"""
module: email_alert_info
author:
- Ana Zobec (@anazobec)
short_description: List Email Alert Recipients on HyperCore API
description:
- Use this module to list information about the DNS configuration on HyperCore API.
version_added: 1.2.0
extends_documentation_fragment:
- scale_computing.hypercore.cluster_instance
seealso:
- module: scale_computing.hypercore.email_alert
"""
# language=yaml
EXAMPLES = r"""
- name: List all Email Alert Recipients on HyperCore API
scale_computing.hypercore.email_alert_info:
register: email_alert
"""
# language=yaml
RETURN = r"""
records:
description:
- A list of Email Alert Recipient records.
returned: success
type: list
contains:
alert_tag_uuid:
description: Unique identifier for an AlertTag
type: str
sample: 0
email:
description: Email address of the alert recipient
type: str
sample: sample@sample.com
latest_task_tag:
description: Latest Task Tag
type: dict
sample:
completed: 1675680830
created: 1675680830
descriptionParameters: []
formattedDescription: Create Alert Email Target
formattedMessage: ""
messageParameters: []
modified: 1675680830
nodeUUIDs: []
objectUUID: 8664ed18-c354-4bab-be96-78dae5f6377f
progressPercent: 100
sessionID: 2bed8c34-1ef3-4366-8895-360f4f786afe
state: COMPLETE
taskTag: 813
resend_delay:
description: Alert resend delay in seconds
type: int
sample: 86400
silent_period:
description: Alerts will not resend if there are additional event triggers within this time in seconds
type: int
sample: 900
uuid:
description: Unique identifer
type: str
sample: default-target
"""
from typing import List
from typing import Optional
from ansible.module_utils.basic import AnsibleModule
from ..module_utils import arguments
from ..module_utils import errors
from ..module_utils.client import Client
from ..module_utils.email_alert import EmailAlert
from ..module_utils.rest_client import RestClient
from ..module_utils.typed_classes import TypedEmailAlertToAnsible
def run(rest_client: RestClient) -> List[Optional[TypedEmailAlertToAnsible]]:
return EmailAlert.get_state(rest_client)
def main() -> None:
module = AnsibleModule(
supports_check_mode=True,
argument_spec=dict(
arguments.get_spec("cluster_instance"),
),
)
try:
with Client.get_client(module.params["cluster_instance"]) as client:
rest_client = RestClient(client)
records = run(rest_client)
module.exit_json(changed=False, records=records)
except errors.ScaleComputingError as e:
module.fail_json(msg=str(e))
if __name__ == "__main__":
main()