Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_alertconsole.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_alertconsole
15 short_description: Alert console.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_crud
20 options:
21 system_alertconsole:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 period:
27 type: str
28 description:
29 - Alert console keeps alerts for this period.
30 - 1 - 1 day.
31 - 2 - 2 days.
32 - 3 - 3 days.
33 - 4 - 4 days.
34 - 5 - 5 days.
35 - 6 - 6 days.
36 - 7 - 7 days.
37 choices: ['1', '2', '3', '4', '5', '6', '7']
38 severity_level:
39 aliases: ['severity-level']
40 type: list
41 elements: str
42 description:
43 - Alert console keeps alerts of this and higher severity.
44 - debug - Debug level.
45 - information - Information level.
46 - notify - Notify level.
47 - warning - Warning level.
48 - error - Error level.
49 - critical - Critical level.
50 - alert - Alert level.
51 - emergency - Emergency level.
52 choices: ['debug', 'information', 'notify', 'warning', 'error', 'critical',
53 'alert', 'emergency']
54 '''
55
56 EXAMPLES = '''
57 - name: Example playbook (generated based on argument schema)
58 hosts: fortimanagers
59 connection: httpapi
60 gather_facts: false
61 tasks:
62 - name: Alert console.
63 fortinet.fortimanager.fmgr_system_alertconsole:
64 # workspace_locking_adom: <global or your adom name>
65 system_alertconsole:
66 # period: <value in [1, 2, 3, ...]>
67 # severity_level: ["debug", "information", "notify", "warning", "error", "critical",
68 # "alert", "emergency"]
69 '''
70
71 RETURN = '''
72 meta:
73 description: The result of the request.
74 type: dict
75 returned: always
76 contains:
77 request_url:
78 description: The full url requested.
79 returned: always
80 type: str
81 sample: /sys/login/user
82 response_code:
83 description: The status of api request.
84 returned: always
85 type: int
86 sample: 0
87 response_data:
88 description: The api response.
89 type: list
90 returned: always
91 response_message:
92 description: The descriptive message of the api response.
93 type: str
94 returned: always
95 sample: OK.
96 system_information:
97 description: The information of the target system.
98 type: dict
99 returned: always
100 rc:
101 description: The status the request.
102 type: int
103 returned: always
104 sample: 0
105 version_check_warning:
106 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
107 type: list
108 returned: complex
109 '''
110 from ansible.module_utils.basic import AnsibleModule
111 from ansible.module_utils.connection import Connection
112 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
113 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
114
115
116 def main():
117 urls_list = [
118 '/cli/global/system/alert-console'
119 ]
120 module_arg_spec = {
121 'system_alertconsole': {
122 'type': 'dict', 'v_range': [['6.0.0', '']],
123 'options': {
124 'period': {'choices': ['1', '2', '3', '4', '5', '6', '7'], 'type': 'str'},
125 'severity-level': {
126 'type': 'list',
127 'choices': ['debug', 'information', 'notify', 'warning', 'error', 'critical', 'alert', 'emergency'],
128 'elements': 'str'
129 }
130 }
131 }
132 }
133
134 module_option_spec = get_module_arg_spec('partial crud')
135 module_arg_spec.update(module_option_spec)
136 check_galaxy_version(module_arg_spec)
137 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_alertconsole'),
138 supports_check_mode=True)
139 if not module._socket_path:
140 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
141 connection = Connection(module._socket_path)
142 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
143 None, 'data', module, connection)
144 fmgr.process_partial_crud()
145 module.exit_json(meta=module.params)
146
147
148 if __name__ == '__main__':
149 main()