1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

dnsimple_info: minor improvements (#11052)

* dnsimple_info: minor improvements

* add changelog frag

* typo

* Update plugins/modules/dnsimple_info.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2025-11-10 06:02:29 +13:00 committed by GitHub
parent 5ea1dee3ea
commit 0175d75a7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 25 deletions

View file

@ -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__":