Skip to content

Commit

Permalink
Implemented hidding views at Publish time from 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryant Howell committed Apr 16, 2019
1 parent 6f31081 commit 1c8e99f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
12 changes: 11 additions & 1 deletion tableau_rest_api/tableau_rest_api_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
33 changes: 33 additions & 0 deletions tableau_rest_api/tableau_rest_api_connection_32.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
3 changes: 2 additions & 1 deletion tableau_rest_api/tableau_rest_api_connection_33.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 1c8e99f

Please sign in to comment.