Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2018, Yanis Guenane <[email protected]>
4 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7 from __future__ import annotations
8
9 DOCUMENTATION = r"""
10 module: scaleway_organization_info
11 short_description: Gather information about the Scaleway organizations available
12 description:
13 - Gather information about the Scaleway organizations available.
14 author:
15 - "Yanis Guenane (@Spredzy)"
16 - "Remy Leone (@remyleone)"
17
18 attributes:
19 action_group:
20 version_added: 11.3.0
21
22 options:
23 api_url:
24 description:
25 - Scaleway API URL.
26 default: 'https://account.scaleway.com'
27 aliases: ['base_url']
28 extends_documentation_fragment:
29 - community.general._scaleway
30 - community.general._attributes
31 - community.general._scaleway.actiongroup_scaleway
32 - community.general._attributes.info_module
33 """
34
35 EXAMPLES = r"""
36 - name: Gather Scaleway organizations information
37 community.general.scaleway_organization_info:
38 register: result
39
40 - ansible.builtin.debug:
41 msg: "{{ result.scaleway_organization_info }}"
42 """
43
44 RETURN = r"""
45 scaleway_organization_info:
46 description: Response from Scaleway API.
47 returned: success
48 type: list
49 elements: dict
50 sample:
51 [
52 {
53 "address_city_name": "Paris",
54 "address_country_code": "FR",
55 "address_line1": "42 Rue de l'univers",
56 "address_line2": null,
57 "address_postal_code": "75042",
58 "address_subdivision_code": "FR-75",
59 "creation_date": "2018-08-06T13:43:28.508575+00:00",
60 "currency": "EUR",
61 "customer_class": "individual",
62 "id": "3f709602-5e6c-4619-b80c-e8432ferewtr",
63 "locale": "fr_FR",
64 "modification_date": "2018-08-06T14:56:41.401685+00:00",
65 "name": "James Bond",
66 "support_id": "694324",
67 "support_level": "basic",
68 "support_pin": "9324",
69 "users": [],
70 "vat_number": null,
71 "warnings": []
72 }
73 ]
74 """
75
76 from ansible.module_utils.basic import AnsibleModule, env_fallback
77
78 from ansible_collections.community.general.plugins.module_utils._scaleway import (
79 Scaleway,
80 ScalewayException,
81 scaleway_argument_spec,
82 )
83
84
85 class ScalewayOrganizationInfo(Scaleway):
86 def __init__(self, module):
87 super().__init__(module)
88 self.name = "organizations"
89
90
91 def main():
92 argument_spec = scaleway_argument_spec()
93 argument_spec.update(
94 dict(
95 api_url=dict(
96 fallback=(env_fallback, ["SCW_API_URL"]), default="https://account.scaleway.com", aliases=["base_url"]
97 ),
98 )
99 )
100
101 module = AnsibleModule(
102 argument_spec=argument_spec,
103 supports_check_mode=True,
104 )
105
106 try:
107 module.exit_json(scaleway_organization_info=ScalewayOrganizationInfo(module).get_resources())
108 except ScalewayException as exc:
109 module.fail_json(msg=exc.message)
110
111
112 if __name__ == "__main__":
113 main()