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
75 changes: 66 additions & 9 deletions tableauserverclient/server/endpoint/workbooks_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
from tableauserverclient.server import RequestFactory

from typing import (
Literal,
Optional,
TYPE_CHECKING,
TypeVar,
Union,
overload,
)
from collections.abc import Iterable, Sequence

Expand Down Expand Up @@ -383,16 +386,34 @@ def update_connections(
logger.info(f"Updated connections for workbook {workbook_item.id}: {', '.join(updated_ids)}")
return connection_items

T = TypeVar("T", bound=FileObjectW)

@overload
def download(
self,
workbook_id: str,
filepath: T,
include_extract: bool = True,
) -> T: ...

@overload
def download(
self,
workbook_id: str,
filepath: Optional[FilePath] = None,
include_extract: bool = True,
) -> str: ...

# Download workbook contents with option of passing in filepath
@api(version="2.0")
@parameter_added_in(no_extract="2.5")
@parameter_added_in(include_extract="2.5")
def download(
self,
workbook_id: str,
filepath: Optional[PathOrFileW] = None,
include_extract: bool = True,
) -> PathOrFileW:
workbook_id,
filepath=None,
include_extract=True,
):
"""
Downloads a workbook to the specified directory (optional).

Expand Down Expand Up @@ -741,6 +762,30 @@ def delete_permission(self, item: WorkbookItem, capability_item: PermissionsRule
"""
return self._permissions.delete(item, capability_item)

@overload
def publish(
self,
workbook_item: WorkbookItem,
file: PathOrFileR,
mode: str,
connections: Optional[Sequence[ConnectionItem]],
as_job: Literal[False],
skip_connection_check: bool,
parameters=None,
) -> WorkbookItem: ...

@overload
def publish(
self,
workbook_item: WorkbookItem,
file: PathOrFileR,
mode: str,
connections: Optional[Sequence[ConnectionItem]],
as_job: Literal[True],
skip_connection_check: bool,
parameters=None,
) -> JobItem: ...

@api(version="2.0")
@parameter_added_in(as_job="3.0")
@parameter_added_in(connections="2.8")
Expand Down Expand Up @@ -977,15 +1022,27 @@ def _get_workbook_revisions(
revisions = RevisionItem.from_response(server_response.content, self.parent_srv.namespace, workbook_item)
return revisions

T = TypeVar("T", bound=FileObjectW)

@overload
def download_revision(
self, workbook_id: str, revision_number: Optional[str], filepath: T, include_extract: bool
) -> T: ...

@overload
def download_revision(
self, workbook_id: str, revision_number: Optional[str], filepath: Optional[FilePath], include_extract: bool
) -> str: ...

# Download 1 workbook revision by revision number
@api(version="2.3")
def download_revision(
self,
workbook_id: str,
revision_number: Optional[str],
filepath: Optional[PathOrFileW] = None,
include_extract: bool = True,
) -> PathOrFileW:
workbook_id,
revision_number,
filepath,
include_extract=True,
):
"""
Downloads a workbook revision to the specified directory (optional).

Expand Down
Loading
Loading