Fix formatting inconsistencies in dns.py

This commit is contained in:
2025-12-28 18:14:58 +01:00
parent 1b2bb83eeb
commit c5d6916fa6

View File

@@ -7,14 +7,14 @@ def list_records(record_type: str = None):
f"https://{MIAB_HOST}/admin/dns/custom",
headers={"Authorization": MIAB_AUTH_HEADER}
)
if response.status_code == 200:
records = response.json()
if record_type:
jmespath_expr = f"[?rtype=='{record_type.upper()}']"
else:
jmespath_expr = "[]"
return jmespath.search(jmespath_expr + ".{name: qname, type: rtype, value: value}", records)
else:
raise Exception(f"Failed to retrieve DNS records: {response.status_code} {response.text}")
@@ -45,4 +45,4 @@ def delete_record(name: str, type: str):
if response.status_code == 200:
return response.text
else:
raise Exception(f"Failed to delete DNS record: {response.status_code} {response.text}")
raise Exception(f"Failed to delete DNS record: {response.status_code} {response.text}")