Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_wanopt_profile_tcp.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_tcp
15 short_description: Enable/disable TCP WAN Optimization and configure TCP 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_tcp:
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 byte_caching_opt:
43 aliases: ['byte-caching-opt']
44 type: str
45 description: Select whether TCP byte-caching uses system memory only or both memory and disk space.
46 choices: ['mem-only', 'mem-disk']
47 log_traffic:
48 aliases: ['log-traffic']
49 type: str
50 description: Enable/disable logging.
51 choices: ['disable', 'enable']
52 port:
53 type: str
54 description: Single port number or port number range for TCP.
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_sharing:
73 aliases: ['tunnel-sharing']
74 type: str
75 description: Tunnel sharing mode for aggressive/non-aggressive and/or interactive/non-interactive protocols.
76 choices: ['private', 'shared', 'express-shared']
77 '''
78
79 EXAMPLES = '''
80 - name: Example playbook (generated based on argument schema)
81 hosts: fortimanagers
82 connection: httpapi
83 gather_facts: false
84 tasks:
85 - name: Enable/disable TCP WAN Optimization and configure TCP WAN Optimization features.
86 fortinet.fortimanager.fmgr_wanopt_profile_tcp:
87 # workspace_locking_adom: <global or your adom name>
88 adom: <your own value>
89 profile: <your own value>
90 wanopt_profile_tcp:
91 # byte_caching: <value in [disable, enable]>
92 # byte_caching_opt: <value in [mem-only, mem-disk]>
93 # log_traffic: <value in [disable, enable]>
94 # port: <string>
95 # secure_tunnel: <value in [disable, enable]>
96 # ssl: <value in [disable, enable]>
97 # ssl_port: <list or integer>
98 # status: <value in [disable, enable]>
99 # tunnel_sharing: <value in [private, shared, express-shared]>
100 '''
101
102 RETURN = '''
103 meta:
104 description: The result of the request.
105 type: dict
106 returned: always
107 contains:
108 request_url:
109 description: The full url requested.
110 returned: always
111 type: str
112 sample: /sys/login/user
113 response_code:
114 description: The status of api request.
115 returned: always
116 type: int
117 sample: 0
118 response_data:
119 description: The api response.
120 type: list
121 returned: always
122 response_message:
123 description: The descriptive message of the api response.
124 type: str
125 returned: always
126 sample: OK.
127 system_information:
128 description: The information of the target system.
129 type: dict
130 returned: always
131 rc:
132 description: The status the request.
133 type: int
134 returned: always
135 sample: 0
136 version_check_warning:
137 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
138 type: list
139 returned: complex
140 '''
141 from ansible.module_utils.basic import AnsibleModule
142 from ansible.module_utils.connection import Connection
143 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
144 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
145
146
147 def main():
148 urls_list = [
149 '/pm/config/adom/{adom}/obj/wanopt/profile/{profile}/tcp',
150 '/pm/config/global/obj/wanopt/profile/{profile}/tcp'
151 ]
152 module_arg_spec = {
153 'adom': {'required': True, 'type': 'str'},
154 'profile': {'required': True, 'type': 'str'},
155 'revision_note': {'type': 'str'},
156 'wanopt_profile_tcp': {
157 'type': 'dict', 'v_range': [['6.0.0', '']],
158 'options': {
159 'byte-caching': {'choices': ['disable', 'enable'], 'type': 'str'},
160 'byte-caching-opt': {'choices': ['mem-only', 'mem-disk'], 'type': 'str'},
161 'log-traffic': {'choices': ['disable', 'enable'], 'type': 'str'},
162 'port': {'type': 'str'},
163 'secure-tunnel': {'choices': ['disable', 'enable'], 'type': 'str'},
164 'ssl': {'choices': ['disable', 'enable'], 'type': 'str'},
165 'ssl-port': {'type': 'raw'},
166 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
167 'tunnel-sharing': {'choices': ['private', 'shared', 'express-shared'], 'type': 'str'}
168 }
169 }
170 }
171
172 module_option_spec = get_module_arg_spec('partial crud')
173 module_arg_spec.update(module_option_spec)
174 check_galaxy_version(module_arg_spec)
175 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'wanopt_profile_tcp'),
176 supports_check_mode=True)
177 if not module._socket_path:
178 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
179 connection = Connection(module._socket_path)
180 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
181 None, 'data', module, connection)
182 fmgr.process_partial_crud()
183 module.exit_json(meta=module.params)
184
185
186 if __name__ == '__main__':
187 main()