Debian Codegraph @

ansible_collections/community/general/plugins/modules/online_user_info.py

raw
1 #!/usr/bin/python
2 # Copyright (c) Ansible project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 from __future__ import annotations
7
8 DOCUMENTATION = r"""
9 module: online_user_info
10 short_description: Gather information about Online user
11 description:
12 - Gather information about the user.
13 author:
14 - "Remy Leone (@remyleone)"
15 extends_documentation_fragment:
16 - community.general._online
17 - community.general._attributes
18 - community.general._attributes.info_module
19 """
20
21 EXAMPLES = r"""
22 - name: Gather Online user info
23 community.general.online_user_info:
24 register: result
25
26 - ansible.builtin.debug:
27 msg: "{{ result.online_user_info }}"
28 """
29
30 RETURN = r"""
31 online_user_info:
32 description:
33 - Response from Online API.
34 - 'For more details please refer to: U(https://console.online.net/en/api/).'
35 returned: success
36 type: dict
37 sample:
38 {
39 "company": "foobar LLC",
40 "email": "[email protected]",
41 "first_name": "foo",
42 "id": 42,
43 "last_name": "bar",
44 "login": "foobar"
45 }
46 """
47
48 from ansible.module_utils.basic import AnsibleModule
49
50 from ansible_collections.community.general.plugins.module_utils._online import (
51 Online,
52 OnlineException,
53 online_argument_spec,
54 )
55
56
57 class OnlineUserInfo(Online):
58 def __init__(self, module):
59 super().__init__(module)
60 self.name = "api/v1/user"
61
62
63 def main():
64 module = AnsibleModule(
65 argument_spec=online_argument_spec(),
66 supports_check_mode=True,
67 )
68
69 try:
70 module.exit_json(online_user_info=OnlineUserInfo(module).get_resources())
71 except OnlineException as exc:
72 module.fail_json(msg=exc.message)
73
74
75 if __name__ == "__main__":
76 main()