From 28daae894ed4409cebb7a72c7eb4c4884b933fba Mon Sep 17 00:00:00 2001 From: Felix Wong Date: Thu, 17 Sep 2015 09:39:12 +0000 Subject: [PATCH] fix delete endpoint --- cloudflare_v4/__init__.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/cloudflare_v4/__init__.py b/cloudflare_v4/__init__.py index b6f6f3a..a14aab4 100644 --- a/cloudflare_v4/__init__.py +++ b/cloudflare_v4/__init__.py @@ -22,30 +22,33 @@ def call(self, method, main_endpoint, endpoint=None, params=None, data=None): else: url = BASE_URL + '/' + main_endpoint method = method.upper() - self.logger.debug("EMAIL is: " + str(self.EMAIL)) - self.logger.debug("TOKEN is: " + str(self.TOKEN)) - self.logger.debug("method type is: " + method) - self.logger.debug("url endpoint is: " + url) - self.logger.debug("optional params is: " + str(params)) - self.logger.debug("optional data is: " + str(data)) + self.logger.debug("EMAIL is: %s" % str(self.EMAIL)) + self.logger.debug("TOKEN is: %s" % str(self.TOKEN)) + self.logger.debug("method type is: %s" % method) + self.logger.debug("main endpoint is: %s" % main_endpoint) + self.logger.debug("optional endpoint is: %s" % endpoint) + self.logger.debug("url endpoint is: %s" % url) + self.logger.debug("optional params is: %s" % str(params)) + self.logger.debug("optional data is: %s" % str(data)) if (method is None) or (main_endpoint is None): raise CloudFlareError('You must specify a method and endpoint') # should never happen else: - self.logger.debug("headers being sent: " + str(headers)) + self.logger.debug("headers being sent: %s" % str(headers)) if method == 'GET': if data: params_to_send = data else: params_to_send = params + self.logger.debug("params being sent: %s", params_to_send) response = requests.get(url, headers=headers, params=params_to_send) elif method == 'POST': headers['Content-Type'] = 'application/json' response = requests.post(url, headers=headers, json=data) elif method == 'DELETE': - response = requests.delete(url, headers=headers, json=data) + response = requests.delete("%s/%s" % (url, data), headers=headers) data = response.text - self.logger.debug("data received: " + data) + self.logger.debug("data received: %s" % data) try: data = json.loads(data) if data['success'] is False: @@ -57,9 +60,9 @@ def call(self, method, main_endpoint, endpoint=None, params=None, data=None): class DynamicClient: def __init__(self, base_client, main_endpoint, endpoint=None): - base_client.logger.debug("base client is: " + str(base_client)) - base_client.logger.debug("main endpoint is: " + str(main_endpoint)) - base_client.logger.debug("endpoint is: " + str(endpoint)) + base_client.logger.debug("base client is: %s" % str(base_client)) + base_client.logger.debug("main endpoint is: %s" % str(main_endpoint)) + base_client.logger.debug("endpoint is: %s" % str(endpoint)) self.base_client = base_client self.main_endpoint = main_endpoint self.endpoint = endpoint