Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_logfetch_clientprofile.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_logfetch_clientprofile
15 short_description: Log-fetch client profile settings.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_logfetch_clientprofile:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 client_adom:
27 aliases: ['client-adom']
28 type: str
29 description: Log-fetch client sides adom name.
30 data_range:
31 aliases: ['data-range']
32 type: str
33 description:
34 - Data-range for fetched logs.
35 - custom - Specify some other date and time range.
36 choices: ['custom']
37 data_range_value:
38 aliases: ['data-range-value']
39 type: int
40 description: Last n days or hours.
41 device_filter:
42 aliases: ['device-filter']
43 type: list
44 elements: dict
45 description: Device filter.
46 suboptions:
47 adom:
48 type: str
49 description: Adom name.
50 device:
51 type: str
52 description: Device name or Serial number.
53 id:
54 type: int
55 description: Add or edit a device filter.
56 vdom:
57 type: str
58 description: Vdom filters.
59 end_time:
60 aliases: ['end-time']
61 type: raw
62 description: (list) End date and time of the data-range
63 id:
64 type: int
65 description: Log-fetch client profile ID.
66 required: true
67 index_fetch_logs:
68 aliases: ['index-fetch-logs']
69 type: str
70 description:
71 - Enable/Disable indexing logs automatically after fetching logs.
72 - disable - Disable attribute function.
73 - enable - Enable attribute function.
74 choices: ['disable', 'enable']
75 log_filter:
76 aliases: ['log-filter']
77 type: list
78 elements: dict
79 description: Log filter.
80 suboptions:
81 field:
82 type: str
83 description: Field name.
84 id:
85 type: int
86 description: Log filter ID.
87 oper:
88 type: str
89 description:
90 - Field filter operator.
91 - no description
92 - no description
93 - contain - Contain
94 - not-contain - Not contain
95 - match - Match
96 choices: ['=', '!=', '<', '>', '<=', '>=', 'contain', 'not-contain',
97 'match']
98 value:
99 type: str
100 description: Field filter operand or free-text matching expression.
101 log_filter_logic:
102 aliases: ['log-filter-logic']
103 type: str
104 description:
105 - And/Or logic for log-filters.
106 - and - Logic And.
107 - or - Logic Or.
108 choices: ['and', 'or']
109 log_filter_status:
110 aliases: ['log-filter-status']
111 type: str
112 description:
113 - Enable/Disable log-filter.
114 - disable - Disable attribute function.
115 - enable - Enable attribute function.
116 choices: ['disable', 'enable']
117 name:
118 type: str
119 description: Name of log-fetch client profile.
120 password:
121 type: raw
122 description: (list) Log-fetch server login password.
123 secure_connection:
124 aliases: ['secure-connection']
125 type: str
126 description:
127 - Enable/Disable protecting log-fetch connection with TLS/SSL.
128 - disable - Disable attribute function.
129 - enable - Enable attribute function.
130 choices: ['disable', 'enable']
131 server_adom:
132 aliases: ['server-adom']
133 type: str
134 description: Log-fetch server sides adom name.
135 server_ip:
136 aliases: ['server-ip']
137 type: str
138 description: Log-fetch server IP address.
139 start_time:
140 aliases: ['start-time']
141 type: raw
142 description: (list) Start date and time of the data-range
143 sync_adom_config:
144 aliases: ['sync-adom-config']
145 type: str
146 description:
147 - Enable/Disable sync adom related config.
148 - disable - Disable attribute function.
149 - enable - Enable attribute function.
150 choices: ['disable', 'enable']
151 user:
152 type: str
153 description: Log-fetch server login username.
154 peer_cert_cn:
155 aliases: ['peer-cert-cn']
156 type: str
157 description: Certificate common name of log-fetch server.
158 '''
159
160 EXAMPLES = '''
161 - name: Example playbook
162 hosts: fortimanagers
163 gather_facts: false
164 connection: httpapi
165 vars:
166 ansible_httpapi_use_ssl: true
167 ansible_httpapi_validate_certs: false
168 ansible_httpapi_port: 443
169 tasks:
170 - name: Log-fetch client profile settings.
171 fortinet.fortimanager.fmgr_system_logfetch_clientprofile:
172 bypass_validation: false
173 state: present
174 system_logfetch_clientprofile:
175 client_adom: ansible
176 data_range: custom # <value in [custom]>
177 id: 1
178 index_fetch_logs: enable
179 name: ansible-test-clientprofile
180 password: fortinet
181 server_ip: "222.222.22.25"
182 user: ansible
183
184 - name: Gathering fortimanager facts
185 hosts: fortimanagers
186 gather_facts: false
187 connection: httpapi
188 vars:
189 ansible_httpapi_use_ssl: true
190 ansible_httpapi_validate_certs: false
191 ansible_httpapi_port: 443
192 tasks:
193 - name: Retrieve all the Log-fetch client profile settings
194 fortinet.fortimanager.fmgr_fact:
195 facts:
196 selector: "system_logfetch_clientprofile"
197 params:
198 client_profile: "your_value"
199 '''
200
201 RETURN = '''
202 meta:
203 description: The result of the request.
204 type: dict
205 returned: always
206 contains:
207 request_url:
208 description: The full url requested.
209 returned: always
210 type: str
211 sample: /sys/login/user
212 response_code:
213 description: The status of api request.
214 returned: always
215 type: int
216 sample: 0
217 response_data:
218 description: The api response.
219 type: list
220 returned: always
221 response_message:
222 description: The descriptive message of the api response.
223 type: str
224 returned: always
225 sample: OK.
226 system_information:
227 description: The information of the target system.
228 type: dict
229 returned: always
230 rc:
231 description: The status the request.
232 type: int
233 returned: always
234 sample: 0
235 version_check_warning:
236 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
237 type: list
238 returned: complex
239 '''
240 from ansible.module_utils.basic import AnsibleModule
241 from ansible.module_utils.connection import Connection
242 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
243 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
244
245
246 def main():
247 urls_list = [
248 '/cli/global/system/log-fetch/client-profile'
249 ]
250 module_arg_spec = {
251 'system_logfetch_clientprofile': {
252 'type': 'dict', 'v_range': [['6.0.0', '7.2.1']],
253 'options': {
254 'client-adom': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
255 'data-range': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['custom'], 'type': 'str'},
256 'data-range-value': {'v_range': [['6.0.0', '7.2.1']], 'type': 'int'},
257 'device-filter': {
258 'v_range': [['6.0.0', '7.2.1']],
259 'type': 'list',
260 'options': {
261 'adom': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
262 'device': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
263 'id': {'v_range': [['6.0.0', '7.2.1']], 'type': 'int'},
264 'vdom': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'}
265 },
266 'elements': 'dict'
267 },
268 'end-time': {'v_range': [['6.0.0', '7.2.1']], 'type': 'raw'},
269 'id': {'v_range': [['6.0.0', '7.2.1']], 'required': True, 'type': 'int'},
270 'index-fetch-logs': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'},
271 'log-filter': {
272 'v_range': [['6.0.0', '7.2.1']],
273 'type': 'list',
274 'options': {
275 'field': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
276 'id': {'v_range': [['6.0.0', '7.2.1']], 'type': 'int'},
277 'oper': {
278 'v_range': [['6.0.0', '7.2.1']],
279 'choices': ['=', '!=', '<', '>', '<=', '>=', 'contain', 'not-contain', 'match'],
280 'type': 'str'
281 },
282 'value': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'}
283 },
284 'elements': 'dict'
285 },
286 'log-filter-logic': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['and', 'or'], 'type': 'str'},
287 'log-filter-status': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'},
288 'name': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
289 'password': {'v_range': [['6.0.0', '7.2.1']], 'no_log': True, 'type': 'raw'},
290 'secure-connection': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'},
291 'server-adom': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
292 'server-ip': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
293 'start-time': {'v_range': [['6.0.0', '7.2.1']], 'type': 'raw'},
294 'sync-adom-config': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'},
295 'user': {'v_range': [['6.0.0', '7.2.1']], 'type': 'str'},
296 'peer-cert-cn': {'v_range': [['7.0.3', '7.2.1']], 'type': 'str'}
297 }
298 }
299 }
300
301 module_option_spec = get_module_arg_spec('full crud')
302 module_arg_spec.update(module_option_spec)
303 check_galaxy_version(module_arg_spec)
304 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_logfetch_clientprofile'),
305 supports_check_mode=True)
306 if not module._socket_path:
307 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
308 connection = Connection(module._socket_path)
309 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
310 'id', 'data', module, connection)
311 fmgr.process_crud()
312 module.exit_json(meta=module.params)
313
314
315 if __name__ == '__main__':
316 main()