diff --git a/tableau_rest_api/tableau_rest_api_connection.py b/tableau_rest_api/tableau_rest_api_connection.py index 4c64179..d9e7531 100644 --- a/tableau_rest_api/tableau_rest_api_connection.py +++ b/tableau_rest_api/tableau_rest_api_connection.py @@ -2341,7 +2341,7 @@ def publish_datasource(self, ds_filename, ds_name, project_obj, overwrite=False, def publish_content(self, content_type, content_filename, content_name, project_luid, url_params=None, connection_username=None, connection_password=None, save_credentials=True, show_tabs=False, check_published_ds=True, oauth_flag=False, generate_thumbnails_as_username_or_luid=None, - description=None): + description=None, views_to_hide_list=None): # Single upload limit in MB single_upload_limit = 20 @@ -2414,6 +2414,16 @@ def publish_content(self, content_type, content_filename, content_name, project_ cc.set(u'embed', str(save_credentials).lower()) t1.append(cc) + # Views to Hide in Workbooks from 3.2 + if views_to_hide_list is not None: + if len(views_to_hide_list) > 0: + vs = etree.Element(u'views') + for view_name in views_to_hide_list: + v = etree.Element(u'view') + v.set(u'name', view_name) + v.set(u'hidden', u'true') + t1.append(vs) + # Description only allowed for Flows as of 3.3 if description is not None: t1.set(u'description', description) diff --git a/tableau_rest_api/tableau_rest_api_connection_32.py b/tableau_rest_api/tableau_rest_api_connection_32.py index bdcca14..abae737 100644 --- a/tableau_rest_api/tableau_rest_api_connection_32.py +++ b/tableau_rest_api/tableau_rest_api_connection_32.py @@ -97,3 +97,36 @@ def delete_user_from_data_driven_alert(self, data_alert_luid, username_or_luid): self.send_delete_request(url) self.end_log_block() + # In 3.2, you can hide views from publishing + def publish_workbook(self, workbook_filename, workbook_name, project_obj, overwrite=False, async_publish=False, connection_username=None, + connection_password=None, save_credentials=True, show_tabs=True, check_published_ds=True, + oauth_flag=False, views_to_hide_list=None): + """ + :type workbook_filename: unicode + :type workbook_name: unicode + :type project_obj: Project20 or Project21 + :type overwrite: bool + :type connection_username: unicode + :type connection_password: unicode + :type save_credentials: bool + :type show_tabs: bool + :param check_published_ds: Set to False to improve publish speed if you KNOW there are no published data sources + :type check_published_ds: bool + :type oauth_flag: bool: + :type views_to_hide_list: list[unicode] + : + :rtype: unicode + """ + + project_luid = project_obj.luid + xml = self.publish_content(u'workbook', workbook_filename, workbook_name, project_luid, + {u"overwrite": overwrite, u"asJob": async_publish}, connection_username, + connection_password, save_credentials, show_tabs=show_tabs, + check_published_ds=check_published_ds, oauth_flag=oauth_flag, + views_to_hide_list=views_to_hide_list) + if async_publish is True: + job = xml.findall(u'.//t:job', self.ns_map) + return job[0].get(u'id') + else: + workbook = xml.findall(u'.//t:workbook', self.ns_map) + return workbook[0].get(u'id') diff --git a/tableau_rest_api/tableau_rest_api_connection_33.py b/tableau_rest_api/tableau_rest_api_connection_33.py index a9c450a..9a8b138 100644 --- a/tableau_rest_api/tableau_rest_api_connection_33.py +++ b/tableau_rest_api/tableau_rest_api_connection_33.py @@ -14,7 +14,7 @@ def __init__(self, server, username, password, site_content_url=u""): def publish_workbook(self, workbook_filename, workbook_name, project_obj, overwrite=False, async_publish=False, connection_username=None, connection_password=None, save_credentials=True, show_tabs=True, check_published_ds=True, - oauth_flag=False, generate_thumbnails_as_username_or_luid=None): + oauth_flag=False, views_to_hide_list=None, generate_thumbnails_as_username_or_luid=None): """ :type workbook_filename: unicode :type workbook_name: unicode @@ -36,6 +36,7 @@ def publish_workbook(self, workbook_filename, workbook_name, project_obj, overwr {u"overwrite": overwrite, u"asJob": async_publish}, connection_username, connection_password, save_credentials, show_tabs=show_tabs, check_published_ds=check_published_ds, oauth_flag=oauth_flag, + views_to_hide_list=views_to_hide_list, generate_thumbnails_as_username_or_luid=generate_thumbnails_as_username_or_luid) if async_publish is True: job = xml.findall(u'.//t:job', self.ns_map)