@@ -211,7 +211,7 @@ class DatalakeRESTInterface:
211211 url_suffix: str (None)
212212 Domain to send REST requests to. The end-point URL is constructed
213213 using this and the store_name. If None, use default.
214- api_version: str (2016-11 -01)
214+ api_version: str (2018-05 -01)
215215 The API version to target with requests. Changing this value will
216216 change the behavior of the requests, and can cause unexpected behavior or
217217 breaking changes. Changes to this value should be undergone with caution.
@@ -246,7 +246,7 @@ class DatalakeRESTInterface:
246246 }
247247
248248 def __init__ (self , store_name = default_store , token = None ,
249- url_suffix = default_adls_suffix , api_version = '2016-11 -01' , ** kwargs ):
249+ url_suffix = default_adls_suffix , api_version = '2018-05 -01' , ** kwargs ):
250250 # in the case where an empty string is passed for the url suffix, it must be replaced with the default.
251251 url_suffix = url_suffix or default_adls_suffix
252252 self .local = threading .local ()
@@ -288,7 +288,7 @@ def _check_token(self):
288288 self .head = {'Authorization' : cur_session .headers ['Authorization' ]}
289289 self .local .session = None
290290
291- def _log_request (self , method , url , op , path , params , headers , retry_count ):
291+ def _log_request (self , method , url , op , path , params , headers , retry_count ):
292292 msg = "HTTP Request\n {} {}\n " .format (method .upper (), url )
293293 msg += "{} '{}' {}\n \n " .format (
294294 op , path ,
@@ -334,7 +334,7 @@ def _is_json_response(self, response):
334334 return False
335335 return response .headers ['content-type' ].startswith ('application/json' )
336336
337- def call (self , op , path = '' , is_extended = False , expected_error_code = None , retry_policy = None , ** kwargs ):
337+ def call (self , op , path = '' , is_extended = False , expected_error_code = None , retry_policy = None , headers = {}, ** kwargs ):
338338 """ Execute a REST call
339339
340340 Parameters
@@ -389,15 +389,16 @@ def call(self, op, path='', is_extended=False, expected_error_code=None, retry_p
389389 retry_count += 1
390390 last_exception = None
391391 try :
392- response = self .__call_once (method ,
393- url ,
394- params ,
395- data ,
396- stream ,
397- request_id ,
398- retry_count ,
399- op ,
400- path ,
392+ response = self .__call_once (method = method ,
393+ url = url ,
394+ params = params ,
395+ data = data ,
396+ stream = stream ,
397+ request_id = request_id ,
398+ retry_count = retry_count ,
399+ op = op ,
400+ path = path ,
401+ headers = headers ,
401402 ** kwargs )
402403 except requests .exceptions .RequestException as e :
403404 last_exception = e
@@ -449,13 +450,14 @@ def is_successful_response(self, response, exception):
449450 return True
450451 return False
451452
452- def __call_once (self , method , url , params , data , stream , request_id , retry_count , op , path = '' , ** kwargs ):
453+ def __call_once (self , method , url , params , data , stream , request_id , retry_count , op , path = '' , headers = {}, ** kwargs ):
453454 func = getattr (self .session , method )
454- headers = self .head .copy ()
455- headers ['x-ms-client-request-id' ] = request_id + "." + str (retry_count )
456- headers ['User-Agent' ] = self .user_agent
457- self ._log_request (method , url , op , urllib .quote (path ), kwargs , headers , retry_count )
458- return func (url , params = params , headers = headers , data = data , stream = stream )
455+ req_headers = self .head .copy ()
456+ req_headers ['x-ms-client-request-id' ] = request_id + "." + str (retry_count )
457+ req_headers ['User-Agent' ] = self .user_agent
458+ req_headers .update (headers )
459+ self ._log_request (method , url , op , urllib .quote (path ), kwargs , req_headers , retry_count )
460+ return func (url , params = params , headers = req_headers , data = data , stream = stream )
459461
460462 def __getstate__ (self ):
461463 state = self .__dict__ .copy ()
0 commit comments