From aeded216827ec12700f227a0a23f73ddadb6138d Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 9 Nov 2025 17:19:40 +0000 Subject: [PATCH] [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 0175d75a7c344af4c5970337174f05ff7a0d48d9) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein --- .../11052-dnsimple-info-improves.yml | 2 + plugins/modules/dnsimple_info.py | 46 +++++++++---------- 2 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 changelogs/fragments/11052-dnsimple-info-improves.yml diff --git a/changelogs/fragments/11052-dnsimple-info-improves.yml b/changelogs/fragments/11052-dnsimple-info-improves.yml new file mode 100644 index 0000000000..852a1ee434 --- /dev/null +++ b/changelogs/fragments/11052-dnsimple-info-improves.yml @@ -0,0 +1,2 @@ +minor_changes: + - dnsimple_info - use Ansible construct to validate parameters (https://github.com/ansible-collections/community.general/pull/11052). diff --git a/plugins/modules/dnsimple_info.py b/plugins/modules/dnsimple_info.py index 2fade3dd56..06fca596ec 100644 --- a/plugins/modules/dnsimple_info.py +++ b/plugins/modules/dnsimple_info.py @@ -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__":