Skip to content

Commit 2c89247

Browse files
Added accept_language property for updating the Accept-Language header. This affects /searchdata and other endpoints in terms of locale based formatting of strings
1 parent f5217e0 commit 2c89247

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/thoughtspot_rest_api_v1/tsrestapiv2.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ def __init__(self, server_url: str):
4747
# X-Requested-By is necessary for all calls.
4848
# Accept: application/json isn't necessary with requests (default: Accept: */*) but might be in other frameworks
4949
#
50+
self.__accept_language = "en-US"
5051
# This sets the header on any subsequent call
51-
self.api_headers = {'X-Requested-By': 'ThoughtSpot', 'Accept': 'application/json', 'Accept-Language': 'en_US'}
52+
self.api_headers = {'X-Requested-By': 'ThoughtSpot',
53+
'Accept': 'application/json',
54+
'Accept-Language': self.__accept_language}
5255
self.requests_session.headers.update(self.api_headers)
5356

5457
# Will be set after initial request
@@ -77,6 +80,16 @@ def bearer_token(self, bearer_token):
7780
self.api_headers['Authorization'] = 'Bearer {}'.format(bearer_token)
7881
self.requests_session.headers.update(self.api_headers)
7982

83+
@property
84+
def accept_language(self):
85+
return self.__accept_language
86+
87+
@accept_language.setter
88+
def accept_language(self, accept_language_code):
89+
self.__accept_language = accept_language_code
90+
self.api_headers['Accept-Language'] = accept_language_code
91+
self.requests_session.headers.update(self.api_headers)
92+
8093
#
8194
# Session management calls
8295
# - up here vs. in the SESSION section below (because these two are required)

0 commit comments

Comments
 (0)