Skip to content
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
long_description=readme,
long_description_content_type='text/markdown',
name="tableau_utilities",
version="2.2.12",
version="2.2.13",
requires_python=">=3.8",
packages=[
'tableau_utilities',
Expand Down
11 changes: 7 additions & 4 deletions tableau_utilities/tableau_server/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,27 @@ def view(self, view_id):
v = v['view']
return tso.View(**v)

def projects(self, top_level_only=True):
def projects(self, top_level_only=True, include_extra_fields=True):
""" Queries for all projects in the site
URI GET /api/api-version/sites/site-id/projects
Args:
top_level_only (bool): True to only get top level projects
include_extra_fields (bool): True to include extra fields not provided in the default query
Returns: All top level projects in the site
"""
url = f"{self.url}/projects?fields=_default_" \
if include_extra_fields:
url = f"{self.url}/projects?fields=_default_" \
f",topLevelProject" \
f",writeable" \
f",contentsCounts.projectCount" \
f",contentsCounts.viewCount" \
f",contentsCounts.datasourceCount" \
f",contentsCounts.workbookCount"
else:
url = f"{self.url}/projects"
for p in self.__get_objects_pager(url, 'project'):
project = tso.Project(**p)
# Only get Top Level projects
if top_level_only and not project.top_level_project:
if top_level_only and project.parent_project_id:
continue
yield project

Expand Down
8 changes: 4 additions & 4 deletions tableau_utilities/tableau_server/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def __get_datasource_for_publication(self, datasource_id, datasource_name, proje
return self.get.datasource(datasource_id)
elif datasource_name and project_name:
project = None
for p in self.get.projects():
for p in self.get.projects(False, False):
if p.name == project_name:
project = p
break
if not project:
raise TableauConnectionError(f'Project does not exist: {project}')
raise TableauConnectionError(f'Project does not exist: {project_name}')
return tso.Datasource(
name=datasource_name,
project_id=project.id,
Expand All @@ -58,12 +58,12 @@ def __get_workbook_for_publication(self, workbook_id, workbook_name, project_nam
return self.get.workbook(workbook_id)
elif workbook_name and project_name:
project = None
for p in self.get.projects():
for p in self.get.projects(False, False):
if p.name == project_name:
project = p
break
if not project:
raise TableauConnectionError(f'Project does not exist: {project}')
raise TableauConnectionError(f'Project does not exist: {project_name}')
return tso.Workbook(
name=workbook_name,
project_id=project.id,
Expand Down
Loading