From 6d31b73b6fc51ec5c36096b5c1b151bebf44e3e0 Mon Sep 17 00:00:00 2001 From: Ranjith Guggilla Date: Sat, 21 Nov 2026 21:03:01 -0600 Subject: [PATCH] fix: send encryptExtracts when publishing a workbook The publish workbook method documents an optional encryptExtracts attribute, and TSC already sends it for data sources. A workbook had no way to set it, so publish could not choose extract encryption. --- tableauserverclient/models/workbook_item.py | 10 +++++++++- tableauserverclient/server/request_factory.py | 2 ++ test/test_workbook.py | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tableauserverclient/models/workbook_item.py b/tableauserverclient/models/workbook_item.py index 75ca0034e..9f4b1ec40 100644 --- a/tableauserverclient/models/workbook_item.py +++ b/tableauserverclient/models/workbook_item.py @@ -61,7 +61,10 @@ class as arguments. The workbook item specifies the project. User-defined description of the workbook. encrypt_extracts : bool | None - Indicates whether extracts are encrypted. + Set this before publishing to send ``encryptExtracts``. ``True`` encrypts + the workbook's extracts and ``False`` leaves them unencrypted. ``None`` + omits the attribute, which is also what a workbook parsed from the + server uses when the response does not include it. has_extracts : bool | None Indicates whether the workbook has extracts. @@ -357,6 +360,11 @@ def location(self) -> LocationItem | None: def encrypt_extracts(self) -> bool | None: return self._encrypt_extracts + @encrypt_extracts.setter + @property_is_boolean + def encrypt_extracts(self, value: bool) -> None: + self._encrypt_extracts = value + @property def default_view_id(self) -> str | None: return self._default_view_id diff --git a/tableauserverclient/server/request_factory.py b/tableauserverclient/server/request_factory.py index 517a26956..f416f7312 100644 --- a/tableauserverclient/server/request_factory.py +++ b/tableauserverclient/server/request_factory.py @@ -1070,6 +1070,8 @@ def _generate_xml( workbook_element.attrib["name"] = workbook_item.name if workbook_item.show_tabs: workbook_element.attrib["showTabs"] = str(workbook_item.show_tabs).lower() + if workbook_item.encrypt_extracts is not None: + workbook_element.attrib["encryptExtracts"] = str(workbook_item.encrypt_extracts).lower() project_element = ET.SubElement(workbook_element, "project") project_element.attrib["id"] = str(workbook_item.project_id) diff --git a/test/test_workbook.py b/test/test_workbook.py index c0965f121..109ab2ebc 100644 --- a/test/test_workbook.py +++ b/test/test_workbook.py @@ -884,6 +884,20 @@ def test_publish_file_object_of_unknown_type_raises_exception(server: TSC.Server server.workbooks.publish(new_workbook, file_object, server.PublishMode.CreateNew) +def test_publish_sends_encrypt_extracts_when_set(server: TSC.Server) -> None: + new_workbook = TSC.WorkbookItem(name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760") + omitted = RequestFactory.Workbook._generate_xml(new_workbook) + assert "encryptExtracts" not in fromstring(omitted).find("workbook").attrib + + new_workbook.encrypt_extracts = True + encrypted = RequestFactory.Workbook._generate_xml(new_workbook) + assert fromstring(encrypted).find("workbook").get("encryptExtracts") == "true" + + new_workbook.encrypt_extracts = False + plain = RequestFactory.Workbook._generate_xml(new_workbook) + assert fromstring(plain).find("workbook").get("encryptExtracts") == "false" + + def test_publish_multi_connection(server: TSC.Server) -> None: new_workbook = TSC.WorkbookItem(name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760") connection1 = TSC.ConnectionItem()