How to print projects and workbook names based on site id in tableau server client

883 Views Asked by At
     SIGN IN
    tableau_auth = TSC.TableauAuth(args.username, password, args.site)
    server = TSC. Server(args.server, use_server_version=True)
    with server.auth.sign_in(tableau_auth):
        print("Your server contains the following sites:")
        for site in TSC.Pager(server.sites.get):
            print(site.name)
        i=input("Enter the site name :")
        print(i)
    for project in TSC.Pager(server.sites.projects.get):
        print(project.name)

In Tableau server client i can able to print the site id based on the site id i need to print project and workbook.In the above code the user get the list of siteid's belongs to his role the user select the site id and i have stored in object "i" based on the site name how can i drill down to project and workbook.

1

There are 1 best solutions below

1
On

Here is how I do it after I have my site_id

auth = TSC.TableauAuth('username', 'password', site_id=i)
server = TSC.Server(serverAddress) 
with server.auth.sign_in(auth):
    all_project_items, pagination_item = server.projects.get()
    for proj in all_project_items:
        print(proj.id)

    all_workbooks, pagination_item = server.workbooks.get()
    for workbook in all_workbooks:
        print(workbook.name)