Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_proxyaddress.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_firewall_proxyaddress
15 short_description: Web proxy address configuration.
16 version_added: "2.0.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 firewall_proxyaddress:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 case_sensitivity:
34 aliases: ['case-sensitivity']
35 type: str
36 description: Enable to make the pattern case sensitive.
37 choices: ['disable', 'enable']
38 category:
39 type: raw
40 description: (list or str) FortiGuard category ID.
41 color:
42 type: int
43 description: Integer value to determine the color of the icon in the GUI
44 comment:
45 type: str
46 description: Optional comments.
47 header:
48 type: str
49 description: HTTP header name as a regular expression.
50 header_group:
51 aliases: ['header-group']
52 type: list
53 elements: dict
54 description: Header group.
55 suboptions:
56 case_sensitivity:
57 aliases: ['case-sensitivity']
58 type: str
59 description: Case sensitivity in pattern.
60 choices: ['disable', 'enable']
61 header:
62 type: str
63 description: HTTP header regular expression.
64 header_name:
65 aliases: ['header-name']
66 type: str
67 description: HTTP header.
68 id:
69 type: int
70 description: ID.
71 header_name:
72 aliases: ['header-name']
73 type: str
74 description: Name of HTTP header.
75 host:
76 type: str
77 description: Address object for the host.
78 host_regex:
79 aliases: ['host-regex']
80 type: str
81 description: Host name as a regular expression.
82 method:
83 type: list
84 elements: str
85 description: HTTP request methods to be used.
86 choices: ['delete', 'get', 'head', 'options', 'post', 'put', 'trace', 'connect',
87 'other', 'patch', 'update']
88 name:
89 type: str
90 description: Address name.
91 required: true
92 path:
93 type: str
94 description: URL path as a regular expression.
95 query:
96 type: str
97 description: Match the query part of the URL as a regular expression.
98 referrer:
99 type: str
100 description: Enable/disable use of referrer field in the HTTP header to match the address.
101 choices: ['disable', 'enable']
102 tagging:
103 type: list
104 elements: dict
105 description: Tagging.
106 suboptions:
107 category:
108 type: str
109 description: Tag category.
110 name:
111 type: str
112 description: Tagging entry name.
113 tags:
114 type: raw
115 description: (list) Tags.
116 type:
117 type: str
118 description: Proxy address type.
119 choices: ['host-regex', 'url', 'category', 'method', 'ua', 'header',
120 'src-advanced', 'dst-advanced', 'url-list', 'saas', 'response-header',
121 'llm-server']
122 ua:
123 type: list
124 elements: str
125 description: Names of browsers to be used as user agent.
126 choices: ['chrome', 'ms', 'firefox', 'safari', 'other', 'ie', 'edge']
127 uuid:
128 type: str
129 description: Universally Unique Identifier
130 visibility:
131 type: str
132 description: Enable/disable visibility of the object in the GUI.
133 choices: ['disable', 'enable']
134 tags:
135 type: str
136 description: Names of object-tags
137 _image_base64:
138 aliases: ['_image-base64']
139 type: str
140 description: Image base64.
141 application:
142 type: raw
143 description: (list) SaaS application.
144 ua_max_ver:
145 aliases: ['ua-max-ver']
146 type: str
147 description: Maximum version of the user agent specified in dotted notation.
148 ua_min_ver:
149 aliases: ['ua-min-ver']
150 type: str
151 description: Minimum version of the user agent specified in dotted notation.
152 post_arg:
153 aliases: ['post-arg']
154 type: str
155 description: Post arg.
156 choices: ['disable', 'enable']
157 url_list:
158 aliases: ['url-list']
159 type: raw
160 description: (list) Url list.
161 llm_servers:
162 aliases: ['llm-servers']
163 type: raw
164 description: (list) Llm servers.
165 '''
166
167 EXAMPLES = '''
168 - name: Example playbook
169 hosts: fortimanagers
170 gather_facts: false
171 connection: httpapi
172 vars:
173 ansible_httpapi_use_ssl: true
174 ansible_httpapi_validate_certs: false
175 ansible_httpapi_port: 443
176 tasks:
177 - name: Web proxy address configuration.
178 fortinet.fortimanager.fmgr_firewall_proxyaddress:
179 bypass_validation: false
180 adom: ansible
181 state: present
182 firewall_proxyaddress:
183 case_sensitivity: disable
184 color: 1
185 comment: "ansible-comment"
186 name: "ansible-test"
187
188 - name: Gathering fortimanager facts
189 hosts: fortimanagers
190 gather_facts: false
191 connection: httpapi
192 vars:
193 ansible_httpapi_use_ssl: true
194 ansible_httpapi_validate_certs: false
195 ansible_httpapi_port: 443
196 tasks:
197 - name: Retrieve all the proxy addresses
198 fortinet.fortimanager.fmgr_fact:
199 facts:
200 selector: "firewall_proxyaddress"
201 params:
202 adom: "ansible"
203 proxy_address: "your_value"
204 '''
205
206 RETURN = '''
207 meta:
208 description: The result of the request.
209 type: dict
210 returned: always
211 contains:
212 request_url:
213 description: The full url requested.
214 returned: always
215 type: str
216 sample: /sys/login/user
217 response_code:
218 description: The status of api request.
219 returned: always
220 type: int
221 sample: 0
222 response_data:
223 description: The api response.
224 type: list
225 returned: always
226 response_message:
227 description: The descriptive message of the api response.
228 type: str
229 returned: always
230 sample: OK.
231 system_information:
232 description: The information of the target system.
233 type: dict
234 returned: always
235 rc:
236 description: The status the request.
237 type: int
238 returned: always
239 sample: 0
240 version_check_warning:
241 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
242 type: list
243 returned: complex
244 '''
245 from ansible.module_utils.basic import AnsibleModule
246 from ansible.module_utils.connection import Connection
247 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
248 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
249
250
251 def main():
252 urls_list = [
253 '/pm/config/adom/{adom}/obj/firewall/proxy-address',
254 '/pm/config/global/obj/firewall/proxy-address'
255 ]
256 module_arg_spec = {
257 'adom': {'required': True, 'type': 'str'},
258 'revision_note': {'type': 'str'},
259 'firewall_proxyaddress': {
260 'type': 'dict', 'v_range': [['6.0.0', '']],
261 'options': {
262 'case-sensitivity': {'choices': ['disable', 'enable'], 'type': 'str'},
263 'category': {'type': 'raw'},
264 'color': {'type': 'int'},
265 'comment': {'type': 'str'},
266 'header': {'type': 'str'},
267 'header-group': {
268 'type': 'list',
269 'options': {
270 'case-sensitivity': {'choices': ['disable', 'enable'], 'type': 'str'},
271 'header': {'type': 'str'},
272 'header-name': {'type': 'str'},
273 'id': {'type': 'int'}
274 },
275 'elements': 'dict'
276 },
277 'header-name': {'type': 'str'},
278 'host': {'type': 'str'},
279 'host-regex': {'type': 'str'},
280 'method': {
281 'type': 'list',
282 'choices': ['delete', 'get', 'head', 'options', 'post', 'put', 'trace', 'connect', 'other', 'patch', 'update'],
283 'elements': 'str'
284 },
285 'name': {'required': True, 'type': 'str'},
286 'path': {'type': 'str'},
287 'query': {'type': 'str'},
288 'referrer': {'choices': ['disable', 'enable'], 'type': 'str'},
289 'tagging': {
290 'type': 'list',
291 'options': {'category': {'type': 'str'}, 'name': {'type': 'str'}, 'tags': {'type': 'raw'}},
292 'elements': 'dict'
293 },
294 'type': {
295 'choices': [
296 'host-regex', 'url', 'category', 'method', 'ua', 'header', 'src-advanced', 'dst-advanced', 'url-list', 'saas', 'response-header',
297 'llm-server'
298 ],
299 'type': 'str'
300 },
301 'ua': {'type': 'list', 'choices': ['chrome', 'ms', 'firefox', 'safari', 'other', 'ie', 'edge'], 'elements': 'str'},
302 'uuid': {'type': 'str'},
303 'visibility': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
304 'tags': {'v_range': [['6.2.0', '6.4.15'], ['7.4.8', '7.4.10']], 'type': 'str'},
305 '_image-base64': {'v_range': [['6.2.2', '']], 'type': 'str'},
306 'application': {'v_range': [['7.2.1', '']], 'type': 'raw'},
307 'ua-max-ver': {'v_range': [['7.2.2', '']], 'type': 'str'},
308 'ua-min-ver': {'v_range': [['7.2.2', '']], 'type': 'str'},
309 'post-arg': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
310 'url-list': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'raw'},
311 'llm-servers': {'v_range': [['7.6.5', '']], 'type': 'raw'}
312 }
313 }
314 }
315
316 module_option_spec = get_module_arg_spec('full crud')
317 module_arg_spec.update(module_option_spec)
318 check_galaxy_version(module_arg_spec)
319 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_proxyaddress'),
320 supports_check_mode=True)
321 if not module._socket_path:
322 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
323 connection = Connection(module._socket_path)
324 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
325 'name', 'data', module, connection)
326 fmgr.process_crud()
327 module.exit_json(meta=module.params)
328
329
330 if __name__ == '__main__':
331 main()