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
23 changes: 23 additions & 0 deletions tableauserverclient/server/endpoint/views_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,29 @@ def update(self, view_item: ViewItem) -> ViewItem:
# Returning view item to stay consistent with datasource/view update functions
return view_item

@api(version="3.27")
def delete(self, view: ViewItem | str) -> None:
"""
Deletes a view in a workbook. If you delete the only view in a workbook,
the workbook is deleted. Can be used to remove hidden views when
republishing or migrating to a different environment.

REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooks_and_views.htm#delete_view

Parameters
----------
view: ViewItem | str
The ViewItem or the luid for the view to be deleted.

Returns
-------
None
"""
id_ = getattr(view, "id", view)
self.delete_request(f"{self.baseurl}/{id_}")
logger.info(f"View({id_}) deleted.")
return None

@api(version="1.0")
def add_tags(self, item: Union[ViewItem, str], tags: Union[Iterable[str], str]) -> set[str]:
"""
Expand Down
3 changes: 2 additions & 1 deletion test/test_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,8 @@ def test_publish_description(server: TSC.Server) -> None:
ds_elem = body.find(".//datasource")
assert ds_elem is not None
assert ds_elem.attrib["description"] == "Sample description"



def test_get_datasource_no_owner(server: TSC.Server) -> None:
with requests_mock.mock() as m:
m.get(server.datasources.baseurl, text=GET_NO_OWNER.read_text())
Expand Down
Loading
Loading