@@ -23,7 +23,7 @@ class Client(object):
23
23
def __init__ (self , username = None , password = None , token = None ,
24
24
ecs_endpoint = None , token_endpoint = None , verify_ssl = False ,
25
25
token_path = '/tmp/ecsclient.tkn' ,
26
- request_timeout = 15.0 , cache_token = True ):
26
+ request_timeout = 15.0 , cache_token = True , override_header = None ):
27
27
"""
28
28
Creates the ECSClient class that the client will directly work with
29
29
@@ -39,6 +39,7 @@ def __init__(self, username=None, password=None, token=None,
39
39
:param cache_token: Whether to cache the token, by default this is true
40
40
you should only switch this to false when you want to directly fetch
41
41
a token for a user
42
+ :param override_header: X-EMC-Override header value into API calls
42
43
"""
43
44
if not ecs_endpoint :
44
45
raise ECSClientException ("Missing 'ecs_endpoint'" )
@@ -53,6 +54,7 @@ def __init__(self, username=None, password=None, token=None,
53
54
if not (token or os .path .isfile (token_path )):
54
55
raise ECSClientException ("'token_endpoint' not provided and missing 'token'|'token_path'" )
55
56
57
+ self .override_header = override_header
56
58
self .username = username
57
59
self .password = password
58
60
self .token = token
@@ -104,9 +106,12 @@ def remove_cached_token(self):
104
106
105
107
def _fetch_headers (self ):
106
108
token = self .token if self .token else self ._token_request .get_token ()
107
- return {'Accept' : 'application/json' ,
108
- 'Content-Type' : 'application/json' ,
109
- 'x-sds-auth-token' : token }
109
+ headers = {'Accept' : 'application/json' ,
110
+ 'Content-Type' : 'application/json' ,
111
+ 'x-sds-auth-token' : token }
112
+ if self .override_header != None :
113
+ headers ['X-EMC-Override' ] = self .override_header
114
+ return headers
110
115
111
116
def _construct_url (self , path ):
112
117
url = '{0}/{1}' .format (self .ecs_endpoint , path )
0 commit comments