mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 12:33:59 -07:00
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.17) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.10) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.12) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.7) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
* Adjust all __future__ imports: for i in $(grep -REl "__future__.*absolute_import" plugins/ tests/); do sed -e 's/from __future__ import .*/from __future__ import annotations/g' -i $i; done * Remove all UTF-8 encoding specifications for Python source files: for i in $(grep -REl '[-][*]- coding: utf-8 -[*]-' plugins/ tests/); do sed -e '/^# -\*- coding: utf-8 -\*-/d' -i $i; done * Remove __metaclass__ = type: for i in $(grep -REl '__metaclass__ = type' plugins/ tests/); do sed -e '/^__metaclass__ = type/d' -i $i; done
76 lines
1.8 KiB
Python
76 lines
1.8 KiB
Python
#!/usr/bin/python
|
|
# Copyright (c) Ansible project
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from __future__ import annotations
|
|
|
|
DOCUMENTATION = r"""
|
|
module: online_user_info
|
|
short_description: Gather information about Online user
|
|
description:
|
|
- Gather information about the user.
|
|
author:
|
|
- "Remy Leone (@remyleone)"
|
|
extends_documentation_fragment:
|
|
- community.general.online
|
|
- community.general.attributes
|
|
- community.general.attributes.info_module
|
|
"""
|
|
|
|
EXAMPLES = r"""
|
|
- name: Gather Online user info
|
|
community.general.online_user_info:
|
|
register: result
|
|
|
|
- ansible.builtin.debug:
|
|
msg: "{{ result.online_user_info }}"
|
|
"""
|
|
|
|
RETURN = r"""
|
|
online_user_info:
|
|
description:
|
|
- Response from Online API.
|
|
- 'For more details please refer to: U(https://console.online.net/en/api/).'
|
|
returned: success
|
|
type: dict
|
|
sample:
|
|
{
|
|
"company": "foobar LLC",
|
|
"email": "foobar@example.com",
|
|
"first_name": "foo",
|
|
"id": 42,
|
|
"last_name": "bar",
|
|
"login": "foobar"
|
|
}
|
|
"""
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
from ansible_collections.community.general.plugins.module_utils.online import (
|
|
Online, OnlineException, online_argument_spec
|
|
)
|
|
|
|
|
|
class OnlineUserInfo(Online):
|
|
|
|
def __init__(self, module):
|
|
super(OnlineUserInfo, self).__init__(module)
|
|
self.name = 'api/v1/user'
|
|
|
|
|
|
def main():
|
|
module = AnsibleModule(
|
|
argument_spec=online_argument_spec(),
|
|
supports_check_mode=True,
|
|
)
|
|
|
|
try:
|
|
module.exit_json(
|
|
online_user_info=OnlineUserInfo(module).get_resources()
|
|
)
|
|
except OnlineException as exc:
|
|
module.fail_json(msg=exc.message)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|