2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
2022-08-08 14:24:58 +02:00
|
|
|
# Copyright (c) Ansible project
|
2022-08-05 12:28:29 +02:00
|
|
|
# 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
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
module: online_user_info
|
|
|
|
short_description: Gather information about Online user.
|
|
|
|
description:
|
|
|
|
- Gather information about the user.
|
|
|
|
author:
|
2021-12-08 18:32:26 +01:00
|
|
|
- "Remy Leone (@remyleone)"
|
2020-03-09 10:11:07 +01:00
|
|
|
extends_documentation_fragment:
|
2022-11-06 21:16:43 +01:00
|
|
|
- community.general.online
|
|
|
|
- community.general.attributes
|
|
|
|
- community.general.attributes.info_module
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
|
|
|
- name: Gather Online user info
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.online_user_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
register: result
|
|
|
|
|
2020-07-14 17:28:08 +02:00
|
|
|
- ansible.builtin.debug:
|
2020-03-09 10:11:07 +01:00
|
|
|
msg: "{{ result.online_user_info }}"
|
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = r'''
|
|
|
|
online_user_info:
|
2021-05-29 16:48:59 +02:00
|
|
|
description:
|
|
|
|
- Response from Online API.
|
|
|
|
- "For more details please refer to: U(https://console.online.net/en/api/)."
|
2020-03-09 10:11:07 +01:00
|
|
|
returned: success
|
2021-05-29 16:48:59 +02:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
sample:
|
|
|
|
"online_user_info": {
|
|
|
|
"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()
|