Skip to content

Commit

Permalink
Changed snapshot "uuid" to "id" to reflect the latest API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Danamir committed May 22, 2021
1 parent 240e223 commit e138537
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions dyn_gandi.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,33 @@ def livedns_handle(domain, ip, records):
if r_snap is None:
raise RuntimeWarning("Could not create snapshot." % domain)

snapshot_uuid = r_snap['id']
snapshot_id = r_snap['id']

if verbose:
print("Backup snapshot created, uuid: %s." % snapshot_uuid)
print("Backup snapshot created, id: %s." % snapshot_id)

# update DNS records
for rec in records:
try:
r_update = ldns.put_domain_record(domain=domain, record_name=rec['name'], record_type=rec['type'], value=ip, ttl=int(config['dns']['ttl']))
except Exception as e:
print(
"%s, Error: %s. Backup snapshot uuid: %s."
% (message, repr(e), snapshot_uuid),
"%s, Error: %s. Backup snapshot id: %s."
% (message, repr(e), snapshot_id),
file=sys.stderr,
)
raise e

if r_update is None:
message = "%s, Error when updating: %s/%s. Backup snapshot uuid: %s." % (message, rec['name'], rec['type'], snapshot_uuid)
message = "%s, Error when updating: %s/%s. Backup snapshot id: %s." % (message, rec['name'], rec['type'], snapshot_id)
return "ERROR", message

if verbose:
print("Updated record %s/%s from %s to %s" % (rec['name'], rec['type'], dns_ip, ip))
print("API response: %s" % json.dumps(r_update, indent=2))

# delete snapshot
ldns.delete_domain_snapshot(domain, uuid=snapshot_uuid)
ldns.delete_domain_snapshot(domain, sid=snapshot_id)
if verbose:
print("Backup snapshot deleted.")

Expand Down
6 changes: 3 additions & 3 deletions livedns_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ def post_domain_snapshot(self, domain, name=None):
}
return self._query_api(method="POST", query="domains/%s/snapshots" % domain, json_data=json_data)

def delete_domain_snapshot(self, domain, uuid):
def delete_domain_snapshot(self, domain, sid):
"""POST a domain snapshot.
:param str domain: The domain.
:param str uuid: The snapshot uuid.
:param str sid: The snapshot id.
:return: The API response, or ``None`` on error.
:rtype: dict|list|None
"""

return self._query_api(method="DELETE", query="domains/%s/snapshots/%s" % (domain, uuid))
return self._query_api(method="DELETE", query="domains/%s/snapshots/%s" % (domain, sid))

0 comments on commit e138537

Please sign in to comment.