From 294752f172be8e005d288e7b4eab8ee419aab8ee Mon Sep 17 00:00:00 2001 From: Bryant Howell Date: Mon, 6 May 2019 21:52:26 -0500 Subject: [PATCH] Added a swap_token() method to TableauRestApiConnection to help with wrapped REST API services where you might need to switch between many different user tokens on the backend --- setup.py | 2 +- .../tableau_rest_api_connection.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e526ddb..654d665 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='tableau_tools', - version='4.9.2', + version='4.9.3', packages=['tableau_tools', 'tableau_tools.tableau_rest_api', 'tableau_tools.tableau_documents', 'tableau_tools.examples'], url='https://github.com/bryantbhowell/tableau_tools', license='', diff --git a/tableau_rest_api/tableau_rest_api_connection.py b/tableau_rest_api/tableau_rest_api_connection.py index d9e7531..6136f20 100644 --- a/tableau_rest_api/tableau_rest_api_connection.py +++ b/tableau_rest_api/tableau_rest_api_connection.py @@ -279,6 +279,24 @@ def signin(self, user_luid_to_impersonate=None): self._request_obj.xml_request = None self.end_log_block() + def swap_token(self, site_luid, user_luid, token): + """ + :type token: unicode + :type site_luid: unicode + :type user_luid: unicode + :return: + """ + self.start_log_block() + self.token = token + self.site_luid = site_luid + self.user_luid = user_luid + if self._request_obj is None: + self._request_obj = RestXmlRequest(None, self.token, self.logger, ns_map_url=self.ns_map['t'], + verify_ssl_cert=self.verify_ssl_cert) + else: + self._request_obj.token = self.token + self.end_log_block() + def signout(self, session_token=None): """ :type session_token: unicode