Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_alertevent_alertdestination.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_system_alertevent_alertdestination
15 short_description: Alert destination.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 alert-event:
22 description: Deprecated, please use "alert_event"
23 type: str
24 alert_event:
25 description: The parameter (alert-event) in requested url.
26 type: str
27 system_alertevent_alertdestination:
28 description: The top level parameters set.
29 required: false
30 type: dict
31 suboptions:
32 from:
33 type: str
34 description: Sender email address to use in alert emails.
35 smtp_name:
36 aliases: ['smtp-name']
37 type: str
38 description: SMTP server name.
39 snmp_name:
40 aliases: ['snmp-name']
41 type: str
42 description: SNMP trap name.
43 syslog_name:
44 aliases: ['syslog-name']
45 type: str
46 description: Syslog server name.
47 to:
48 type: str
49 description: Recipient email address to use in alert emails.
50 type:
51 type: str
52 description:
53 - Destination type.
54 - mail - Send email alert.
55 - snmp - Send SNMP trap.
56 - syslog - Send syslog message.
57 choices: ['mail', 'snmp', 'syslog']
58 '''
59
60 EXAMPLES = '''
61 - name: Example playbook (generated based on argument schema)
62 hosts: fortimanagers
63 connection: httpapi
64 gather_facts: false
65 tasks:
66 - name: Alert destination.
67 fortinet.fortimanager.fmgr_system_alertevent_alertdestination:
68 # workspace_locking_adom: <global or your adom name>
69 alert_event: <your own value>
70 state: present # <value in [present, absent]>
71 system_alertevent_alertdestination:
72 # from: <string>
73 # smtp_name: <string>
74 # snmp_name: <string>
75 # syslog_name: <string>
76 # to: <string>
77 # type: <value in [mail, snmp, syslog]>
78 '''
79
80 RETURN = '''
81 meta:
82 description: The result of the request.
83 type: dict
84 returned: always
85 contains:
86 request_url:
87 description: The full url requested.
88 returned: always
89 type: str
90 sample: /sys/login/user
91 response_code:
92 description: The status of api request.
93 returned: always
94 type: int
95 sample: 0
96 response_data:
97 description: The api response.
98 type: list
99 returned: always
100 response_message:
101 description: The descriptive message of the api response.
102 type: str
103 returned: always
104 sample: OK.
105 system_information:
106 description: The information of the target system.
107 type: dict
108 returned: always
109 rc:
110 description: The status the request.
111 type: int
112 returned: always
113 sample: 0
114 version_check_warning:
115 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
116 type: list
117 returned: complex
118 '''
119 from ansible.module_utils.basic import AnsibleModule
120 from ansible.module_utils.connection import Connection
121 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
122 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
123
124
125 def main():
126 urls_list = [
127 '/cli/global/system/alert-event/{alert-event}/alert-destination'
128 ]
129 module_arg_spec = {
130 'alert-event': {'type': 'str', 'api_name': 'alert_event'},
131 'alert_event': {'type': 'str'},
132 'system_alertevent_alertdestination': {
133 'type': 'dict', 'v_range': [['6.0.0', '']],
134 'options': {
135 'from': {'type': 'str'},
136 'smtp-name': {'type': 'str'},
137 'snmp-name': {'type': 'str'},
138 'syslog-name': {'type': 'str'},
139 'to': {'type': 'str'},
140 'type': {'choices': ['mail', 'snmp', 'syslog'], 'type': 'str'}
141 }
142 }
143 }
144
145 module_option_spec = get_module_arg_spec('full crud')
146 module_arg_spec.update(module_option_spec)
147 check_galaxy_version(module_arg_spec)
148 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_alertevent_alertdestination'),
149 supports_check_mode=True)
150 if not module._socket_path:
151 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
152 connection = Connection(module._socket_path)
153 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
154 None, 'data', module, connection)
155 fmgr.process_crud()
156 module.exit_json(meta=module.params)
157
158
159 if __name__ == '__main__':
160 main()