Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_autodelete.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_autodelete
15 short_description: Automatic deletion policy for logs, reports, archived, and quarantined files.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_crud
20 options:
21 system_autodelete:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 dlp_files_auto_deletion:
27 aliases: ['dlp-files-auto-deletion']
28 type: dict
29 description: Dlp files auto deletion.
30 suboptions:
31 retention:
32 type: str
33 description:
34 - Automatic deletion in days, weeks, or months.
35 - days - Auto-delete data older than
36 - weeks - Auto-delete data older than
37 - months - Auto-delete data older than
38 choices: ['days', 'weeks', 'months']
39 runat:
40 type: int
41 description: Automatic deletion run at
42 status:
43 type: str
44 description:
45 - Enable/disable automatic deletion.
46 - disable - Disable automatic deletion.
47 - enable - Enable automatic deletion.
48 choices: ['disable', 'enable']
49 value:
50 type: int
51 description: Automatic deletion in x days, weeks, or months.
52 log_auto_deletion:
53 aliases: ['log-auto-deletion']
54 type: dict
55 description: Log auto deletion.
56 suboptions:
57 retention:
58 type: str
59 description:
60 - Automatic deletion in days, weeks, or months.
61 - days - Auto-delete data older than
62 - weeks - Auto-delete data older than
63 - months - Auto-delete data older than
64 choices: ['days', 'weeks', 'months']
65 runat:
66 type: int
67 description: Automatic deletion run at
68 status:
69 type: str
70 description:
71 - Enable/disable automatic deletion.
72 - disable - Disable automatic deletion.
73 - enable - Enable automatic deletion.
74 choices: ['disable', 'enable']
75 value:
76 type: int
77 description: Automatic deletion in x days, weeks, or months.
78 quarantine_files_auto_deletion:
79 aliases: ['quarantine-files-auto-deletion']
80 type: dict
81 description: Quarantine files auto deletion.
82 suboptions:
83 retention:
84 type: str
85 description:
86 - Automatic deletion in days, weeks, or months.
87 - days - Auto-delete data older than
88 - weeks - Auto-delete data older than
89 - months - Auto-delete data older than
90 choices: ['days', 'weeks', 'months']
91 runat:
92 type: int
93 description: Automatic deletion run at
94 status:
95 type: str
96 description:
97 - Enable/disable automatic deletion.
98 - disable - Disable automatic deletion.
99 - enable - Enable automatic deletion.
100 choices: ['disable', 'enable']
101 value:
102 type: int
103 description: Automatic deletion in x days, weeks, or months.
104 report_auto_deletion:
105 aliases: ['report-auto-deletion']
106 type: dict
107 description: Report auto deletion.
108 suboptions:
109 retention:
110 type: str
111 description:
112 - Automatic deletion in days, weeks, or months.
113 - days - Auto-delete data older than
114 - weeks - Auto-delete data older than
115 - months - Auto-delete data older than
116 choices: ['days', 'weeks', 'months']
117 runat:
118 type: int
119 description: Automatic deletion run at
120 status:
121 type: str
122 description:
123 - Enable/disable automatic deletion.
124 - disable - Disable automatic deletion.
125 - enable - Enable automatic deletion.
126 choices: ['disable', 'enable']
127 value:
128 type: int
129 description: Automatic deletion in x days, weeks, or months.
130 status_fake:
131 aliases: ['status-fake']
132 type: int
133 description: Fake value for the menu to work.
134 '''
135
136 EXAMPLES = '''
137 - name: Example playbook (generated based on argument schema)
138 hosts: fortimanagers
139 connection: httpapi
140 gather_facts: false
141 tasks:
142 - name: Automatic deletion policy for logs, reports, archived, and quarantined files.
143 fortinet.fortimanager.fmgr_system_autodelete:
144 # workspace_locking_adom: <global or your adom name>
145 system_autodelete:
146 # dlp_files_auto_deletion:
147 # retention: <value in [days, weeks, months]>
148 # runat: <integer>
149 # status: <value in [disable, enable]>
150 # value: <integer>
151 # log_auto_deletion:
152 # retention: <value in [days, weeks, months]>
153 # runat: <integer>
154 # status: <value in [disable, enable]>
155 # value: <integer>
156 # quarantine_files_auto_deletion:
157 # retention: <value in [days, weeks, months]>
158 # runat: <integer>
159 # status: <value in [disable, enable]>
160 # value: <integer>
161 # report_auto_deletion:
162 # retention: <value in [days, weeks, months]>
163 # runat: <integer>
164 # status: <value in [disable, enable]>
165 # value: <integer>
166 # status_fake: <integer>
167 '''
168
169 RETURN = '''
170 meta:
171 description: The result of the request.
172 type: dict
173 returned: always
174 contains:
175 request_url:
176 description: The full url requested.
177 returned: always
178 type: str
179 sample: /sys/login/user
180 response_code:
181 description: The status of api request.
182 returned: always
183 type: int
184 sample: 0
185 response_data:
186 description: The api response.
187 type: list
188 returned: always
189 response_message:
190 description: The descriptive message of the api response.
191 type: str
192 returned: always
193 sample: OK.
194 system_information:
195 description: The information of the target system.
196 type: dict
197 returned: always
198 rc:
199 description: The status the request.
200 type: int
201 returned: always
202 sample: 0
203 version_check_warning:
204 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
205 type: list
206 returned: complex
207 '''
208 from ansible.module_utils.basic import AnsibleModule
209 from ansible.module_utils.connection import Connection
210 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
211 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
212
213
214 def main():
215 urls_list = [
216 '/cli/global/system/auto-delete'
217 ]
218 module_arg_spec = {
219 'system_autodelete': {
220 'type': 'dict', 'v_range': [['6.0.0', '']],
221 'options': {
222 'dlp-files-auto-deletion': {
223 'type': 'dict',
224 'options': {
225 'retention': {'choices': ['days', 'weeks', 'months'], 'type': 'str'},
226 'runat': {'type': 'int'},
227 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
228 'value': {'type': 'int'}
229 }
230 },
231 'log-auto-deletion': {
232 'type': 'dict',
233 'options': {
234 'retention': {'choices': ['days', 'weeks', 'months'], 'type': 'str'},
235 'runat': {'type': 'int'},
236 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
237 'value': {'type': 'int'}
238 }
239 },
240 'quarantine-files-auto-deletion': {
241 'type': 'dict',
242 'options': {
243 'retention': {'choices': ['days', 'weeks', 'months'], 'type': 'str'},
244 'runat': {'type': 'int'},
245 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
246 'value': {'type': 'int'}
247 }
248 },
249 'report-auto-deletion': {
250 'type': 'dict',
251 'options': {
252 'retention': {'choices': ['days', 'weeks', 'months'], 'type': 'str'},
253 'runat': {'type': 'int'},
254 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
255 'value': {'type': 'int'}
256 }
257 },
258 'status-fake': {'type': 'int'}
259 }
260 }
261 }
262
263 module_option_spec = get_module_arg_spec('partial crud')
264 module_arg_spec.update(module_option_spec)
265 check_galaxy_version(module_arg_spec)
266 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_autodelete'),
267 supports_check_mode=True)
268 if not module._socket_path:
269 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
270 connection = Connection(module._socket_path)
271 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
272 None, 'data', module, connection)
273 fmgr.process_partial_crud()
274 module.exit_json(meta=module.params)
275
276
277 if __name__ == '__main__':
278 main()