Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_vcenter.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_vcenter
15 short_description: User vcenter
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_vcenter:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 name:
34 type: str
35 description: Name.
36 required: true
37 password:
38 type: raw
39 description: (list) Password.
40 rule:
41 type: list
42 elements: dict
43 description: Rule.
44 suboptions:
45 name:
46 type: str
47 description: Name.
48 rule:
49 type: str
50 description: Rule.
51 server:
52 type: str
53 description: Server.
54 status:
55 type: str
56 description: Status.
57 choices: ['disable', 'enable']
58 upd_interval:
59 type: int
60 description: Upd interval.
61 user:
62 type: str
63 description: User.
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: User vcenter
73 fortinet.fortimanager.fmgr_user_vcenter:
74 # workspace_locking_adom: <global or your adom name>
75 adom: <your own value>
76 state: present # <value in [present, absent]>
77 user_vcenter:
78 name: "your value" # Required variable, string
79 # password: <list or string>
80 # rule:
81 # - name: <string>
82 # rule: <string>
83 # server: <string>
84 # status: <value in [disable, enable]>
85 # upd_interval: <integer>
86 # user: <string>
87 '''
88
89 RETURN = '''
90 meta:
91 description: The result of the request.
92 type: dict
93 returned: always
94 contains:
95 request_url:
96 description: The full url requested.
97 returned: always
98 type: str
99 sample: /sys/login/user
100 response_code:
101 description: The status of api request.
102 returned: always
103 type: int
104 sample: 0
105 response_data:
106 description: The api response.
107 type: list
108 returned: always
109 response_message:
110 description: The descriptive message of the api response.
111 type: str
112 returned: always
113 sample: OK.
114 system_information:
115 description: The information of the target system.
116 type: dict
117 returned: always
118 rc:
119 description: The status the request.
120 type: int
121 returned: always
122 sample: 0
123 version_check_warning:
124 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
125 type: list
126 returned: complex
127 '''
128 from ansible.module_utils.basic import AnsibleModule
129 from ansible.module_utils.connection import Connection
130 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
131 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
132
133
134 def main():
135 urls_list = [
136 '/pm/config/adom/{adom}/obj/user/vcenter',
137 '/pm/config/global/obj/user/vcenter'
138 ]
139 module_arg_spec = {
140 'adom': {'required': True, 'type': 'str'},
141 'revision_note': {'type': 'str'},
142 'user_vcenter': {
143 'type': 'dict', 'v_range': [['6.4.0', '']],
144 'options': {
145 'name': {'v_range': [['6.4.0', '']], 'required': True, 'type': 'str'},
146 'password': {'v_range': [['6.4.0', '']], 'no_log': True, 'type': 'raw'},
147 'rule': {
148 'v_range': [['6.4.0', '']],
149 'type': 'list',
150 'options': {'name': {'v_range': [['6.4.0', '']], 'type': 'str'}, 'rule': {'v_range': [['6.4.0', '']], 'type': 'str'}},
151 'elements': 'dict'
152 },
153 'server': {'v_range': [['6.4.0', '']], 'type': 'str'},
154 'status': {'v_range': [['6.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
155 'upd_interval': {'v_range': [['6.4.0', '']], 'type': 'int'},
156 'user': {'v_range': [['6.4.0', '']], 'type': 'str'}
157 }
158 }
159 }
160
161 module_option_spec = get_module_arg_spec('full crud')
162 module_arg_spec.update(module_option_spec)
163 check_galaxy_version(module_arg_spec)
164 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_vcenter'),
165 supports_check_mode=True)
166 if not module._socket_path:
167 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
168 connection = Connection(module._socket_path)
169 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
170 'name', 'data', module, connection)
171 fmgr.process_crud()
172 module.exit_json(meta=module.params)
173
174
175 if __name__ == '__main__':
176 main()