Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions samples/publish_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def main():
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
help='desired logging level (set to error by default)')
parser.add_argument('--as-job', '-a', help='Publishing asynchronously', action='store_true')
parser.add_argument('--skip-connection-check', '-c', help='Skip live connection check', action='store_true')
parser.add_argument('--site', '-S', default='', help='id (contentUrl) of site to sign into')

args = parser.parse_args()
Expand Down Expand Up @@ -71,11 +72,13 @@ def main():
new_workbook = TSC.WorkbookItem(default_project.id)
if args.as_job:
new_job = server.workbooks.publish(new_workbook, args.filepath, overwrite_true,
connections=all_connections, as_job=args.as_job)
connections=all_connections, as_job=args.as_job,
skip_connection_check=args.skip_connection_check)
print("Workbook published. JOB ID: {0}".format(new_job.id))
else:
new_workbook = server.workbooks.publish(new_workbook, args.filepath, overwrite_true,
connections=all_connections, as_job=args.as_job)
connections=all_connections, as_job=args.as_job,
skip_connection_check=args.skip_connection_check)
print("Workbook published. ID: {0}".format(new_workbook.id))
else:
error = "The default project could not be found."
Expand Down
5 changes: 4 additions & 1 deletion tableauserverclient/server/endpoint/workbooks_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def delete_permission(self, item, capability_item):
def publish(
self, workbook_item, file, mode,
connection_credentials=None, connections=None, as_job=False,
hidden_views=None
hidden_views=None, skip_connection_check=False
):

if connection_credentials is not None:
Expand Down Expand Up @@ -318,6 +318,9 @@ def publish(
if as_job:
url += '&{0}=true'.format('asJob')

if skip_connection_check:
url += '&{0}=true'.format('skipConnectionCheck')

# Determine if chunking is required (64MB is the limit for single upload method)
if file_size >= FILESIZE_LIMIT:
logger.info('Publishing {0} to server with chunking method (workbook over 64MB)'.format(workbook_item.name))
Expand Down
22 changes: 22 additions & 0 deletions test/test_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,28 @@ def test_publish_with_hidden_view(self):
self.assertTrue(re.search(rb'<views><view.*?hidden=\"true\".*?\/><\/views>', request_body))
self.assertTrue(re.search(rb'<views><view.*?name=\"GDP per capita\".*?\/><\/views>', request_body))

def test_publish_with_query_params(self):
with open(PUBLISH_ASYNC_XML, 'rb') as f:
response_xml = f.read().decode('utf-8')
with requests_mock.mock() as m:
m.post(self.baseurl, text=response_xml)

new_workbook = TSC.WorkbookItem(name='Sample',
show_tabs=False,
project_id='ee8c6e70-43b6-11e6-af4f-f7b0d8e20760')

sample_workbook = os.path.join(TEST_ASSET_DIR, 'SampleWB.twbx')
publish_mode = self.server.PublishMode.CreateNew

self.server.workbooks.publish(new_workbook, sample_workbook, publish_mode,
as_job=True, skip_connection_check=True)

request_query_params = m._adapter.request_history[0].qs
self.assertTrue('asjob' in request_query_params)
self.assertTrue(request_query_params['asjob'])
self.assertTrue('skipconnectioncheck' in request_query_params)
self.assertTrue(request_query_params['skipconnectioncheck'])

def test_publish_async(self):
self.server.version = '3.0'
baseurl = self.server.workbooks.baseurl
Expand Down