Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_sys_login_user.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_login_user
15 short_description: Log into the device with user name and password.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 options:
20 sys_login_user:
21 description: The top level parameters set.
22 required: false
23 type: dict
24 suboptions:
25 passwd:
26 type: str
27 description: Passwd.
28 user:
29 type: str
30 description: User.
31 '''
32
33 EXAMPLES = '''
34 - name: Example playbook (generated based on argument schema)
35 hosts: fortimanagers
36 connection: httpapi
37 gather_facts: false
38 tasks:
39 - name: Log into the device with user name and password.
40 fortinet.fortimanager.fmgr_sys_login_user:
41 # workspace_locking_adom: <global or your adom name>
42 sys_login_user:
43 # passwd: <string>
44 # user: <string>
45 '''
46
47 RETURN = '''
48 meta:
49 description: The result of the request.
50 type: dict
51 returned: always
52 contains:
53 request_url:
54 description: The full url requested.
55 returned: always
56 type: str
57 sample: /sys/login/user
58 response_code:
59 description: The status of api request.
60 returned: always
61 type: int
62 sample: 0
63 response_data:
64 description: The api response.
65 type: list
66 returned: always
67 response_message:
68 description: The descriptive message of the api response.
69 type: str
70 returned: always
71 sample: OK.
72 system_information:
73 description: The information of the target system.
74 type: dict
75 returned: always
76 rc:
77 description: The status the request.
78 type: int
79 returned: always
80 sample: 0
81 version_check_warning:
82 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
83 type: list
84 returned: complex
85 '''
86 from ansible.module_utils.basic import AnsibleModule
87 from ansible.module_utils.connection import Connection
88 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
89 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
90
91
92 def main():
93 urls_list = [
94 '/sys/login/user'
95 ]
96 module_arg_spec = {
97 'sys_login_user': {
98 'type': 'dict', 'v_range': [['6.0.0', '']],
99 'options': {'passwd': {'no_log': True, 'type': 'str'}, 'user': {'type': 'str'}}
100 }
101 }
102
103 module_option_spec = get_module_arg_spec('exec')
104 module_arg_spec.update(module_option_spec)
105 check_galaxy_version(module_arg_spec)
106 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'sys_login_user'),
107 supports_check_mode=True)
108 if not module._socket_path:
109 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
110 connection = Connection(module._socket_path)
111 fmgr = NAPIManager('exec', module_arg_spec, urls_list,
112 None, 'data', module, connection)
113 fmgr.process_exec()
114 module.exit_json(meta=module.params)
115
116
117 if __name__ == '__main__':
118 main()