10000 Add publish samples attribute by jacalata · Pull Request #1264 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Add publish samples attribute #1264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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
9 changes: 8 additions & 1 deletion samples/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ def main():
server.use_server_version()

# Without parent_id specified, projects are created at the top level.
top_level_project = TSC.ProjectItem(name="Top Level Project")
# With the publish-samples attribute, the project will be created with sample items
top_level_project = TSC.ProjectItem(
name="Top Level Project",
description="A sample tsc project",
content_permissions=None,
parent_id=None,
samples=True,
)
top_level_project = create_project(server, top_level_project)

# Specifying parent_id creates a nested projects.
Expand Down
2 changes: 2 additions & 0 deletions tableauserverclient/models/project_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ def __init__(
description: Optional[str] = None,
content_permissions: Optional[str] = None,
parent_id: Optional[str] = None,
samples: Optional[bool] = None,
) -> None:
self._content_permissions = None
self._id: Optional[str] = None
self.description: Optional[str] = description
self.name: str = name
self.content_permissions: Optional[str] = content_permissions
self.parent_id: Optional[str] = parent_id
self._samples: Optional[bool] = samples

self._permissions = None
self._default_workbook_permissions = None
Expand Down
2 changes: 2 additions & 0 deletions tableauserverclient/server/endpoint/projects_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def update(self, project_item: ProjectItem, samples: bool = False) -> ProjectIte
def create(self, project_item: ProjectItem, samples: bool = False) -> ProjectItem:
params = {"params": {RequestOptions.Field.PublishSamples: samples}}
url = self.baseurl
if project_item._samples:
url = "{0}?publishSamples={1}".format(self.baseurl, project_item._samples)
create_req = RequestFactory.Project.create_req(project_item)
server_response = self.post_request(url, create_req, XML_CONTENT_TYPE, params)
new_project = ProjectItem.from_response(server_response.content, self.parent_srv.namespace)[0]
Expand Down
0