@@ -149,9 +149,16 @@ def _call(self, method, headers,
149149 response = requests .delete (url , headers = headers )
150150 elif method == 'PATCH' :
151151 if data :
152- response = requests .request ('PATCH' , url , headers = headers , params = params , json = data )
152+ response = requests .request ('PATCH' ,
153+ url ,
154+ headers = headers ,
155+ params = params ,
156+ json = data )
153157 else :
154- response = requests .request ('PATCH' , url , headers = headers , params = params )
158+ response = requests .request ('PATCH' ,
159+ url ,
160+ headers = headers ,
161+ params = params )
155162 else :
156163 # should never happen
157164 raise CloudFlareAPIError (0 , 'method not supported' )
@@ -168,10 +175,11 @@ def _call(self, method, headers,
168175 raise CloudFlareAPIError (0 , 'JSON parse failed.' )
169176
170177 if response_data ['success' ] is False :
178+ code = response_data ['errors' ][0 ]['code' ]
179+ message = response_data ['errors' ][0 ]['message' ]
171180 if self .logger :
172- self .logger .debug ("response_data error: %d %s" % (response_data ['errors' ][0 ]['code' ],
173- response_data ['errors' ][0 ]['message' ]))
174- raise CloudFlareAPIError (response_data ['errors' ][0 ]['code' ], response_data ['errors' ][0 ]['message' ])
181+ self .logger .debug ("response_data error: %d %s" % (code , message ))
182+ raise CloudFlareAPIError (code , message )
175183
176184 return response_data ['result' ]
177185
@@ -181,8 +189,6 @@ class _unused(object):
181189 def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
182190 """ CloudFlare v4 API"""
183191
184- #if self.logger:
185- # self.logger.debug("_unused %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
186192 self .base = base
187193 self .api_call_part1 = api_call_part1
188194 self .api_call_part2 = api_call_part2
@@ -194,8 +200,6 @@ class _client_noauth(object):
194200 def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
195201 """ CloudFlare v4 API"""
196202
197- #if self.logger:
198- # self.logger.debug("_client_noauth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
199203 self .base = base
200204 self .api_call_part1 = api_call_part1
201205 self .api_call_part2 = api_call_part2
@@ -204,16 +208,20 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non
204208 def get (self , identifier1 = None , identifier2 = None , params = None , data = None ):
205209 """ CloudFlare v4 API"""
206210
207- return self .base ._call_with_no_auth ('GET' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
211+ return self .base ._call_with_no_auth ('GET' ,
212+ self .api_call_part1 ,
213+ self .api_call_part2 ,
214+ self .api_call_part3 ,
215+ identifier1 ,
216+ identifier2 ,
217+ params , data )
208218
209219 class _client_with_auth (object ):
210220 """ CloudFlare v4 API"""
211221
212222 def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
213223 """ CloudFlare v4 API"""
214224
215- #if self.logger:
216- # self.logger.debug("_client_with_auth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
217225 self .base = base
218226 self .api_call_part1 = api_call_part1
219227 self .api_call_part2 = api_call_part2
@@ -222,36 +230,64 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non
222230 def get (self , identifier1 = None , identifier2 = None , params = None , data = None ):
223231 """ CloudFlare v4 API"""
224232
225- return self .base ._call_with_auth ('GET' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
233+ return self .base ._call_with_auth ('GET' ,
234+ self .api_call_part1 ,
235+ self .api_call_part2 ,
236+ self .api_call_part3 ,
237+ identifier1 ,
238+ identifier2 ,
239+ params , data )
226240
227241 def patch (self , identifier1 = None , identifier2 = None , params = None , data = None ):
228242 """ CloudFlare v4 API"""
229243
230- return self .base ._call_with_auth ('PATCH' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
244+ return self .base ._call_with_auth ('PATCH' ,
245+ self .api_call_part1 ,
246+ self .api_call_part2 ,
247+ self .api_call_part3 ,
248+ identifier1 ,
249+ identifier2 ,
250+ params , data )
231251
232252 def post (self , identifier1 = None , identifier2 = None , params = None , data = None ):
233253 """ CloudFlare v4 API"""
234254
235- return self .base ._call_with_auth ('POST' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
255+ return self .base ._call_with_auth ('POST' ,
256+ self .api_call_part1 ,
257+ self .api_call_part2 ,
258+ self .api_call_part3 ,
259+ identifier1 ,
260+ identifier2 ,
261+ params , data )
236262
237263 def put (self , identifier1 = None , identifier2 = None , params = None , data = None ):
238264 """ CloudFlare v4 API"""
239265
240- return self .base ._call_with_auth ('PUT' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
266+ return self .base ._call_with_auth ('PUT' ,
267+ self .api_call_part1 ,
268+ self .api_call_part2 ,
269+ self .api_call_part3 ,
270+ identifier1 ,
271+ identifier2 ,
272+ params , data )
241273
242274 def delete (self , identifier1 = None , identifier2 = None , params = None , data = None ):
243275 """ CloudFlare v4 API"""
244276
245- return self .base ._call_with_auth ('DELETE' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
277+ return self .base ._call_with_auth ('DELETE' ,
278+ self .api_call_part1 ,
279+ self .api_call_part2 ,
280+ self .api_call_part3 ,
281+ identifier1 ,
282+ identifier2 ,
283+ params , data )
246284
247285 class _client_with_cert_auth (object ):
248286 """ CloudFlare v4 API"""
249287
250288 def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
251289 """ CloudFlare v4 API"""
252290
253- #if self.logger:
254- # self.logger.debug("_client_with_cert_auth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
255291 self .base = base
256292 self .api_call_part1 = api_call_part1
257293 self .api_call_part2 = api_call_part2
@@ -260,27 +296,57 @@ def __init__(self, base, api_call_part1, api_call_part2=None, api_call_part3=Non
260296 def get (self , identifier1 = None , identifier2 = None , params = None , data = None ):
261297 """ CloudFlare v4 API"""
262298
263- return self .base ._call_with_certauth ('GET' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
299+ return self .base ._call_with_certauth ('GET' ,
300+ self .api_call_part1 ,
301+ self .api_call_part2 ,
302+ self .api_call_part3 ,
303+ identifier1 ,
304+ identifier2 ,
305+ params , data )
264306
265307 def patch (self , identifier1 = None , identifier2 = None , params = None , data = None ):
266308 """ CloudFlare v4 API"""
267309
268- return self .base ._call_with_certauth ('PATCH' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
310+ return self .base ._call_with_certauth ('PATCH' ,
311+ self .api_call_part1 ,
312+ self .api_call_part2 ,
313+ self .api_call_part3 ,
314+ identifier1 ,
315+ identifier2 ,
316+ params , data )
269317
270318 def post (self , identifier1 = None , identifier2 = None , params = None , data = None ):
271319 """ CloudFlare v4 API"""
272320
273- return self .base ._call_with_certauth ('POST' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
321+ return self .base ._call_with_certauth ('POST' ,
322+ self .api_call_part1 ,
323+ self .api_call_part2 ,
324+ self .api_call_part3 ,
325+ identifier1 ,
326+ identifier2 ,
327+ params , data )
274328
275329 def put (self , identifier1 = None , identifier2 = None , params = None , data = None ):
276330 """ CloudFlare v4 API"""
277331
278- return self .base ._call_with_certauth ('PUT' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
332+ return self .base ._call_with_certauth ('PUT' ,
333+ self .api_call_part1 ,
334+ self .api_call_part2 ,
335+ self .api_call_part3 ,
336+ identifier1 ,
337+ identifier2 ,
338+ params , data )
279339
280340 def delete (self , identifier1 = None , identifier2 = None , params = None , data = None ):
281341 """ CloudFlare v4 API"""
282342
283- return self .base ._call_with_certauth ('DELETE' , self .api_call_part1 , self .api_call_part2 , self .api_call_part3 , identifier1 , identifier2 , params , data )
343+ return self .base ._call_with_certauth ('DELETE' ,
344+ self .api_call_part1 ,
345+ self .api_call_part2 ,
346+ self .api_call_part3 ,
347+ identifier1 ,
348+ identifier2 ,
349+ params , data )
284350
285351 def __init__ (self , email = None , token = None , certtoken = None , debug = False ):
286352 """ CloudFlare v4 API"""
0 commit comments