Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_sdnproxy.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_system_sdnproxy
15 short_description: Configure SDN proxy.
16 version_added: "2.3.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_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 system_sdnproxy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 name:
34 type: str
35 description: SDN proxy name.
36 required: true
37 password:
38 type: list
39 elements: str
40 description: SDN proxy password.
41 server:
42 type: str
43 description: Server address of the SDN proxy.
44 server_port:
45 aliases: ['server-port']
46 type: int
47 description: Port number of the SDN proxy.
48 type:
49 type: str
50 description: Type of SDN proxy.
51 choices: ['general', 'fortimanager']
52 username:
53 type: str
54 description: SDN proxy username.
55 '''
56
57 EXAMPLES = '''
58 - name: Example playbook (generated based on argument schema)
59 hosts: fortimanagers
60 connection: httpapi
61 gather_facts: false
62 tasks:
63 - name: Configure SDN proxy.
64 fortinet.fortimanager.fmgr_system_sdnproxy:
65 # workspace_locking_adom: <global or your adom name>
66 adom: <your own value>
67 state: present # <value in [present, absent]>
68 system_sdnproxy:
69 name: "your value" # Required variable, string
70 # password: <list or string>
71 # server: <string>
72 # server_port: <integer>
73 # type: <value in [general, fortimanager]>
74 # username: <string>
75 '''
76
77 RETURN = '''
78 meta:
79 description: The result of the request.
80 type: dict
81 returned: always
82 contains:
83 request_url:
84 description: The full url requested.
85 returned: always
86 type: str
87 sample: /sys/login/user
88 response_code:
89 description: The status of api request.
90 returned: always
91 type: int
92 sample: 0
93 response_data:
94 description: The api response.
95 type: list
96 returned: always
97 response_message:
98 description: The descriptive message of the api response.
99 type: str
100 returned: always
101 sample: OK.
102 system_information:
103 description: The information of the target system.
104 type: dict
105 returned: always
106 rc:
107 description: The status the request.
108 type: int
109 returned: always
110 sample: 0
111 version_check_warning:
112 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
113 type: list
114 returned: complex
115 '''
116 from ansible.module_utils.basic import AnsibleModule
117 from ansible.module_utils.connection import Connection
118 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
119 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
120
121
122 def main():
123 urls_list = [
124 '/pm/config/adom/{adom}/obj/system/sdn-proxy',
125 '/pm/config/global/obj/system/sdn-proxy'
126 ]
127 module_arg_spec = {
128 'adom': {'required': True, 'type': 'str'},
129 'revision_note': {'type': 'str'},
130 'system_sdnproxy': {
131 'type': 'dict', 'v_range': [['7.4.1', '']],
132 'options': {
133 'name': {'v_range': [['7.4.1', '']], 'required': True, 'type': 'str'},
134 'password': {'v_range': [['7.4.1', '']], 'no_log': True, 'type': 'list', 'elements': 'str'},
135 'server': {'v_range': [['7.4.1', '']], 'type': 'str'},
136 'server-port': {'v_range': [['7.4.1', '']], 'type': 'int'},
137 'type': {'v_range': [['7.4.1', '']], 'choices': ['general', 'fortimanager'], 'type': 'str'},
138 'username': {'v_range': [['7.4.1', '']], 'type': 'str'}
139 }
140 }
141 }
142
143 module_option_spec = get_module_arg_spec('full crud')
144 module_arg_spec.update(module_option_spec)
145 check_galaxy_version(module_arg_spec)
146 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_sdnproxy'),
147 supports_check_mode=True)
148 if not module._socket_path:
149 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
150 connection = Connection(module._socket_path)
151 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
152 'name', 'data', module, connection)
153 fmgr.process_crud()
154 module.exit_json(meta=module.params)
155
156
157 if __name__ == '__main__':
158 main()