From 15004e3e724e5e79c0fbcc495e5bc2057ad9ff92 Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Fri, 8 May 2020 17:39:50 +0200 Subject: [PATCH] use new api for dns list --- gandi/cli/core/base.py | 11 +++++++++-- gandi/cli/modules/dns.py | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gandi/cli/core/base.py b/gandi/cli/core/base.py index 853e04a9..813b2015 100644 --- a/gandi/cli/core/base.py +++ b/gandi/cli/core/base.py @@ -136,10 +136,17 @@ def json_call(cls, method, url, **kwargs): "'gandi setup' command") sys.exit(1) if send_key: + #print(url) if 'headers' in kwargs: - kwargs['headers'].update({'X-Api-Key': apikey}) + if url.startswith('https://api.gandi.net/v5/domain'): + kwargs['headers'].update({'authorization': 'apikey ' + apikey}) + else: + kwargs['headers'].update({'X-Api-Key': apikey}) else: - kwargs['headers'] = {'X-Api-Key': apikey} + if url.startswith('https://api.gandi.net/v5/domain'): + kwargs['headers'] = {'authorization': 'apikey ' + apikey} + else: + kwargs['headers'] = {'X-Api-Key': apikey} except MissingConfiguration: if not empty_key: return [] diff --git a/gandi/cli/modules/dns.py b/gandi/cli/modules/dns.py index 1d997fff..9ca0f4ef 100644 --- a/gandi/cli/modules/dns.py +++ b/gandi/cli/modules/dns.py @@ -35,7 +35,8 @@ def get_sort_url(cls, url, sort_by=None): @classmethod def list(cls): """List domains.""" - return cls.json_get('%s/domains' % cls.api_url) + api_url = 'https://api.gandi.net/v5/domain' + return cls.json_get('%s/domains' % api_url) @classmethod def type_list(cls):