Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_nsx.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_user_nsx
15 short_description: User nsx
16 version_added: "2.1.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 user_nsx:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 fmgip:
34 type: str
35 description: Fmgip.
36 fmguser:
37 type: str
38 description: Fmguser.
39 name:
40 type: str
41 description: Name.
42 required: true
43 password:
44 type: raw
45 description: (list) Password.
46 server:
47 type: str
48 description: Server.
49 status:
50 type: str
51 description: Status.
52 choices: ['disable', 'enable']
53 user:
54 type: str
55 description: User.
56 fmgpasswd:
57 type: raw
58 description: (list) Fmgpasswd.
59 service_id:
60 aliases: ['service-id']
61 type: raw
62 description: (list) Service id.
63 if_allgroup:
64 aliases: ['if-allgroup']
65 type: str
66 description: If allgroup.
67 choices: ['disable', 'enable']
68 service:
69 type: list
70 elements: dict
71 description: Service.
72 suboptions:
73 id:
74 type: str
75 description: Id.
76 integration:
77 type: str
78 description: Integration.
79 choices: ['east-west', 'north-south']
80 name:
81 type: str
82 description: Name.
83 ref_id:
84 aliases: ['ref-id']
85 type: str
86 description: Ref id.
87 service_manager_id:
88 aliases: ['service-manager-id']
89 type: str
90 description: Service manager id.
91 service_manager_rev:
92 aliases: ['service-manager-rev']
93 type: int
94 description: Service manager rev.
95 '''
96
97 EXAMPLES = '''
98 - name: Example playbook (generated based on argument schema)
99 hosts: fortimanagers
100 connection: httpapi
101 gather_facts: false
102 tasks:
103 - name: User nsx
104 fortinet.fortimanager.fmgr_user_nsx:
105 # workspace_locking_adom: <global or your adom name>
106 adom: <your own value>
107 state: present # <value in [present, absent]>
108 user_nsx:
109 name: "your value" # Required variable, string
110 # fmgip: <string>
111 # fmguser: <string>
112 # password: <list or string>
113 # server: <string>
114 # status: <value in [disable, enable]>
115 # user: <string>
116 # fmgpasswd: <list or string>
117 # service_id: <list or string>
118 # if_allgroup: <value in [disable, enable]>
119 # service:
120 # - id: <string>
121 # integration: <value in [east-west, north-south]>
122 # name: <string>
123 # ref_id: <string>
124 # service_manager_id: <string>
125 # service_manager_rev: <integer>
126 '''
127
128 RETURN = '''
129 meta:
130 description: The result of the request.
131 type: dict
132 returned: always
133 contains:
134 request_url:
135 description: The full url requested.
136 returned: always
137 type: str
138 sample: /sys/login/user
139 response_code:
140 description: The status of api request.
141 returned: always
142 type: int
143 sample: 0
144 response_data:
145 description: The api response.
146 type: list
147 returned: always
148 response_message:
149 description: The descriptive message of the api response.
150 type: str
151 returned: always
152 sample: OK.
153 system_information:
154 description: The information of the target system.
155 type: dict
156 returned: always
157 rc:
158 description: The status the request.
159 type: int
160 returned: always
161 sample: 0
162 version_check_warning:
163 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
164 type: list
165 returned: complex
166 '''
167 from ansible.module_utils.basic import AnsibleModule
168 from ansible.module_utils.connection import Connection
169 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
170 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
171
172
173 def main():
174 urls_list = [
175 '/pm/config/adom/{adom}/obj/user/nsx',
176 '/pm/config/global/obj/user/nsx'
177 ]
178 module_arg_spec = {
179 'adom': {'required': True, 'type': 'str'},
180 'revision_note': {'type': 'str'},
181 'user_nsx': {
182 'type': 'dict', 'v_range': [['6.2.1', '']],
183 'options': {
184 'fmgip': {'v_range': [['6.2.1', '']], 'type': 'str'},
185 'fmguser': {'v_range': [['6.2.1', '']], 'type': 'str'},
186 'name': {'v_range': [['6.2.1', '']], 'required': True, 'type': 'str'},
187 'password': {'v_range': [['6.2.1', '']], 'no_log': True, 'type': 'raw'},
188 'server': {'v_range': [['6.2.1', '']], 'type': 'str'},
189 'status': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
190 'user': {'v_range': [['6.2.1', '']], 'type': 'str'},
191 'fmgpasswd': {'v_range': [['6.2.2', '']], 'no_log': True, 'type': 'raw'},
192 'service-id': {'v_range': [['6.2.2', '']], 'type': 'raw'},
193 'if-allgroup': {'v_range': [['7.0.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
194 'service': {
195 'v_range': [['7.0.4', '']],
196 'type': 'list',
197 'options': {
198 'id': {'v_range': [['7.0.4', '']], 'type': 'str'},
199 'integration': {'v_range': [['7.0.4', '']], 'choices': ['east-west', 'north-south'], 'type': 'str'},
200 'name': {'v_range': [['7.0.4', '']], 'type': 'str'},
201 'ref-id': {'v_range': [['7.0.4', '']], 'type': 'str'}
202 },
203 'elements': 'dict'
204 },
205 'service-manager-id': {'v_range': [['7.0.4', '']], 'type': 'str'},
206 'service-manager-rev': {'v_range': [['7.0.4', '7.0.16'], ['7.2.1', '']], 'type': 'int'}
207 }
208 }
209 }
210
211 module_option_spec = get_module_arg_spec('full crud')
212 module_arg_spec.update(module_option_spec)
213 check_galaxy_version(module_arg_spec)
214 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_nsx'),
215 supports_check_mode=True)
216 if not module._socket_path:
217 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
218 connection = Connection(module._socket_path)
219 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
220 'name', 'data', module, connection)
221 fmgr.process_crud()
222 module.exit_json(meta=module.params)
223
224
225 if __name__ == '__main__':
226 main()