Debian Codegraph @

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