Skip to content

Commit

Permalink
add missing HTTP method put, fix unknown exception class
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Martin committed Dec 5, 2015
1 parent 6fff910 commit 7c0fc05
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cloudflare_v4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def call(self, method, main_endpoint, endpoint=None, params=None, data=None):
params=params_to_send)
elif method == 'POST':
response = requests.post(url, headers=headers, json=data)
elif method == 'PUT':
response = requests.put(url, headers=headers, json=data)
elif method == 'DELETE':
if data:
response = requests.delete(url, headers=headers, json=data)
Expand All @@ -55,7 +57,7 @@ def call(self, method, main_endpoint, endpoint=None, params=None, data=None):
elif method == 'PATCH':
pass
else:
raise CloudFlareAPIInternalError('method not supported') # should never happen
raise CloudFlareAPIError('method not supported') # should never happen
data = response.text
self.logger.debug("data received: %s" % data)
try:
Expand Down Expand Up @@ -84,10 +86,15 @@ def post(self, params=None, data=None):
return self.base_client.call('POST', self.main_endpoint,
self.endpoint, params, data)

def put(self, params=None, data=None):
return self.base_client.call('PUT', self.main_endpoint,
self.endpoint, params, data)

def delete(self, params=None, data=None):
return self.base_client.call('DELETE', self.main_endpoint,
self.endpoint, params, data)


def __init__(self, email, token, debug):
self.base_client = self.BaseClient(email, token, debug)
setattr(self, "zones", self.DynamicClient(self.base_client, "zones"))
Expand Down

0 comments on commit 7c0fc05

Please sign in to comment.