8000 do not allow update on workbooks/projects when site is disabled for m… · gmiretti/server-client-python@6a7a065 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a7a065

Browse files
author
bzhang
committed
do not allow update on workbooks/projects when site is disabled for materialized views
1 parent 440b6cf commit 6a7a065

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

samples/materialize_workbooks.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def main():
1010
parser.add_argument('--server', '-s', required=True, help='Tableau server address')
1111
parser.add_argument('--username', '-u', required=True, help='username to sign into server')
1212
parser.add_argument('--password', '-p', required=False, help='password to sign into server')
13-
# TODO: for workbook, only disable and enable
1413
parser.add_argument('--mode', '-m', required=False, choices=['disable', 'enable', 'enable_all', 'enable_selective'],
1514
help='enable/disable materialized views for sites/workbooks')
1615
parser.add_argument('--status', '-st', required=False, action='store_true',
@@ -134,6 +133,8 @@ def update_project_by_path(args, materialized_views_mode, password, site_content
134133
server = TSC.Server(args.server, use_server_version=True)
135134
project_name = args.project_path.split('/')[-1]
136135
with server.auth.sign_in(tableau_auth):
136+
if not assert_site_enabled_for_materialized_views(server, site_content_url):
137+
return False
137138
projects = [project for project in TSC.Pager(server.projects) if project.name == project_name]
138139

139140
possible_paths = get_project_paths(server, projects)
@@ -148,6 +149,8 @@ def update_project_by_name(args, materialized_views_config, password, site_conte
148149
tableau_auth = TSC.TableauAuth(args.username, password, site_content_url)
149150
server = TSC.Server(args.server, use_server_version=True)
150151
with server.auth.sign_in(tableau_auth):
152+
if not assert_site_enabled_for_materialized_views(server, site_content_url):
153+
return False
151154
# get all projects with given name
152155
projects = [project for project in TSC.Pager(server.projects) if project.name == args.project_name]
153156

@@ -191,6 +194,8 @@ def update_workbook(args, materialized_views_config, password, site_content_url)
191194
tableau_auth = TSC.TableauAuth(args.username, password, site_id=site_content_url)
192195
server = TSC.Server(args.server, use_server_version=True)
193196
with server.auth.sign_in(tableau_auth):
197+
if not assert_site_enabled_for_materialized_views(server, site_content_url):
198+
return False
194199
if args.path_list is not None:
195200
workbook_path_mapping = parse_workbook_path(args.path_list)
196201
all_projects = {project.id: project for project in TSC.Pager(server.projects)}
@@ -273,5 +278,14 @@ def assert_options_valid(args):
273278
return False
274279
return True
275280

281+
282+
def assert_site_enabled_for_materialized_views(server, site_content_url):
283+
parent_site = server.sites.get_by_content_url(site_content_url)
284+
if parent_site.materialized_views_mode == "disable":
285+
print('Cannot update workbook/project because site is disabled for materialized views')
286+
return False
287+
return True
288+
289+
276290
if __name__ == "__main__":
277291
main()

0 commit comments

Comments
 (0)
0