diff --git a/samples/publish_workbook.py b/samples/publish_workbook.py index be2c9599f..ca366cf9e 100644 --- a/samples/publish_workbook.py +++ b/samples/publish_workbook.py @@ -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() @@ -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." diff --git a/tableauserverclient/server/endpoint/workbooks_endpoint.py b/tableauserverclient/server/endpoint/workbooks_endpoint.py index 62f94f99a..e40d9e1dd 100644 --- a/tableauserverclient/server/endpoint/workbooks_endpoint.py +++ b/tableauserverclient/server/endpoint/workbooks_endpoint.py @@ -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: @@ -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)) diff --git a/test/test_workbook.py b/test/test_workbook.py index f14e4d96f..fc1344b9e 100644 --- a/test/test_workbook.py +++ b/test/test_workbook.py @@ -544,6 +544,28 @@ def test_publish_with_hidden_view(self): self.assertTrue(re.search(rb'<\/views>', request_body)) self.assertTrue(re.search(rb'<\/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