Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_sys_proxy_json.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_sys_proxy_json
15 short_description: Send and receive JSON request to/from managed devices.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 options:
20 sys_proxy_json:
21 description: The top level parameters set.
22 required: false
23 type: dict
24 suboptions:
25 action:
26 type: str
27 description: Specify HTTP action for the request.
28 choices: ['get', 'post', 'put', 'delete']
29 payload:
30 type: dict
31 description: Payload.
32 resource:
33 type: str
34 description: URL on the remote device to be accessed.
35 target:
36 type: list
37 elements: str
38 description: Target.
39 timeout:
40 type: int
41 description: Maximum time in seconds to wait for response from remote device.
42 '''
43
44 EXAMPLES = '''
45 - name: Example playbook (generated based on argument schema)
46 hosts: fortimanagers
47 connection: httpapi
48 gather_facts: false
49 tasks:
50 - name: Send and receive JSON request to/from managed devices.
51 fortinet.fortimanager.fmgr_sys_proxy_json:
52 # workspace_locking_adom: <global or your adom name>
53 sys_proxy_json:
54 # action: <value in [get, post, put, ...]>
55 # payload: <dict>
56 # resource: <string>
57 # target: <list or string>
58 # timeout: <integer>
59 '''
60
61 RETURN = '''
62 meta:
63 description: The result of the request.
64 type: dict
65 returned: always
66 contains:
67 request_url:
68 description: The full url requested.
69 returned: always
70 type: str
71 sample: /sys/login/user
72 response_code:
73 description: The status of api request.
74 returned: always
75 type: int
76 sample: 0
77 response_data:
78 description: The api response.
79 type: list
80 returned: always
81 response_message:
82 description: The descriptive message of the api response.
83 type: str
84 returned: always
85 sample: OK.
86 system_information:
87 description: The information of the target system.
88 type: dict
89 returned: always
90 rc:
91 description: The status the request.
92 type: int
93 returned: always
94 sample: 0
95 version_check_warning:
96 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
97 type: list
98 returned: complex
99 '''
100 from ansible.module_utils.basic import AnsibleModule
101 from ansible.module_utils.connection import Connection
102 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
103 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
104
105
106 def main():
107 urls_list = [
108 '/sys/proxy/json'
109 ]
110 module_arg_spec = {
111 'sys_proxy_json': {
112 'type': 'dict', 'v_range': [['6.0.0', '']],
113 'options': {
114 'action': {'choices': ['get', 'post', 'put', 'delete'], 'type': 'str'},
115 'payload': {'type': 'dict'},
116 'resource': {'type': 'str'},
117 'target': {'type': 'list', 'elements': 'str'},
118 'timeout': {'v_range': [['7.0.1', '']], 'type': 'int'}
119 }
120 }
121 }
122
123 module_option_spec = get_module_arg_spec('exec')
124 module_arg_spec.update(module_option_spec)
125 check_galaxy_version(module_arg_spec)
126 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'sys_proxy_json'),
127 supports_check_mode=True)
128 if not module._socket_path:
129 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
130 connection = Connection(module._socket_path)
131 fmgr = NAPIManager('exec', module_arg_spec, urls_list,
132 None, 'data', module, connection)
133 fmgr.process_exec()
134 module.exit_json(meta=module.params)
135
136
137 if __name__ == '__main__':
138 main()