From 3d02389c6e978208b6a705f2751835e89c19adbd Mon Sep 17 00:00:00 2001 From: Etienne Gauvin Date: Sat, 22 May 2021 00:01:35 +0200 Subject: [PATCH 1/4] Updated authorization header --- livedns_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/livedns_client.py b/livedns_client.py index aa23fbc..84db7ae 100644 --- a/livedns_client.py +++ b/livedns_client.py @@ -37,7 +37,7 @@ def _query_api(self, method, query, json_data=None): url = "%s%s" % (self.url, urllib.parse.quote(query)) headers = { - "x-api-key": self.key, + "Authorization": "Apikey %s" % self.key, "Accept": "application/json", } From 2090dc98a96087f18ed29828dc49f0685d806d52 Mon Sep 17 00:00:00 2001 From: Etienne Gauvin Date: Sat, 22 May 2021 00:02:01 +0200 Subject: [PATCH 2/4] Updated default API URL --- config.ini-dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.ini-dist b/config.ini-dist index 86a1632..e3527f2 100644 --- a/config.ini-dist +++ b/config.ini-dist @@ -1,5 +1,5 @@ [api] -url = https://dns.api.gandi.net/api/v5 +url = https://api.gandi.net/v5/livedns/ ; Generate your Gandi API key via : https://account.gandi.net/en/users//security key = From beaed138665705f8391abdb212b1e4c99f7c16e0 Mon Sep 17 00:00:00 2001 From: Etienne Gauvin Date: Sat, 22 May 2021 00:31:30 +0200 Subject: [PATCH 3/4] Updated UUID property name --- dyn_gandi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyn_gandi.py b/dyn_gandi.py index ec0ae68..7ca0d68 100644 --- a/dyn_gandi.py +++ b/dyn_gandi.py @@ -118,7 +118,7 @@ def livedns_handle(domain, ip, records): if r_snap is None: raise RuntimeWarning("Could not create snapshot." % domain) - snapshot_uuid = r_snap['uuid'] + snapshot_uuid = r_snap['id'] if verbose: print("Backup snapshot created, uuid: %s." % snapshot_uuid) From e138537dfae0557631174ffb6be4c3601cd21bbc Mon Sep 17 00:00:00 2001 From: Danamir Date: Sat, 22 May 2021 02:02:50 +0200 Subject: [PATCH 4/4] Changed snapshot "uuid" to "id" to reflect the latest API doc --- dyn_gandi.py | 12 ++++++------ livedns_client.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dyn_gandi.py b/dyn_gandi.py index 7ca0d68..3ad47c9 100644 --- a/dyn_gandi.py +++ b/dyn_gandi.py @@ -118,10 +118,10 @@ 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: @@ -129,14 +129,14 @@ def livedns_handle(domain, ip, records): 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: @@ -144,7 +144,7 @@ def livedns_handle(domain, ip, records): 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.") diff --git a/livedns_client.py b/livedns_client.py index 84db7ae..ca11cb0 100644 --- a/livedns_client.py +++ b/livedns_client.py @@ -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))