Created
July 12, 2017 19:28
-
-
Save erichannell/0eab577a88a33caf1b93853fbff5fb70 to your computer and use it in GitHub Desktop.
migrate users between servers
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
# -*- coding: utf-8 -*- | |
import tableauserverclient as TSC | |
# migrate from | |
site = "" | |
user = "" | |
pwd = "" | |
tableau_auth = TSC.TableauAuth(user, pwd, site_id=site) | |
server = TSC.Server('https://dub01.online.tableau.com') | |
users_to_migrate = [] | |
print "migrating users from:", site | |
print '*' * 25 | |
with server.auth.sign_in(tableau_auth): | |
# get a list of all users | |
all_users, pagination_item = server.users.get() | |
print "There are {} user on site".format(pagination_item.total_available) | |
for i, user in enumerate(all_users): | |
print "{} {} ({})".format(i + 1, user.name, user.site_role) | |
# skip the admin | |
if 'Administrator' not in user.site_role: | |
users_to_migrate.append(user) | |
print "migrating {} users (skipping admins)".format(len(users_to_migrate)) | |
print '*' * 25 | |
# migrate to | |
site = "" | |
user = "" | |
pwd = "" | |
print "migrating users to:", site | |
tableau_auth = TSC.TableauAuth(user, pwd, site_id=site) | |
server = TSC.Server('https://dub01.online.tableau.com') | |
with server.auth.sign_in(tableau_auth): | |
for i, user in enumerate(users_to_migrate): | |
# create user | |
new_user = TSC.UserItem(user.name, 'Viewer') | |
# add new user | |
new_user = server.users.add(new_user) | |
print "{} {} ({})".format(i+1, new_user.name, new_user.site_role) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment