Skip to content

Commit c131a77

Browse files
author
Nicolai Buchwitz
committed
Handle empty zones correctly
1 parent 273b6dc commit c131a77

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

nc_dnsapi/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def request(self, action, **kwargs):
8585

8686
if data['status'] == 'success':
8787
return data
88+
# empty dns zone
89+
elif data['statuscode'] == 5029:
90+
return []
8891
else:
8992
raise Exception("{} ({})".format(data['longmessage'], data['statuscode']))
9093
else:
@@ -116,6 +119,9 @@ def update_dns_records(self, domain, records):
116119
"dnsrecordset": {"dnsrecords": [record.__dict__ for record in records]}
117120
})
118121

122+
if 'responsedata' not in data:
123+
return []
124+
119125
return [DNSRecord(**r) for r in data['responsedata']['dnsrecords']]
120126

121127
def dns_record_exists(self, domain, record):
@@ -152,6 +158,10 @@ def delete_dns_records(self, domain, records):
152158

153159
def dns_records(self, domain):
154160
data = self.request("infoDnsRecords", params={"domainname": domain})
161+
162+
if 'responsedata' not in data:
163+
return []
164+
155165
return [DNSRecord(**r) for r in data['responsedata']['dnsrecords']]
156166

157167
def update_dns_zone(self, domain, zone):

0 commit comments

Comments
 (0)