Debian Codegraph @

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