Skip to content
Open
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
10 changes: 9 additions & 1 deletion tableauserverclient/models/workbook_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions test/test_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down