@@ -99,12 +99,7 @@ def __init__(self, items, total_count):
99
99
100
100
class XmlRpcTransport (object ):
101
101
"""XML-RPC transport."""
102
- def __init__ (self ,
103
- endpoint_url = None ,
104
- timeout = None ,
105
- proxy = None ,
106
- user_agent = None ,
107
- verify = True ):
102
+ def __init__ (self , endpoint_url = None , timeout = None , proxy = None , user_agent = None , verify = True ):
108
103
109
104
self .endpoint_url = (endpoint_url or
110
105
consts .API_PUBLIC_ENDPOINT ).rstrip ('/' )
@@ -202,19 +197,13 @@ def __call__(self, request):
202
197
class RestTransport (object ):
203
198
"""REST transport.
204
199
205
- Currently only supports GET requests (no POST, PUT, DELETE) and lacks
206
- support for masks, filters, limits and offsets.
200
+ REST calls should mostly work, but is not fully tested.
201
+ XML-RPC should be used when in doubt
207
202
"""
208
203
209
- def __init__ (self ,
210
- endpoint_url = None ,
211
- timeout = None ,
212
- proxy = None ,
213
- user_agent = None ,
214
- verify = True ):
204
+ def __init__ (self , endpoint_url = None , timeout = None , proxy = None , user_agent = None , verify = True ):
215
205
216
- self .endpoint_url = (endpoint_url or
217
- consts .API_PUBLIC_ENDPOINT_REST ).rstrip ('/' )
206
+ self .endpoint_url = (endpoint_url or consts .API_PUBLIC_ENDPOINT_REST ).rstrip ('/' )
218
207
self .timeout = timeout or None
219
208
self .proxy = proxy
220
209
self .user_agent = user_agent or consts .USER_AGENT
@@ -223,12 +212,12 @@ def __init__(self,
223
212
def __call__ (self , request ):
224
213
"""Makes a SoftLayer API call against the REST endpoint.
225
214
226
- This currently only works with GET requests
215
+ REST calls should mostly work, but is not fully tested.
216
+ XML-RPC should be used when in doubt
227
217
228
218
:param request request: Request object
229
219
"""
230
- request .transport_headers .setdefault ('Content-Type' ,
231
- 'application/json' )
220
+ request .transport_headers .setdefault ('Content-Type' , 'application/json' )
232
221
request .transport_headers .setdefault ('User-Agent' , self .user_agent )
233
222
234
223
params = request .headers .copy ()
@@ -252,9 +241,8 @@ def __call__(self, request):
252
241
)
253
242
254
243
method = REST_SPECIAL_METHODS .get (request .method )
255
- is_special_method = True
244
+
256
245
if method is None :
257
- is_special_method = False
258
246
method = 'GET'
259
247
260
248
body = {}
@@ -272,9 +260,7 @@ def __call__(self, request):
272
260
if request .identifier is not None :
273
261
url_parts .append (str (request .identifier ))
274
262
275
- # Special methods (createObject, editObject, etc) use the HTTP verb
276
- # to determine the action on the resource
277
- if request .method is not None and not is_special_method :
263
+ if request .method is not None :
278
264
url_parts .append (request .method )
279
265
280
266
url = '%s.%s' % ('/' .join (url_parts ), 'json' )
0 commit comments