Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 35e9bf5

Browse files
committed
more debugging
1 parent 82c5020 commit 35e9bf5

3 files changed

Lines changed: 30 additions & 15 deletions

File tree

cloudflare_v4/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# because everything logs
2+
import logging
3+
4+
# all the exceptions
15
from exceptions import CloudFlareError, CloudFlareAPIError
26

37
from construct import CloudFlare

cloudflare_v4/util.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,25 @@
44
import requests
55

66
def call(auth, method, endpoint, params=None):
7-
response = requests.request(method,
8-
'https://api.cloudflare.com/client/v4/' + endpoint,
9-
headers={ "X-Auth-Email": auth['EMAIL'],
10-
"X-Auth-Key": auth['TOKEN'] },
11-
params=params
12-
)
13-
data = response.text
14-
try:
15-
data = json.loads(data)
16-
return data
17-
except ValueError:
18-
raise CloudFlareAPIError('JSON parse failed.')
19-
if data['result'] == 'error':
20-
raise CloudFlareAPIError(data['msg'])
7+
logging.debug('auth')
8+
logging.debug('method')
9+
logging.debug('endpoint')
10+
logging.debug('params')
11+
if (auth is None) or (method is None) or (endpoint is None):
12+
raise CloudFlareError('You must specify auth, method, and endpoint')
13+
else:
14+
response = requests.request(method,
15+
'https://api.cloudflare.com/client/v4/' + endpoint,
16+
headers={ "X-Auth-Email": auth['EMAIL'],
17+
"X-Auth-Key": auth['TOKEN'] },
18+
params=params
19+
)
20+
data = response.text
21+
logging.debug('data')
22+
try:
23+
data = json.loads(data)
24+
return data
25+
except ValueError:
26+
raise CloudFlareAPIError('JSON parse failed.')
27+
if data['result'] == 'error':
28+
raise CloudFlareAPIError(data['msg'])

cloudflare_v4/zones/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
ENDPOINT = 'zones'
44

55
def get(auth, params=None):
6-
return util.call(auth, 'GET', ENDPOINT, params)
6+
if type(params) is dict:
7+
return util.call(auth, 'GET', ENDPOINT, params)
8+
elif type(params) is str:
9+
return util.call(auth)

0 commit comments

Comments
 (0)