Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_wanopt_profile_http.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_wanopt_profile_http
15 short_description: Enable/disable HTTP WAN Optimization and configure HTTP WAN Optimization features.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_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 wanopt_profile_http:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 byte_caching:
38 aliases: ['byte-caching']
39 type: str
40 description: Enable/disable byte-caching for HTTP.
41 choices: ['disable', 'enable']
42 log_traffic:
43 aliases: ['log-traffic']
44 type: str
45 description: Enable/disable logging.
46 choices: ['disable', 'enable']
47 port:
48 type: raw
49 description: (list) Single port number or port number range for HTTP.
50 prefer_chunking:
51 aliases: ['prefer-chunking']
52 type: str
53 description: Select dynamic or fixed-size data chunking for HTTP WAN Optimization.
54 choices: ['dynamic', 'fix']
55 secure_tunnel:
56 aliases: ['secure-tunnel']
57 type: str
58 description: Enable/disable securing the WAN Opt tunnel using SSL.
59 choices: ['disable', 'enable']
60 ssl:
61 type: str
62 description: Enable/disable SSL/TLS offloading
63 choices: ['disable', 'enable']
64 ssl_port:
65 aliases: ['ssl-port']
66 type: raw
67 description: (list) Port on which to expect HTTPS traffic for SSL/TLS offloading.
68 status:
69 type: str
70 description: Enable/disable HTTP WAN Optimization.
71 choices: ['disable', 'enable']
72 tunnel_non_http:
73 aliases: ['tunnel-non-http']
74 type: str
75 description: Configure how to process non-HTTP traffic when a profile configured for HTTP traffic accepts a non-HTTP session.
76 choices: ['disable', 'enable']
77 tunnel_sharing:
78 aliases: ['tunnel-sharing']
79 type: str
80 description: Tunnel sharing mode for aggressive/non-aggressive and/or interactive/non-interactive protocols.
81 choices: ['private', 'shared', 'express-shared']
82 unknown_http_version:
83 aliases: ['unknown-http-version']
84 type: str
85 description: How to handle HTTP sessions that do not comply with HTTP 0.
86 choices: ['best-effort', 'reject', 'tunnel']
87 protocol_opt:
88 aliases: ['protocol-opt']
89 type: str
90 description: Select Protocol specific optimitation or generic TCP optimization.
91 choices: ['protocol', 'tcp']
92 '''
93
94 EXAMPLES = '''
95 - name: Example playbook (generated based on argument schema)
96 hosts: fortimanagers
97 connection: httpapi
98 gather_facts: false
99 tasks:
100 - name: Enable/disable HTTP WAN Optimization and configure HTTP WAN Optimization features.
101 fortinet.fortimanager.fmgr_wanopt_profile_http:
102 # workspace_locking_adom: <global or your adom name>
103 adom: <your own value>
104 profile: <your own value>
105 wanopt_profile_http:
106 # byte_caching: <value in [disable, enable]>
107 # log_traffic: <value in [disable, enable]>
108 # port: <list or integer>
109 # prefer_chunking: <value in [dynamic, fix]>
110 # secure_tunnel: <value in [disable, enable]>
111 # ssl: <value in [disable, enable]>
112 # ssl_port: <list or integer>
113 # status: <value in [disable, enable]>
114 # tunnel_non_http: <value in [disable, enable]>
115 # tunnel_sharing: <value in [private, shared, express-shared]>
116 # unknown_http_version: <value in [best-effort, reject, tunnel]>
117 # protocol_opt: <value in [protocol, tcp]>
118 '''
119
120 RETURN = '''
121 meta:
122 description: The result of the request.
123 type: dict
124 returned: always
125 contains:
126 request_url:
127 description: The full url requested.
128 returned: always
129 type: str
130 sample: /sys/login/user
131 response_code:
132 description: The status of api request.
133 returned: always
134 type: int
135 sample: 0
136 response_data:
137 description: The api response.
138 type: list
139 returned: always
140 response_message:
141 description: The descriptive message of the api response.
142 type: str
143 returned: always
144 sample: OK.
145 system_information:
146 description: The information of the target system.
147 type: dict
148 returned: always
149 rc:
150 description: The status the request.
151 type: int
152 returned: always
153 sample: 0
154 version_check_warning:
155 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
156 type: list
157 returned: complex
158 '''
159 from ansible.module_utils.basic import AnsibleModule
160 from ansible.module_utils.connection import Connection
161 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
162 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
163
164
165 def main():
166 urls_list = [
167 '/pm/config/adom/{adom}/obj/wanopt/profile/{profile}/http',
168 '/pm/config/global/obj/wanopt/profile/{profile}/http'
169 ]
170 module_arg_spec = {
171 'adom': {'required': True, 'type': 'str'},
172 'profile': {'required': True, 'type': 'str'},
173 'revision_note': {'type': 'str'},
174 'wanopt_profile_http': {
175 'type': 'dict', 'v_range': [['6.0.0', '']],
176 'options': {
177 'byte-caching': {'choices': ['disable', 'enable'], 'type': 'str'},
178 'log-traffic': {'choices': ['disable', 'enable'], 'type': 'str'},
179 'port': {'v_range': [['6.0.0', '7.6.2']], 'type': 'raw'},
180 'prefer-chunking': {'choices': ['dynamic', 'fix'], 'type': 'str'},
181 'secure-tunnel': {'choices': ['disable', 'enable'], 'type': 'str'},
182 'ssl': {'choices': ['disable', 'enable'], 'type': 'str'},
183 'ssl-port': {'v_range': [['6.0.0', '7.6.2']], 'type': 'raw'},
184 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
185 'tunnel-non-http': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
186 'tunnel-sharing': {'choices': ['private', 'shared', 'express-shared'], 'type': 'str'},
187 'unknown-http-version': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['best-effort', 'reject', 'tunnel'], 'type': 'str'},
188 'protocol-opt': {'v_range': [['6.4.0', '']], 'choices': ['protocol', 'tcp'], 'type': 'str'}
189 }
190 }
191 }
192
193 module_option_spec = get_module_arg_spec('partial crud')
194 module_arg_spec.update(module_option_spec)
195 check_galaxy_version(module_arg_spec)
196 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'wanopt_profile_http'),
197 supports_check_mode=True)
198 if not module._socket_path:
199 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
200 connection = Connection(module._socket_path)
201 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
202 None, 'data', module, connection)
203 fmgr.process_partial_crud()
204 module.exit_json(meta=module.params)
205
206
207 if __name__ == '__main__':
208 main()