Skip to content

Commit

Permalink
feat: add description support on wb publish
Browse files Browse the repository at this point in the history
  • Loading branch information
jorwoods committed Feb 15, 2024
1 parent 7631abb commit 0ddae7c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tableauserverclient/models/workbook_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def created_at(self) -> Optional[datetime.datetime]:
def description(self) -> Optional[str]:
return self._description

@description.setter
def description(self, value: str):
self._description = value

@property
def id(self) -> Optional[str]:
return self._id
Expand Down
3 changes: 3 additions & 0 deletions tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ def _generate_xml(
for connection in connections:
_add_connections_element(connections_element, connection)

if workbook_item.description is not None:
workbook_element.attrib["description"] = workbook_item.description

if hidden_views is not None:
import warnings

Expand Down
4 changes: 2 additions & 2 deletions test/assets/workbook_publish.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.3.xsd">
<workbook id="a8076ca1-e9d8-495e-bae6-c684dbb55836" name="RESTAPISample" contentUrl="RESTAPISample_0" showTabs="false" size="1" createdAt="2016-08-18T18:33:24Z" updatedAt="2016-08-18T20:31:34Z">
<workbook id="a8076ca1-e9d8-495e-bae6-c684dbb55836" name="RESTAPISample" contentUrl="RESTAPISample_0" showTabs="false" size="1" createdAt="2016-08-18T18:33:24Z" updatedAt="2016-08-18T20:31:34Z" description="REST API Testing">
<project id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760" name="default" />
<owner id="5de011f8-5aa9-4d5b-b991-f462c8dd6bb7" />
<tags />
<views>
<view id="fe0b4e89-73f4-435e-952d-3a263fbfa56c" name="GDP per capita" contentUrl="RESTAPISample_0/sheets/GDPpercapita" />
</views>
</workbook>
</tsResponse>
</tsResponse>
3 changes: 3 additions & 0 deletions test/test_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ def test_publish(self) -> None:
name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760"
)

new_workbook.description = "REST API Testing"

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

Expand All @@ -506,6 +508,7 @@ def test_publish(self) -> None:
self.assertEqual("fe0b4e89-73f4-435e-952d-3a263fbfa56c", new_workbook.views[0].id)
self.assertEqual("GDP per capita", new_workbook.views[0].name)
self.assertEqual("RESTAPISample_0/sheets/GDPpercapita", new_workbook.views[0].content_url)
self.assertEqual("REST API Testing", new_workbook.description)

def test_publish_a_packaged_file_object(self) -> None:
with open(PUBLISH_XML, "rb") as f:
Expand Down

0 comments on commit 0ddae7c

Please sign in to comment.