diff --git a/setup.py b/setup.py index a95e1a0..0016560 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='tableau_tools', - version='4.3.10', + version='4.3.11', 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_base.py b/tableau_base.py index ee26c1c..a6c7240 100644 --- a/tableau_base.py +++ b/tableau_base.py @@ -15,8 +15,8 @@ def __init__(self): self.luid_pattern = r"[0-9a-fA-F]*-[0-9a-fA-F]*-[0-9a-fA-F]*-[0-9a-fA-F]*-[0-9a-fA-F]*" # Defaults, will get updated with each update. Overwritten by set_tableau_server_version - self.version = u"10.3" - self.api_version = u"2.6" + self.version = u"10.5" + self.api_version = u"2.8" self.tableau_namespace = u'http://tableau.com/api' self.ns_map = {'t': 'http://tableau.com/api'} self.ns_prefix = '{' + self.ns_map['t'] + '}' diff --git a/tableau_documents/tableau_connection.py b/tableau_documents/tableau_connection.py index ca7367f..c291723 100644 --- a/tableau_documents/tableau_connection.py +++ b/tableau_documents/tableau_connection.py @@ -80,9 +80,9 @@ def port(self): @port.setter def port(self, new_port): if self.xml_obj.get(u"port") is not None: - self.xml_obj.attrib[u"port"] = new_port + self.xml_obj.attrib[u"port"] = unicode(new_port) else: - self.xml_obj.set(u'port', new_port) + self.xml_obj.set(u'port', unicode(new_port)) @property def connection_type(self): @@ -102,13 +102,31 @@ def is_windows_auth(self): else: return False + @property + def filename(self): + if self.xml_obj.get(u'filename') is None: + raise NoResultsException(u'Connection type {} does not have filename attribute'.format( + self.connection_type)) + else: + return self.xml_obj.get(u'filename') + + @filename.setter + def filename(self, filename): + if self.xml_obj.get(u'filename') is not None: + self.xml_obj.attrib[u'filename'] = filename + else: + self.xml_obj.set(u'filename', filename) + @property def sslmode(self): return self.xml_obj.get(u'sslmode') @sslmode.setter def sslmode(self, value=u'require'): - self.xml_obj.attrib[u"sslmode"] = value + if self.xml_obj.get(u'sslmode') is not None: + self.xml_obj.attrib[u"sslmode"] = value + else: + self.xml_obj.set(u'sslmode', value) @property def authentication(self): @@ -119,7 +137,7 @@ def authentication(self, auth_type): if self.xml_obj.get(u"authentication") is not None: self.xml_obj.attrib[u"authentication"] = auth_type else: - self.xml_obj.set(u"authentication") + self.xml_obj.set(u"authentication", auth_type) @property def service(self): @@ -130,5 +148,5 @@ def service(self, service): if self.xml_obj.get(u"service") is not None: self.xml_obj.attrib[u"service"] = service else: - self.xml_obj.set(u"service") + self.xml_obj.set(u"service", service) diff --git a/tableau_documents/tableau_datasource.py b/tableau_documents/tableau_datasource.py index 61d6580..f1195a8 100644 --- a/tableau_documents/tableau_datasource.py +++ b/tableau_documents/tableau_datasource.py @@ -839,7 +839,7 @@ def generate_cols_map_section(self): m.set(u"key", u"[{}]".format(key)) m.set(u"value", self.column_mapping[key]) c.append(m) - self.ds_xml.append(c) + self.xml.append(c) @staticmethod def generate_aliases_tag(): diff --git a/tableau_rest_api/rest_xml_request.py b/tableau_rest_api/rest_xml_request.py index 8297793..08e40f1 100644 --- a/tableau_rest_api/rest_xml_request.py +++ b/tableau_rest_api/rest_xml_request.py @@ -10,6 +10,7 @@ import requests import sys + # Handles all of the actual HTTP calling class RestXmlRequest(TableauBase): def __init__(self, url, token=None, logger=None, ns_map_url='http://tableau.com/api', @@ -254,6 +255,9 @@ def __make_request(self, page_number=1): else: detail_luid = False self.log(u'Tableau REST API error code is: {}'.format(error_code)) + # If you are not signed in + if error_code == u'401000': + raise NotSignedInException(u'You must sign in first') # Everything that is not 400 can potentially be recovered from if status_code in [401, 402, 403, 404, 405, 409]: # If 'not exists' for a delete, recover and log @@ -262,6 +266,7 @@ def __make_request(self, page_number=1): if status_code == 409: self.log(u'HTTP 409 error, most likely an already exists') raise RecoverableHTTPException(status_code, error_code, detail_luid) + raise except: raise diff --git a/tableau_rest_api/tableau_rest_api_connection.py b/tableau_rest_api/tableau_rest_api_connection.py index c14e631..31e62d3 100644 --- a/tableau_rest_api/tableau_rest_api_connection.py +++ b/tableau_rest_api/tableau_rest_api_connection.py @@ -204,9 +204,12 @@ def signin(self): api.http_verb = 'post' self.log(u'Login payload is\n {}'.format(etree.tostring(tsr))) + api.request_from_api(0) # self.log(api.get_raw_response()) xml = api.get_response() + + credentials_element = xml.findall(u'.//t:credentials', self.ns_map) self.token = credentials_element[0].get("token") self.log(u"Token is " + self.token) diff --git a/tableau_rest_api/tableau_rest_api_connection_28.py b/tableau_rest_api/tableau_rest_api_connection_28.py index c22f3ea..83905c6 100644 --- a/tableau_rest_api/tableau_rest_api_connection_28.py +++ b/tableau_rest_api/tableau_rest_api_connection_28.py @@ -192,7 +192,7 @@ def add_datasource_to_schedule(self, ds_name_or_luid, schedule_name_or_luid, pro tsr = etree.Element(u'tsRequest') t = etree.Element(u'task') er = etree.Element(u'extractRefresh') - d = etree.Element(u'dataasource') + d = etree.Element(u'datasource') d.set(u'id', ds_luid) er.append(d) t.append(er)