mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
[PR #11052/0175d75a backport][stable-12] dnsimple_info: minor improvements (#11068)
dnsimple_info: minor improvements (#11052)
* dnsimple_info: minor improvements
* add changelog frag
* typo
* Update plugins/modules/dnsimple_info.py
---------
(cherry picked from commit 0175d75a7c)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
bb926e462f
commit
aeded21682
2 changed files with 23 additions and 25 deletions
2
changelogs/fragments/11052-dnsimple-info-improves.yml
Normal file
2
changelogs/fragments/11052-dnsimple-info-improves.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- dnsimple_info - use Ansible construct to validate parameters (https://github.com/ansible-collections/community.general/pull/11052).
|
||||
|
|
@ -279,42 +279,38 @@ def account_info(dnsimple_mod, req_obj):
|
|||
|
||||
|
||||
def main():
|
||||
# define available arguments/parameters a user can pass to the module
|
||||
fields = {
|
||||
"account_id": {"required": True, "type": "str"},
|
||||
"api_key": {"required": True, "type": "str", "no_log": True},
|
||||
"name": {"required": False, "type": "str"},
|
||||
"record": {"required": False, "type": "str"},
|
||||
"sandbox": {"required": False, "type": "bool", "default": False},
|
||||
}
|
||||
|
||||
result = {"changed": False}
|
||||
|
||||
module = AnsibleModule(argument_spec=fields, supports_check_mode=True)
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
account_id=dict(required=True, type="str"),
|
||||
api_key=dict(required=True, type="str", no_log=True),
|
||||
name=dict(type="str"),
|
||||
record=dict(type="str"),
|
||||
sandbox=dict(type="bool", default=False),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
params = module.params
|
||||
req = build_url(params["account_id"], params["api_key"], params["sandbox"])
|
||||
|
||||
deps.validate(module)
|
||||
|
||||
# At minimum we need account and key
|
||||
if params["account_id"] and params["api_key"]:
|
||||
# If we have a record return info on that record
|
||||
if params["name"] and params["record"]:
|
||||
result["dnsimple_record_info"] = record_info(module, req)
|
||||
module.exit_json(**result)
|
||||
# If we have a record return info on that record
|
||||
if params["name"] and params["record"]:
|
||||
result["dnsimple_record_info"] = record_info(module, req)
|
||||
module.exit_json(**result)
|
||||
|
||||
# If we have the account only and domain, return records for the domain
|
||||
elif params["name"]:
|
||||
result["dnsimple_records_info"] = domain_info(module, req)
|
||||
module.exit_json(**result)
|
||||
# If we have the account only and domain, return records for the domain
|
||||
elif params["name"]:
|
||||
result["dnsimple_records_info"] = domain_info(module, req)
|
||||
module.exit_json(**result)
|
||||
|
||||
# If we have the account only, return domains
|
||||
else:
|
||||
result["dnsimple_domain_info"] = account_info(module, req)
|
||||
module.exit_json(**result)
|
||||
# If we have the account only, return domains
|
||||
else:
|
||||
module.fail_json(msg="Need at least account_id and api_key")
|
||||
result["dnsimple_domain_info"] = account_info(module, req)
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue