Debian Codegraph @

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