Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_casb_profile.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_casb_profile
15 short_description: Configure CASB profile.
16 version_added: "2.3.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 casb_profile:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 name:
34 type: str
35 description: CASB profile name.
36 required: true
37 saas_application:
38 aliases: ['saas-application']
39 type: list
40 elements: dict
41 description: Saas application.
42 suboptions:
43 access_rule:
44 aliases: ['access-rule']
45 type: list
46 elements: dict
47 description: Access rule.
48 suboptions:
49 action:
50 type: str
51 description: CASB access rule action.
52 choices: ['block', 'bypass', 'monitor']
53 bypass:
54 type: list
55 elements: str
56 description: CASB bypass options.
57 choices: ['av', 'dlp', 'web-filter', 'file-filter', 'video-filter']
58 name:
59 type: str
60 description: CASB access rule activity name.
61 attribute_filter:
62 aliases: ['attribute-filter']
63 type: list
64 elements: dict
65 description: Attribute filter.
66 suboptions:
67 action:
68 type: str
69 description: CASB access rule tenant control action.
70 choices: ['block', 'monitor', 'bypass']
71 attribute_match:
72 aliases: ['attribute-match']
73 type: list
74 elements: str
75 description: CASB access rule tenant match.
76 id:
77 type: int
78 description: CASB tenant control ID.
79 custom_control:
80 aliases: ['custom-control']
81 type: list
82 elements: dict
83 description: Custom control.
84 suboptions:
85 name:
86 type: str
87 description: CASB custom control user activity name.
88 option:
89 type: list
90 elements: dict
91 description: Option.
92 suboptions:
93 name:
94 type: str
95 description: CASB custom control option name.
96 user_input:
97 aliases: ['user-input']
98 type: list
99 elements: str
100 description: CASB custom control user input.
101 attribute_filter:
102 aliases: ['attribute-filter']
103 type: list
104 elements: dict
105 description: Attribute filter.
106 suboptions:
107 action:
108 type: str
109 description: CASB access rule tenant control action.
110 choices: ['block', 'monitor', 'bypass']
111 attribute_match:
112 aliases: ['attribute-match']
113 type: list
114 elements: str
115 description: CASB access rule tenant match.
116 id:
117 type: int
118 description: CASB tenant control ID.
119 domain_control:
120 aliases: ['domain-control']
121 type: str
122 description: Enable/disable domain control.
123 choices: ['disable', 'enable']
124 domain_control_domains:
125 aliases: ['domain-control-domains']
126 type: list
127 elements: str
128 description: CASB profile domain control domains.
129 log:
130 type: str
131 description: Enable/disable log settings.
132 choices: ['disable', 'enable']
133 name:
134 type: str
135 description: CASB profile SaaS application name.
136 safe_search:
137 aliases: ['safe-search']
138 type: str
139 description: Enable/disable safe search.
140 choices: ['disable', 'enable']
141 safe_search_control:
142 aliases: ['safe-search-control']
143 type: list
144 elements: str
145 description: CASB profile safe search control.
146 tenant_control:
147 aliases: ['tenant-control']
148 type: str
149 description: Enable/disable tenant control.
150 choices: ['disable', 'enable']
151 tenant_control_tenants:
152 aliases: ['tenant-control-tenants']
153 type: list
154 elements: str
155 description: CASB profile tenant control tenants.
156 status:
157 type: str
158 description: Enable/disable setting.
159 choices: ['disable', 'enable']
160 advanced_tenant_control:
161 aliases: ['advanced-tenant-control']
162 type: list
163 elements: dict
164 description: Advanced tenant control.
165 suboptions:
166 attribute:
167 type: list
168 elements: dict
169 description: Attribute.
170 suboptions:
171 input:
172 type: list
173 elements: str
174 description: CASB extend user input value.
175 name:
176 type: str
177 description: CASB extend user input name.
178 name:
179 type: list
180 elements: str
181 description: CASB advanced tenant control name.
182 comment:
183 type: str
184 description: Comment.
185 '''
186
187 EXAMPLES = '''
188 - name: Example playbook (generated based on argument schema)
189 hosts: fortimanagers
190 connection: httpapi
191 gather_facts: false
192 tasks:
193 - name: Configure CASB profile.
194 fortinet.fortimanager.fmgr_casb_profile:
195 # workspace_locking_adom: <global or your adom name>
196 adom: <your own value>
197 state: present # <value in [present, absent]>
198 casb_profile:
199 name: "your value" # Required variable, string
200 # saas_application:
201 # - access_rule:
202 # - action: <value in [block, bypass, monitor]>
203 # bypass: ["av", "dlp", "web-filter", "file-filter", "video-filter"]
204 # name: <string>
205 # attribute_filter:
206 # - action: <value in [block, monitor, bypass]>
207 # attribute_match: <list or string>
208 # id: <integer>
209 # custom_control:
210 # - name: <string>
211 # option:
212 # - name: <string>
213 # user_input: <list or string>
214 # attribute_filter:
215 # - action: <value in [block, monitor, bypass]>
216 # attribute_match: <list or string>
217 # id: <integer>
218 # domain_control: <value in [disable, enable]>
219 # domain_control_domains: <list or string>
220 # log: <value in [disable, enable]>
221 # name: <string>
222 # safe_search: <value in [disable, enable]>
223 # safe_search_control: <list or string>
224 # tenant_control: <value in [disable, enable]>
225 # tenant_control_tenants: <list or string>
226 # status: <value in [disable, enable]>
227 # advanced_tenant_control:
228 # - attribute:
229 # - input: <list or string>
230 # name: <string>
231 # name: <list or string>
232 # comment: <string>
233 '''
234
235 RETURN = '''
236 meta:
237 description: The result of the request.
238 type: dict
239 returned: always
240 contains:
241 request_url:
242 description: The full url requested.
243 returned: always
244 type: str
245 sample: /sys/login/user
246 response_code:
247 description: The status of api request.
248 returned: always
249 type: int
250 sample: 0
251 response_data:
252 description: The api response.
253 type: list
254 returned: always
255 response_message:
256 description: The descriptive message of the api response.
257 type: str
258 returned: always
259 sample: OK.
260 system_information:
261 description: The information of the target system.
262 type: dict
263 returned: always
264 rc:
265 description: The status the request.
266 type: int
267 returned: always
268 sample: 0
269 version_check_warning:
270 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
271 type: list
272 returned: complex
273 '''
274 from ansible.module_utils.basic import AnsibleModule
275 from ansible.module_utils.connection import Connection
276 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
277 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
278
279
280 def main():
281 urls_list = [
282 '/pm/config/adom/{adom}/obj/casb/profile',
283 '/pm/config/global/obj/casb/profile'
284 ]
285 module_arg_spec = {
286 'adom': {'required': True, 'type': 'str'},
287 'revision_note': {'type': 'str'},
288 'casb_profile': {
289 'type': 'dict', 'v_range': [['7.4.1', '']],
290 'options': {
291 'name': {'v_range': [['7.4.1', '']], 'required': True, 'type': 'str'},
292 'saas-application': {
293 'v_range': [['7.4.1', '']],
294 'type': 'list',
295 'options': {
296 'access-rule': {
297 'v_range': [['7.4.1', '']],
298 'type': 'list',
299 'options': {
300 'action': {'v_range': [['7.4.1', '']], 'choices': ['block', 'bypass', 'monitor'], 'type': 'str'},
301 'bypass': {
302 'v_range': [['7.4.1', '']],
303 'type': 'list',
304 'choices': ['av', 'dlp', 'web-filter', 'file-filter', 'video-filter'],
305 'elements': 'str'
306 },
307 'name': {'v_range': [['7.4.1', '']], 'type': 'str'},
308 'attribute-filter': {
309 'v_range': [['7.6.2', '']],
310 'type': 'list',
311 'options': {
312 'action': {'v_range': [['7.6.2', '']], 'choices': ['block', 'monitor', 'bypass'], 'type': 'str'},
313 'attribute-match': {'v_range': [['7.6.2', '']], 'type': 'list', 'elements': 'str'},
314 'id': {'v_range': [['7.6.2', '']], 'type': 'int'}
315 },
316 'elements': 'dict'
317 }
318 },
319 'elements': 'dict'
320 },
321 'custom-control': {
322 'v_range': [['7.4.1', '']],
323 'type': 'list',
324 'options': {
325 'name': {'v_range': [['7.4.1', '']], 'type': 'str'},
326 'option': {
327 'v_range': [['7.4.1', '']],
328 'type': 'list',
329 'options': {
330 'name': {'v_range': [['7.4.1', '']], 'type': 'str'},
331 'user-input': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'str'}
332 },
333 'elements': 'dict'
334 },
335 'attribute-filter': {
336 'v_range': [['7.6.2', '']],
337 'type': 'list',
338 'options': {
339 'action': {'v_range': [['7.6.2', '']], 'choices': ['block', 'monitor', 'bypass'], 'type': 'str'},
340 'attribute-match': {'v_range': [['7.6.2', '']], 'type': 'list', 'elements': 'str'},
341 'id': {'v_range': [['7.6.2', '']], 'type': 'int'}
342 },
343 'elements': 'dict'
344 }
345 },
346 'elements': 'dict'
347 },
348 'domain-control': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
349 'domain-control-domains': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'str'},
350 'log': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
351 'name': {'v_range': [['7.4.1', '']], 'type': 'str'},
352 'safe-search': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
353 'safe-search-control': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'str'},
354 'tenant-control': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
355 'tenant-control-tenants': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'str'},
356 'status': {'v_range': [['7.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
357 'advanced-tenant-control': {
358 'v_range': [['7.6.2', '']],
359 'type': 'list',
360 'options': {
361 'attribute': {
362 'v_range': [['7.6.2', '']],
363 'type': 'list',
364 'options': {
365 'input': {'v_range': [['7.6.2', '']], 'type': 'list', 'elements': 'str'},
366 'name': {'v_range': [['7.6.2', '']], 'type': 'str'}
367 },
368 'elements': 'dict'
369 },
370 'name': {'v_range': [['7.6.2', '']], 'type': 'list', 'elements': 'str'}
371 },
372 'elements': 'dict'
373 }
374 },
375 'elements': 'dict'
376 },
377 'comment': {'v_range': [['7.4.3', '']], 'type': 'str'}
378 }
379 }
380 }
381
382 module_option_spec = get_module_arg_spec('full crud')
383 module_arg_spec.update(module_option_spec)
384 check_galaxy_version(module_arg_spec)
385 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'casb_profile'),
386 supports_check_mode=True)
387 if not module._socket_path:
388 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
389 connection = Connection(module._socket_path)
390 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
391 'name', 'data', module, connection)
392 fmgr.process_crud()
393 module.exit_json(meta=module.params)
394
395
396 if __name__ == '__main__':
397 main()