Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_log_alert.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_log_alert
15 short_description: Log based alert settings.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_crud
20 options:
21 system_log_alert:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 max_alert_count:
27 aliases: ['max-alert-count']
28 type: int
29 description: Maximum number of alerts supported.
30 min_severity_to_raise_incident_by_grouping:
31 aliases: ['min-severity-to-raise-incident-by-grouping']
32 type: str
33 description: Min severity to raise incident by grouping.
34 choices: ['none', 'critical', 'high']
35 '''
36
37 EXAMPLES = '''
38 - name: Example playbook (generated based on argument schema)
39 hosts: fortimanagers
40 connection: httpapi
41 gather_facts: false
42 tasks:
43 - name: Log based alert settings.
44 fortinet.fortimanager.fmgr_system_log_alert:
45 # workspace_locking_adom: <global or your adom name>
46 system_log_alert:
47 # max_alert_count: <integer>
48 # min_severity_to_raise_incident_by_grouping: <value in [none, critical, high]>
49 '''
50
51 RETURN = '''
52 meta:
53 description: The result of the request.
54 type: dict
55 returned: always
56 contains:
57 request_url:
58 description: The full url requested.
59 returned: always
60 type: str
61 sample: /sys/login/user
62 response_code:
63 description: The status of api request.
64 returned: always
65 type: int
66 sample: 0
67 response_data:
68 description: The api response.
69 type: list
70 returned: always
71 response_message:
72 description: The descriptive message of the api response.
73 type: str
74 returned: always
75 sample: OK.
76 system_information:
77 description: The information of the target system.
78 type: dict
79 returned: always
80 rc:
81 description: The status the request.
82 type: int
83 returned: always
84 sample: 0
85 version_check_warning:
86 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
87 type: list
88 returned: complex
89 '''
90 from ansible.module_utils.basic import AnsibleModule
91 from ansible.module_utils.connection import Connection
92 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
93 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
94
95
96 def main():
97 urls_list = [
98 '/cli/global/system/log/alert'
99 ]
100 module_arg_spec = {
101 'system_log_alert': {
102 'type': 'dict', 'v_range': [['6.0.0', '']],
103 'options': {
104 'max-alert-count': {'type': 'int'},
105 'min-severity-to-raise-incident-by-grouping': {'v_range': [['7.6.4', '']], 'choices': ['none', 'critical', 'high'], 'type': 'str'}
106 }
107 }
108 }
109
110 module_option_spec = get_module_arg_spec('partial crud')
111 module_arg_spec.update(module_option_spec)
112 check_galaxy_version(module_arg_spec)
113 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_log_alert'),
114 supports_check_mode=True)
115 if not module._socket_path:
116 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
117 connection = Connection(module._socket_path)
118 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
119 None, 'data', module, connection)
120 fmgr.process_partial_crud()
121 module.exit_json(meta=module.params)
122
123
124 if __name__ == '__main__':
125 main()