Skip to content

Commit

Permalink
Workbook update Description (tableau#1516)
Browse files Browse the repository at this point in the history
* Allows workbook updates to change the description starting with api version 3.21

* Fixes formatting

* Fixes style issues caused by using black and python version 3.13
  • Loading branch information
LehmD authored Nov 1, 2024
1 parent c3ea910 commit 3460528
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tableauserverclient/server/endpoint/workbooks_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def update(
if include_view_acceleration_status:
url += "?includeViewAccelerationStatus=True"

update_req = RequestFactory.Workbook.update_req(workbook_item)
update_req = RequestFactory.Workbook.update_req(workbook_item, self.parent_srv)
server_response = self.put_request(url, update_req)
logger.info(f"Updated workbook item (ID: {workbook_item.id})")
updated_workbook = copy.copy(workbook_item)
Expand Down
8 changes: 7 additions & 1 deletion tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def _generate_xml(
_add_hiddenview_element(views_element, view_name)
return ET.tostring(xml_request)

def update_req(self, workbook_item):
def update_req(self, workbook_item, parent_srv: Optional["Server"] = None):
xml_request = ET.Element("tsRequest")
workbook_element = ET.SubElement(xml_request, "workbook")
if workbook_item.name:
Expand All @@ -973,6 +973,12 @@ def update_req(self, workbook_item):
if workbook_item.owner_id:
owner_element = ET.SubElement(workbook_element, "owner")
owner_element.attrib["id"] = workbook_item.owner_id
if (
workbook_item.description is not None
and parent_srv is not None
and parent_srv.check_at_least_version("3.21")
):
workbook_element.attrib["description"] = workbook_item.description
if workbook_item._views is not None:
views_element = ET.SubElement(workbook_element, "views")
for view in workbook_item.views:
Expand Down

0 comments on commit 3460528

Please sign in to comment.