Skip to content

Commit

Permalink
feat: publish datasource as replacement (#1546)
Browse files Browse the repository at this point in the history
* Add "Replace" to publish type enum
  • Loading branch information
jacalata authored Dec 30, 2024
1 parent 9ba445b commit 28952e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tableauserverclient/server/endpoint/datasources_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ def publish(
else:
raise TypeError("file should be a filepath or file object.")

if not mode or not hasattr(self.parent_srv.PublishMode, mode):
error = "Invalid mode defined."
raise ValueError(error)

# Construct the url with the defined mode
url = f"{self.baseurl}?datasourceType={file_extension}"
if mode == self.parent_srv.PublishMode.Overwrite or mode == self.parent_srv.PublishMode.Append:
if not mode or not hasattr(self.parent_srv.PublishMode, mode):
error = f"Invalid mode defined: {mode}"
raise ValueError(error)
else:
url += f"&{mode.lower()}=true"

if as_job:
Expand Down
1 change: 1 addition & 0 deletions tableauserverclient/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class PublishMode:
Append = "Append"
Overwrite = "Overwrite"
CreateNew = "CreateNew"
Replace = "Replace"

def __init__(self, server_address, use_server_version=False, http_options=None, session_factory=None):
self._auth_token = None
Expand Down

0 comments on commit 28952e4

Please sign in to comment.