@@ -26,23 +26,23 @@ def __init__(self, email, token, certtoken, base_url, debug):
2626 else :
2727 self .logger = None
2828
29- def _call_with_no_auth (self , method , api_call_part1 , api_call_part2 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
29+ def _call_with_no_auth (self , method , api_call_part1 , api_call_part2 = None , api_call_part3 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
3030 headers = {}
31- return self ._call (method , headers , api_call_part1 , api_call_part2 , identifier1 , identifier2 , params , data )
31+ return self ._call (method , headers , api_call_part1 , api_call_part2 , api_call_part3 , identifier1 , identifier2 , params , data )
3232
33- def _call_with_auth (self , method , api_call_part1 , api_call_part2 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
33+ def _call_with_auth (self , method , api_call_part1 , api_call_part2 = None , api_call_part3 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
3434 if self .EMAIL is '' or self .TOKEN is '' :
3535 raise CloudFlareAPIError (0 , 'no email and/or token defined' )
3636 headers = { "X-Auth-Email" : self .EMAIL , "X-Auth-Key" : self .TOKEN , 'Content-Type' : 'application/json' }
37- return self ._call (method , headers , api_call_part1 , api_call_part2 , identifier1 , identifier2 , params , data )
37+ return self ._call (method , headers , api_call_part1 , api_call_part2 , api_call_part3 , identifier1 , identifier2 , params , data )
3838
39- def _call_with_certauth (self , method , api_call_part1 , api_call_part2 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
39+ def _call_with_certauth (self , method , api_call_part1 , api_call_part2 = None , api_call_part3 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
4040 if self .CERTTOKEN is '' :
4141 raise CloudFlareAPIError (0 , 'no email and/or cert token defined' )
4242 headers = { "X-Auth-User-Service-Key" : self .CERTTOKEN , 'Content-Type' : 'application/json' }
43- return self ._call (method , headers , api_call_part1 , api_call_part2 , identifier1 , identifier2 , params , data )
43+ return self ._call (method , headers , api_call_part1 , api_call_part2 , api_call_part3 , identifier1 , identifier2 , params , data )
4444
45- def _call (self , method , headers , api_call_part1 , api_call_part2 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
45+ def _call (self , method , headers , api_call_part1 , api_call_part2 = None , api_call_part3 = None , identifier1 = None , identifier2 = None , params = None , data = None ):
4646 if api_call_part2 is not None or (data is not None and method == 'GET' ):
4747 if identifier2 is None :
4848 url = self .BASE_URL + '/' + api_call_part1 + '/' + identifier1 + '/' + api_call_part2
@@ -53,9 +53,11 @@ def _call(self, method, headers, api_call_part1, api_call_part2=None, identifier
5353 url = self .BASE_URL + '/' + api_call_part1
5454 else :
5555 url = self .BASE_URL + '/' + api_call_part1 + '/' + identifier1
56+ if api_call_part3 :
57+ url += '/' + api_call_part3
5658
5759 if self .logger :
58- self .logger .debug ("Call: %s,%s,%s,%s" % (str (api_call_part1 ), str (identifier1 ), str (api_call_part2 ), str (identifier2 )))
60+ self .logger .debug ("Call: %s,%s,%s,%s,%s " % (str (api_call_part1 ), str (identifier1 ), str (api_call_part2 ), str (identifier2 ), str ( api_call_part3 )))
5961 self .logger .debug ("Call: optional params and data: %s %s" % (str (params ), str (data )))
6062 self .logger .debug ("Call: url is: %s" % (str (url )))
6163 self .logger .debug ("Call: method is: %s" % (str (method )))
@@ -104,69 +106,73 @@ def _call(self, method, headers, api_call_part1, api_call_part2=None, identifier
104106 return response_data ['result' ]
105107
106108 class _unused :
107- def __init__ (self , base , api_call_part1 , api_call_part2 = None ):
109+ def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
108110 #if self.logger:
109111 # self.logger.debug("_unused %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
110112 self .base = base
111113 self .api_call_part1 = api_call_part1
112114 self .api_call_part2 = api_call_part2
115+ self .api_call_part3 = api_call_part3
113116
114117 class _client_noauth :
115- def __init__ (self , base , api_call_part1 , api_call_part2 = None ):
118+ def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
116119 #if self.logger:
117120 # self.logger.debug("_client_noauth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
118121 self .base = base
119122 self .api_call_part1 = api_call_part1
120123 self .api_call_part2 = api_call_part2
124+ self .api_call_part3 = api_call_part3
121125
122126 def get (self , identifier1 = None , identifier2 = None , params = None , data = None ):
123- return self .base ._call_with_no_auth ('GET' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
127+ return self .base ._call_with_no_auth ('GET' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
124128
125129 class _client_with_auth :
126- def __init__ (self , base , api_call_part1 , api_call_part2 = None ):
130+ def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
127131 #if self.logger:
128132 # self.logger.debug("_client_with_auth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
129133 self .base = base
130134 self .api_call_part1 = api_call_part1
131135 self .api_call_part2 = api_call_part2
136+ self .api_call_part3 = api_call_part3
132137
133138 def get (self , identifier1 = None , identifier2 = None , params = None , data = None ):
134- return self .base ._call_with_auth ('GET' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
139+ return self .base ._call_with_auth ('GET' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
135140
136141 def patch (self , identifier1 = None , identifier2 = None , params = None , data = None ):
137- return self .base ._call_with_auth ('PATCH' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
142+ return self .base ._call_with_auth ('PATCH' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
138143
139144 def post (self , identifier1 = None , identifier2 = None , params = None , data = None ):
140- return self .base ._call_with_auth ('POST' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
145+ return self .base ._call_with_auth ('POST' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
141146
142147 def put (self , identifier1 = None , identifier2 = None , params = None , data = None ):
143- return self .base ._call_with_auth ('PUT' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
148+ return self .base ._call_with_auth ('PUT' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
144149
145150 def delete (self , identifier1 = None , identifier2 = None , params = None , data = None ):
146- return self .base ._call_with_auth ('DELETE' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
151+ return self .base ._call_with_auth ('DELETE' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
147152
148153 class _client_with_cert_auth :
149- def __init__ (self , base , api_call_part1 , api_call_part2 = None ):
154+ def __init__ (self , base , api_call_part1 , api_call_part2 = None , api_call_part3 = None ):
150155 #if self.logger:
151156 # self.logger.debug("_client_with_cert_auth %s,%s,%s" % (str(base), str(api_call_part1), str(api_call_part2)))
152157 self .base = base
153158 self .api_call_part1 = api_call_part1
154159 self .api_call_part2 = api_call_part2
160+ self .api_call_part3 = api_call_part3
155161
156162 def get (self , identifier1 = None , identifier2 = None , params = None , data = None ):
157- return self .base ._call_with_certauth ('GET' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
163+ return self .base ._call_with_certauth ('GET' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
158164
159165 def patch (self , identifier1 = None , identifier2 = None , params = None , data = None ):
160- return self .base ._call_with_certauth ('PATCH' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
166+ return self .base ._call_with_certauth ('PATCH' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
161167
162168 def post (self , identifier1 = None , identifier2 = None , params = None , data = None ):
163- return self .base ._call_with_certauth ('POST' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
169+ return self .base ._call_with_certauth ('POST' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
164170
165171 def put (self , identifier1 = None , identifier2 = None , params = None , data = None ):
166- return self .base ._call_with_certauth ('PUT' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
172+ return self .base ._call_with_certauth ('PUT' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
167173
168174 def delete (self , identifier1 = None , identifier2 = None , params = None , data = None ):
169- return self .base ._call_with_certauth ('DELETE' , self .api_call_part1 , self .api_call_part2 , identifier1 , identifier2 , params , data )
175+ return self .base ._call_with_certauth ('DELETE' , self .api_call_part1 , self .api_call_part2 , self . api_call_part3 , identifier1 , identifier2 , params , data )
170176
171177 def __init__ (self , email = None , token = None , certtoken = None , debug = False ):
172178 base_url = BASE_URL
0 commit comments