Skip to content

Commit 7a7587d

Browse files
committed
chore: remove deprecated workbook publish arguments
1 parent 1b7eb9b commit 7a7587d

3 files changed

Lines changed: 0 additions & 124 deletions

File tree

tableauserverclient/server/endpoint/workbooks_endpoint.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -308,21 +308,12 @@ def publish(
308308
workbook_item: WorkbookItem,
309309
file: PathOrFileR,
310310
mode: str,
311-
connection_credentials: Optional["ConnectionCredentials"] = None,
312311
connections: Optional[Sequence[ConnectionItem]] = None,
313312
as_job: bool = False,
314313
hidden_views: Optional[Sequence[str]] = None,
315314
skip_connection_check: bool = False,
316315
parameters=None,
317316
):
318-
if connection_credentials is not None:
319-
import warnings
320-
321-
warnings.warn(
322-
"connection_credentials is being deprecated. Use connections instead",
323-
DeprecationWarning,
324-
)
325-
326317
if isinstance(file, (str, os.PathLike)):
327318
if not os.path.isfile(file):
328319
error = "File path does not lead to an existing file."
@@ -384,12 +375,9 @@ def publish(
384375
logger.info("Publishing {0} to server with chunking method (workbook over 64MB)".format(workbook_item.name))
385376
upload_session_id = self.parent_srv.fileuploads.upload(file)
386377
url = "{0}&uploadSessionId={1}".format(url, upload_session_id)
387-
conn_creds = connection_credentials
388378
xml_request, content_type = RequestFactory.Workbook.publish_req_chunked(
389379
workbook_item,
390-
connection_credentials=conn_creds,
391380
connections=connections,
392-
hidden_views=hidden_views,
393381
)
394382
else:
395383
logger.info("Publishing {0} to server".format(filename))
@@ -404,14 +392,11 @@ def publish(
404392
else:
405393
raise TypeError("file should be a filepath or file object.")
406394

407-
conn_creds = connection_credentials
408395
xml_request, content_type = RequestFactory.Workbook.publish_req(
409396
workbook_item,
410397
filename,
411398
file_contents,
412-
connection_credentials=conn_creds,
413399
connections=connections,
414-
hidden_views=hidden_views,
415400
)
416401
logger.debug("Request xml: {0} ".format(redact_xml(xml_request[:1000])))
417402

tableauserverclient/server/request_factory.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,7 @@ class WorkbookRequest(object):
881881
def _generate_xml(
882882
self,
883883
workbook_item,
884-
connection_credentials=None,
885884
connections=None,
886-
hidden_views=None,
887885
):
888886
xml_request = ET.Element("tsRequest")
889887
workbook_element = ET.SubElement(xml_request, "workbook")
@@ -893,12 +891,6 @@ def _generate_xml(
893891
project_element = ET.SubElement(workbook_element, "project")
894892
project_element.attrib["id"] = str(workbook_item.project_id)
895893

896-
if connection_credentials is not None and connections is not None:
897-
raise RuntimeError("You cannot set both `connections` and `connection_credentials`")
898-
899-
if connection_credentials is not None and connection_credentials != False:
900-
_add_credentials_element(workbook_element, connection_credentials)
901-
902894
if connections is not None and connections != False and len(connections) > 0:
903895
connections_element = ET.SubElement(workbook_element, "connections")
904896
for connection in connections:
@@ -907,17 +899,6 @@ def _generate_xml(
907899
if workbook_item.description is not None:
908900
workbook_element.attrib["description"] = workbook_item.description
909901

910-
if hidden_views is not None:
911-
import warnings
912-
913-
warnings.simplefilter("always", DeprecationWarning)
914-
warnings.warn(
915-
"the hidden_views parameter should now be set on the workbook directly",
916-
DeprecationWarning,
917-
)
918-
if workbook_item.hidden_views is None:
919-
workbook_item.hidden_views = hidden_views
920-
921902
if workbook_item.hidden_views is not None:
922903
views_element = ET.SubElement(workbook_element, "views")
923904
for view_name in workbook_item.hidden_views:
@@ -1000,15 +981,11 @@ def publish_req(
1000981
workbook_item,
1001982
filename,
1002983
file_contents,
1003-
connection_credentials=None,
1004984
connections=None,
1005-
hidden_views=None,
1006985
):
1007986
xml_request = self._generate_xml(
1008987
workbook_item,
1009-
connection_credentials=connection_credentials,
1010988
connections=connections,
1011-
hidden_views=hidden_views,
1012989
)
1013990

1014991
parts = {
@@ -1020,15 +997,11 @@ def publish_req(
1020997
def publish_req_chunked(
1021998
self,
1022999
workbook_item,
1023-
connection_credentials=None,
10241000
connections=None,
1025-
hidden_views=None,
10261001
):
10271002
xml_request = self._generate_xml(
10281003
workbook_item,
1029-
connection_credentials=connection_credentials,
10301004
connections=connections,
1031-
hidden_views=hidden_views,
10321005
)
10331006

10341007
parts = {"request_payload": ("", xml_request, "text/xml")}

test/test_workbook.py

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -621,31 +621,6 @@ def test_publish_with_hidden_views_on_workbook(self) -> None:
621621
self.assertTrue(re.search(rb"<views><view.*?hidden=\"true\".*?\/><\/views>", request_body))
622622
self.assertTrue(re.search(rb"<views><view.*?name=\"GDP per capita\".*?\/><\/views>", request_body))
623623

624-
# this tests the old method of including workbook views as a parameter for publishing
625-
# should be removed when that functionality is removed
626-
# see https://github.com/tableau/server-client-python/pull/617
627-
def test_publish_with_hidden_view(self) -> None:
628-
with open(PUBLISH_XML, "rb") as f:
629-
response_xml = f.read().decode("utf-8")
630-
with requests_mock.mock() as m:
631-
m.post(self.baseurl, text=response_xml)
632-
633-
new_workbook = TSC.WorkbookItem(
634-
name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760"
635-
)
636-
637-
sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx")
638-
publish_mode = self.server.PublishMode.CreateNew
639-
640-
new_workbook = self.server.workbooks.publish(
641-
new_workbook, sample_workbook, publish_mode, hidden_views=["GDP per capita"]
642-
)
643-
644-
request_body = m._adapter.request_history[0]._request.body
645-
# order of attributes in xml is unspecified
646-
self.assertTrue(re.search(rb"<views><view.*?hidden=\"true\".*?\/><\/views>", request_body))
647-
self.assertTrue(re.search(rb"<views><view.*?name=\"GDP per capita\".*?\/><\/views>", request_body))
648-
649624
def test_publish_with_query_params(self) -> None:
650625
with open(PUBLISH_ASYNC_XML, "rb") as f:
651626
response_xml = f.read().decode("utf-8")
@@ -775,63 +750,6 @@ def test_publish_multi_connection_flat(self) -> None:
775750
self.assertEqual(connection_results[1].get("serverAddress", None), "pgsql.test.com")
776751
self.assertEqual(connection_results[1].find("connectionCredentials").get("password", None), "secret") # type: ignore[union-attr]
777752

778-
def test_publish_single_connection(self) -> None:
779-
new_workbook = TSC.WorkbookItem(
780-
name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760"
781-
)
782-
connection_creds = TSC.ConnectionCredentials("test", "secret", True)
783-
784-
response = RequestFactory.Workbook._generate_xml(new_workbook, connection_credentials=connection_creds)
785-
# Can't use ConnectionItem parser due to xml namespace problems
786-
credentials = fromstring(response).findall(".//connectionCredentials")
787-
self.assertEqual(len(credentials), 1)
788-
self.assertEqual(credentials[0].get("name", None), "test")
789-
self.assertEqual(credentials[0].get("password", None), "secret")
790-
self.assertEqual(credentials[0].get("embed", None), "true")
791-
792-
def test_publish_single_connection_username_none(self) -> None:
793-
new_workbook = TSC.WorkbookItem(
794-
name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760"
795-
)
796-
connection_creds = TSC.ConnectionCredentials(None, "secret", True)
797-
798-
self.assertRaises(
799-
ValueError,
800-
RequestFactory.Workbook._generate_xml,
801-
new_workbook,
802-
connection_credentials=connection_creds,
803-
)
804-
805-
def test_publish_single_connection_username_empty(self) -> None:
806-
new_workbook = TSC.WorkbookItem(
807-
name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760"
808-
)
809-
connection_creds = TSC.ConnectionCredentials("", "secret", True)
810-
811-
response = RequestFactory.Workbook._generate_xml(new_workbook, connection_credentials=connection_creds)
812-
# Can't use ConnectionItem parser due to xml namespace problems
813-
credentials = fromstring(response).findall(".//connectionCredentials")
814-
self.assertEqual(len(credentials), 1)
815-
self.assertEqual(credentials[0].get("name", None), "")
816-
self.assertEqual(credentials[0].get("password", None), "secret")
817-
self.assertEqual(credentials[0].get("embed", None), "true")
818-
819-
def test_credentials_and_multi_connect_raises_exception(self) -> None:
820-
new_workbook = TSC.WorkbookItem(
821-
name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760"
822-
)
823-
824-
connection_creds = TSC.ConnectionCredentials("test", "secret", True)
825-
826-
connection1 = TSC.ConnectionItem()
827-
connection1.server_address = "mysql.test.com"
828-
connection1.connection_credentials = TSC.ConnectionCredentials("test", "secret", True)
829-
830-
with self.assertRaises(RuntimeError):
831-
response = RequestFactory.Workbook._generate_xml(
832-
new_workbook, connection_credentials=connection_creds, connections=[connection1]
833-
)
834-
835753
def test_synchronous_publish_timeout_error(self) -> None:
836754
with requests_mock.mock() as m:
837755
m.register_uri("POST", self.baseurl, status_code=504)

0 commit comments

Comments
 (0)