You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.9 KiB
109 lines
2.9 KiB
#!/usr/bin/python
|
|
|
|
# Copyright: ...
|
|
# ...
|
|
|
|
DOCUMENTATION = r'''
|
|
---
|
|
module: decort_account_info
|
|
|
|
version_added: "2.16"
|
|
|
|
description: See L(Module Documentation,https://repository.basistech.ru/BASIS/decort-ansible/wiki/Home).
|
|
'''
|
|
|
|
# EXAMPLES = r'''
|
|
# '''
|
|
|
|
# RETURN = r'''
|
|
# '''
|
|
|
|
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
|
from ansible.module_utils.decort_utils import DecortController
|
|
|
|
|
|
class DecortAccountInfo(DecortController):
|
|
def __init__(self):
|
|
amodule = AnsibleModule(**self.module_args, supports_check_mode=True)
|
|
|
|
super().__init__(amodule)
|
|
|
|
self.id, self.facts = self.account_find(
|
|
account_name=amodule.params['name'],
|
|
account_id=amodule.params['id'],
|
|
resource_consumption=amodule.params['resource_consumption'],
|
|
fail_if_not_found=True
|
|
)
|
|
|
|
@property
|
|
def module_args(self) -> dict:
|
|
return dict(
|
|
argument_spec=dict(
|
|
app_id=dict(
|
|
type='str',
|
|
fallback=(env_fallback, ['DECORT_APP_ID'])
|
|
),
|
|
app_secret=dict(
|
|
type='str',
|
|
fallback=(env_fallback, ['DECORT_APP_SECRET']),
|
|
no_log=True
|
|
),
|
|
authenticator=dict(
|
|
type='str',
|
|
required=True,
|
|
choices=['oauth2', 'jwt']
|
|
),
|
|
controller_url=dict(
|
|
type='str',
|
|
required=True
|
|
),
|
|
id=dict(
|
|
type='int',
|
|
),
|
|
jwt=dict(
|
|
type='str',
|
|
fallback=(env_fallback, ['DECORT_JWT']),
|
|
no_log=True
|
|
),
|
|
name=dict(
|
|
type='str',
|
|
),
|
|
oauth2_url=dict(
|
|
type='str',
|
|
fallback=(env_fallback, ['DECORT_OAUTH2_URL'])
|
|
),
|
|
resource_consumption=dict(
|
|
type='bool',
|
|
default=False
|
|
),
|
|
verify_ssl=dict(
|
|
type='bool',
|
|
default=True
|
|
),
|
|
),
|
|
mutually_exclusive=[
|
|
('id', 'name')
|
|
],
|
|
required_one_of=[
|
|
('id', 'name')
|
|
],
|
|
required_if=[
|
|
('authenticator', 'oauth2',
|
|
('oauth2_url', 'app_id', 'app_secret')),
|
|
('authenticator', 'jwt', ('jwt',))
|
|
]
|
|
)
|
|
|
|
def exit(self):
|
|
self.result['facts'] = self.facts
|
|
self.amodule.exit_json(**self.result)
|
|
|
|
|
|
def main():
|
|
decort_account_info = DecortAccountInfo()
|
|
decort_account_info.exit()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|