forked from bryanthowell-tableau/tableau_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating samples to reflect new realities. Updating README to clarify…
… the new syntax for imports
- Loading branch information
Bryant Howell
committed
Dec 7, 2019
1 parent
8fb5a35
commit 648496c
Showing
9 changed files
with
93 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from tableau_tools.tableau_rest_api import * | ||
# from tableau_tools.tableau_rest_api import * | ||
from tableau_tools import * | ||
import os | ||
|
||
|
||
def archive_tableau_site(save_to_directory, server, username, password, site_content_url): | ||
# The last two digits of this constructor match to the version of API available on the Tableau Server | ||
t = TableauRestApiConnection30(server=server, username=username, | ||
t = TableauServerRest33(server=server, username=username, | ||
password=password, site_content_url=site_content_url) | ||
t.signin() | ||
all_projects = t.query_projects() | ||
all_projects = t.projects.query_projects() | ||
all_projects_dict = t.convert_xml_list_to_name_id_dict(all_projects) | ||
|
||
# This gives you the Project name; the values of the dict are the LUIDs | ||
for project in all_projects_dict: | ||
# Create directory for projects | ||
try: | ||
print(('Making directory {}'.format(project))) | ||
print('Making directory {}'.format(project)) | ||
os.mkdir('{}/{}'.format(save_to_directory, project)) | ||
except OSError as e: | ||
print('Directory already exists') | ||
|
||
print(('Downloading datasources for project {}'.format(project))) | ||
print('Downloading datasources for project {}'.format(project)) | ||
# Get All Data sources | ||
dses_in_project = t.query_datasources(project_name_or_luid=all_projects_dict[project]) | ||
dses_in_project = t.datasources.query_datasources(project_name_or_luid=all_projects_dict[project]) | ||
for ds in dses_in_project: | ||
ds_luid = ds.get('id') | ||
ds_content_url = ds.get('contentUrl') | ||
print(('Downloading datasource {}'.format(ds_content_url))) | ||
t.download_datasource(ds_name_or_luid=ds_luid, | ||
print('Downloading datasource {}'.format(ds_content_url)) | ||
t.datasources.download_datasource(ds_name_or_luid=ds_luid, | ||
filename_no_extension="{}/{}/{}".format(save_to_directory, project, ds_content_url), | ||
include_extract=False) | ||
|
||
print(('Downloading workbooks for project {}'.format(project))) | ||
wbs_in_project = t.query_workbooks_in_project(project_name_or_luid=all_projects_dict[project]) | ||
print('Downloading workbooks for project {}'.format(project)) | ||
wbs_in_project = t.workbooks.query_workbooks_in_project(project_name_or_luid=all_projects_dict[project]) | ||
for wb in wbs_in_project: | ||
wb_luid = wb.get('id') | ||
wb_content_url = wb.get('contentUrl') | ||
print(('Downloading workbook {}'.format(wb_content_url))) | ||
t.download_workbook(wb_name_or_luid=wb_luid, | ||
t.workbooks.download_workbook(wb_name_or_luid=wb_luid, | ||
filename_no_extension="{}/{}/{}".format(save_to_directory, project, wb_content_url), | ||
include_extract=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
examples/extract_api_samples.py → examples/hyper_api_samples.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.