### Install Dependencies and Run Tests Source: https://tableau.github.io/server-client-python/docs/dev-guide Install project dependencies, including testing tools, and run the test suite to ensure a healthy environment. ```bash python -m pip install --upgrade pip pip install -e .[test] build pytest test ``` -------------------------------- ### Create Daily Schedule Source: https://tableau.github.io/server-client-python/docs/api-ref Example of creating a daily schedule that runs every day at 12:30 AM. ```APIDOC ## Create Daily Schedule ### Description Creates a daily schedule with a specified start time. ### Method `server.schedules.create(schedule_item)` ### Parameters - `schedule_item` (TSC.ScheduleItem) - The schedule item object to create. ### Request Example ```python import tableauserverclient as TSC from datetime import time # Create a daily interval to run every day at 12:30AM daily_interval = TSC.DailyInterval(start_time=time(0, 30)) # Create schedule item using daily interval daily_schedule = TSC.ScheduleItem("Daily-Schedule", 60, TSC.ScheduleItem.Type.Subscription, TSC.ScheduleItem.ExecutionOrder.Serial, daily_interval) # Create daily schedule daily_schedule = server.schedules.create(daily_schedule) ``` ``` -------------------------------- ### Create Monthly Schedule Source: https://tableau.github.io/server-client-python/docs/api-ref Example of creating a monthly schedule that runs on the 15th of every month at 11:30 PM. ```APIDOC ## Create Monthly Schedule ### Description Creates a monthly schedule with a specified start time and interval value (day of the month). ### Method `server.schedules.create(schedule_item)` ### Parameters - `schedule_item` (TSC.ScheduleItem) - The schedule item object to create. ### Request Example ```python import tableauserverclient as TSC from datetime import time # Create a monthly interval to run on the 15th of every month at 11:30PM monthly_interval = TSC.MonthlyInterval(start_time=time(23, 30), interval_value=15) # Create schedule item using monthly interval monthly_schedule = TSC.ScheduleItem("Monthly-Schedule", 80, TSC.ScheduleItem.Type.Subscription TSC.ScheduleItem.ExecutionOrder.Parallel, monthly_interval) # Create monthly schedule monthly_schedule = server.schedules.create(monthly_schedule) ``` ``` -------------------------------- ### Get All Tableau Data Sources Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves all data sources on the Tableau Server site. To get connection details for each data source, use the populate_connections method. This example demonstrates signing in, retrieving all datasources, and printing their names. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD') server = TSC.Server('https://SERVERURL') with server.auth.sign_in(tableau_auth): all_datasources, pagination_item = server.datasources.get() print("\nThere are {} datasources on site: ".format(pagination_item.total_available)) print([datasource.name for datasource in all_datasources]) ``` -------------------------------- ### Create Weekly Schedule Source: https://tableau.github.io/server-client-python/docs/api-ref Example of creating a weekly schedule that runs every Monday, Wednesday, and Friday at 7:15 PM. ```APIDOC ## Create Weekly Schedule ### Description Creates a weekly schedule with a specified start time and days of the week. ### Method `server.schedules.create(schedule_item)` ### Parameters - `schedule_item` (TSC.ScheduleItem) - The schedule item object to create. ### Request Example ```python import tableauserverclient as TSC from datetime import time # Create a weekly interval to run every Monday, Wednesday, and Friday at 7:15PM weekly_interval = TSC.WeeklyInterval(time(19, 15), TSC.IntervalItem.Day.Monday, TSC.IntervalItem.Day.Wednesday, TSC.IntervalItem.Day.Friday) # Create schedule item using weekly interval weekly_schedule = TSC.ScheduleItem("Weekly-Schedule", 70, TSC.ScheduleItem.Type.Extract, TSC.ScheduleItem.ExecutionOrder.Serial, weekly_interval) # Create weekly schedule weekly_schedule = server.schedules.create(weekly_schedule) ``` ``` -------------------------------- ### ProjectItem Content Permissions Examples Source: https://tableau.github.io/server-client-python/docs/api-ref Demonstrates how to use the ProjectItem.ContentPermissions enum to set content permissions for a project. Options include LockedToProject, ManagedByOwner, and LockedToProjectWithoutNested. ```python # import tableauserverclient as TSC # server = TSC.Server('https://MY-SERVER') # sign in, etc locked_true = TSC.ProjectItem.ContentPermissions.LockedToProject print(locked_true) # prints 'LockedToProject' by_owner = TSC.ProjectItem.ContentPermissions.ManagedByOwner print(by_owner) # prints 'ManagedByOwner' # pass the content_permissions to new instance of the project item. new_project = TSC.ProjectItem(name='My Project', content_permissions=by_owner, description='Project example') ``` -------------------------------- ### Display Site Configuration Details Source: https://tableau.github.io/server-client-python/docs/api-ref Iterates through a list of authentication configurations and prints their details. This is useful for understanding the current authentication setup for a site. ```python for config in auth_configs: print(f"ID: {config.idp_configuration_id}") print(f"Name: {config.idp_configuration_name}") print(f"Type: {config.auth_setting}") print(f"Enabled: {config.enabled}") print(f"Provider: {config.known_provider_alias}") ``` -------------------------------- ### Sign in, perform operations, and sign out with JWT Source: https://tableau.github.io/server-client-python/docs/sign-in-out This example demonstrates the complete workflow of signing in with a JWT, performing actions on the server, and then signing out to end the session. ```python import tableauserverclient as TSC # Connected App JWT tableau_auth = TSC.JWTAuth(jwt='JWT', site_id='SITENAME') # UAT JWT tableau_auth = TSC.JWTAuth(jwt='JWT', site_id='SITENAME', isUat=True) server = TSC.Server('https://SERVER_URL', use_server_version=True) server.auth.sign_in(tableau_auth) # Do awesome things here! server.auth.sign_out() ``` -------------------------------- ### Install TSC from Development Branch Source: https://tableau.github.io/server-client-python/docs Installs the development version of TSC from GitHub for previewing upcoming features. This version is not recommended for production due to potential changes. ```bash pip install git+https://github.com/tableau/server-client-python.git@development ``` -------------------------------- ### Server Class Initialization and Usage Source: https://tableau.github.io/server-client-python/docs/api-ref Instantiate the Server class with the server address and optionally set the REST API version. The example shows how to create a server instance, sign in, and use `use_server_version()` or manually set the version. ```APIDOC ## Server Class ```python Server(server_address) ``` The `Server` class contains the attributes that represent the server on Tableau Server. After you create an instance of the `Server` class, you can sign in to the server and call methods to access all of the resources on the server. ### Attributes Attribute | Description ---|--- `server_address` | Specifies the address of the Tableau Server or Tableau Cloud (for example, `https://MY-SERVER/`). `version` | Specifies the version of the REST API to use (for example, `'2.5'`). When you use the TSC library to call methods that access Tableau Server, the `version` is passed to the endpoint as part of the URI (`https://MY-SERVER/api/2.5/`). Each release of Tableau Server supports specific versions of the REST API. New versions of the REST API are released with Tableau Server. By default, the value of `version` is set to `'2.3'`, which corresponds to Tableau Server 10.0. You can view or set this value. You might need to set this to a different value, for example, if you want to access features that are supported by the server and a later version of the REST API. For more information, see REST API Versions. ### Example ```python import tableauserverclient as TSC # create a instance of server server = TSC.Server('https://MY-SERVER') # sign in, etc. # change the REST API version to match the server server.use_server_version() # or change the REST API version to match a specific version # for example, 2.8 # server.version = '2.8' ``` ``` -------------------------------- ### Filtering with Django Style Source: https://tableau.github.io/server-client-python/docs/filter-sort This example demonstrates filtering workbooks by name using Django-style syntax. ```APIDOC ## Filtering with Django Style ### Description Apply filtering criteria directly to the endpoint method using keyword arguments, similar to Django ORM. ### Method GET (implied by `server.workbooks.filter`) ### Endpoint `/api/api-version/sites/[:site_id]/workbooks` (implied) ### Parameters #### Query Parameters - **name** (string) - Optional - Filter by workbook name. ### Request Example ```python all_workbooks = server.workbooks.filter(name='Superstore') for workbook in all_workbooks: print(workbook.owner_id) ``` ### Response #### Success Response (200) - **workbooks** (list) - A list of workbook objects matching the filter criteria. #### Response Example (Response body will contain a list of workbook objects) ``` -------------------------------- ### Create Hourly Schedule Source: https://tableau.github.io/server-client-python/docs/api-ref Example of creating an hourly schedule that runs every 2 hours between 2:30 AM and 11:00 PM. ```APIDOC ## Create Hourly Schedule ### Description Creates an hourly schedule with a specified start time, end time, and interval value. ### Method `server.schedules.create(schedule_item)` ### Parameters - `schedule_item` (TSC.ScheduleItem) - The schedule item object to create. ### Request Example ```python import tableauserverclient as TSC from datetime import time # Create an interval to run every 2 hours between 2:30AM and 11:00PM hourly_interval = TSC.HourlyInterval(start_time=time(2, 30), end_time=time(23, 0), interval_value=2) # Create schedule item hourly_schedule = TSC.ScheduleItem("Hourly-Schedule", 50, TSC.ScheduleItem.Type.Extract, TSC.ScheduleItem.ExecutionOrder.Parallel, hourly_interval) # Create schedule hourly_schedule = server.schedules.create(hourly_schedule) ``` ``` -------------------------------- ### Sorting with Django Style Source: https://tableau.github.io/server-client-python/docs/filter-sort This example shows how to sort workbooks in ascending order by name using Django-style syntax. ```APIDOC ## Sorting with Django Style ### Description Specify sorting order using the `order_by` method. Prefix field names with `-` for descending order. ### Method GET (implied by `server.workbooks.order_by`) ### Endpoint `/api/api-version/sites/[:site_id]/workbooks` (implied) ### Parameters #### Query Parameters - **order_by** (string) - Optional - Field name to sort by. Prefix with `-` for descending order. ### Request Example ```python matching_workbooks = server.workbooks.order_by('name') for wb in matching_workbooks: print(wb.name) # Sorting by multiple fields with different directions workbooks = workbooks.order_by("project_name", "-created_at") ``` ### Response #### Success Response (200) - **workbooks** (list) - A list of workbook objects sorted according to the specified criteria. #### Response Example (Response body will contain a list of sorted workbook objects) ``` -------------------------------- ### Get All Metrics for a Site Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a list of all metric items and pagination information for a given site. Requires authentication with site-specific credentials. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL') server = TSC.Server('https://SERVER') with server.auth.sign_in(tableau_auth): # get all metrics on site all_metric_items, pagination_item = server.metrics.get() print([metric.name for metric in all_metric_items]) ``` -------------------------------- ### Server Resources Source: https://tableau.github.io/server-client-python/docs/api-ref Access various server resources and their associated methods through the Server instance after signing in. Examples include accessing views, users, and workbooks. ```APIDOC #### Server._Resources_ When you create an instance of the `Server` class, you have access to the resources on the server after you sign in. You can select these resources and their methods as members of the class, for example: `server.views.get()` Resource | Description ---|--- _server_.auth | Sets authentication for sign in and sign out. See Auth _server_.views | Access the server views and methods. See Views _server_.users | Access the user resources and methods. See Users _server_.sites | Access the sites. See Sites _server_.groups | Access the groups resources and methods. See Groups _server_.jobs | Access the jobs resources and methods. See Jobs _server_.workbooks | Access the resources and methods for workbooks. See Workbooks _server_.datasources | Access the resources and methods for data sources. See Data Sources _server_.projects | Access the resources and methods for projects. See Projects _server_.schedules | Access the resources and methods for schedules. See Schedules _server_.subscriptions | Access the resources and methods for subscriptions. See Subscriptions _server_.server_info | Access the resources and methods for server information. See ServerInfo class ``` -------------------------------- ### Sign in and out using a 'with' block Source: https://tableau.github.io/server-client-python/docs/sign-in-out Use the 'with' block for a simplified and Pythonic sign-in/sign-out flow. The sign-out is automatically called when the block execution completes. Ensure you have the tableauserverclient library installed and provide your token, server URL, and site name. ```python import tableauserverclient as TSC tableau_auth = TSC.PersonalAccessTokenAuth('TOKEN_NAME', 'TOKEN_VALUE', 'SITENAME') server = TSC.Server('https://SERVER_URL') with server.auth.sign_in(tableau_auth): all_wb, pagination_item = server.workbooks.get() print("\nThere are {} workbooks on site: ".format(pagination_item.total_available)) for wb in all_wb: print(wb.id, wb.name) ``` -------------------------------- ### Get All Tasks on Site Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves all tasks on the site. Use pagination items to iterate through results. Requires authentication. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD') server = TSC.Server('https://SERVERURL') with server.auth.sign_in(tableau_auth): all_tasks, pagination_item = server.tasks.get() print("\nThere are {} tasks on site: ".format(pagination_item.total_available)) print([task.id for task in all_tasks]) ``` -------------------------------- ### JobItem Class Initialization Source: https://tableau.github.io/server-client-python/docs/api-ref Initializes a JobItem object with core job details. Optional parameters include start time, completion time, and finish code. ```python JobItem(id, type, created_at, started_at=None, completed_at=None, finish_code=0) ``` -------------------------------- ### Get All Projects on a Site Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a list of all project items for the current site. Authentication with site ID is required. The returned list can be iterated to access project names. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL') server = TSC.Server('https://SERVER') with server.auth.sign_in(tableau_auth): # get all projects on site all_project_items, pagination_item = server.projects.get() print([proj.name for proj in all_project_items]) ``` -------------------------------- ### Filtering with RequestOptions Source: https://tableau.github.io/server-client-python/docs/filter-sort This example demonstrates how to filter workbooks by name using the RequestOptions object and the add method for filter criteria. ```APIDOC ## Filtering with RequestOptions ### Description Use the `RequestOptions` object to define filtering criteria for an endpoint. This example filters workbooks where the name equals 'Superstore'. ### Method GET (implied by `server.workbooks.get`) ### Endpoint `/api/api-version/sites/[:site_id]/workbooks` (implied) ### Parameters #### Query Parameters - **filter** (string) - Optional - Filter criteria in the format 'field_operator_value'. ### Request Example ```python req_option = TSC.RequestOptions() req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Operator.Equals, 'Superstore')) matching_workbooks, pagination_item = server.workbooks.get(req_option) print(matching_workbooks[0].owner_id) ``` ### Response #### Success Response (200) - **workbooks** (list) - A list of workbook objects matching the filter criteria. - **pagination_item** (object) - Pagination information. #### Response Example (Response body will contain a list of workbook objects and pagination info) ``` -------------------------------- ### Sorting with RequestOptions Source: https://tableau.github.io/server-client-python/docs/filter-sort This example shows how to sort workbooks in ascending order by name using the RequestOptions object and the add method for sort criteria. ```APIDOC ## Sorting with RequestOptions ### Description Use the `RequestOptions` object to define sorting criteria for an endpoint. This example sorts workbooks in ascending order by name. ### Method GET (implied by `server.workbooks.get`) ### Endpoint `/api/api-version/sites/[:site_id]/workbooks` (implied) ### Parameters #### Query Parameters - **sort** (string) - Optional - Sort criteria in the format 'field_direction'. ### Request Example ```python req_option = TSC.RequestOptions() req_option.sort.add(TSC.Sort(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Direction.Asc)) matching_workbooks, pagination_item = server.workbooks.get(req_option) for wb in matching_workbooks: print(wb.name) ``` ### Response #### Success Response (200) - **workbooks** (list) - A list of workbook objects sorted by the specified criteria. - **pagination_item** (object) - Pagination information. #### Response Example (Response body will contain a list of sorted workbook objects and pagination info) ``` -------------------------------- ### Get Site by Content URL Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a specific site using its content URL. Use an empty string for the default site. Requires server connection and sign-in. ```python site = server.sites.get_by_content_url('MarketingTeam') print(site.id, site.name) ``` -------------------------------- ### Run Sample Script with Arguments Source: https://tableau.github.io/server-client-python/docs/samples This command shows how to run a sample script, such as publish_workbook.py, with necessary arguments like server URL, site, and personal access token. Use the -h flag for specific script arguments. ```bash python samples/publish_workbook.py -h ``` -------------------------------- ### Set Starting Page Number for Pager Source: https://tableau.github.io/server-client-python/docs/page-through-results Specify a starting page number for the Pager by setting the pagenumber option in a RequestOptions object. This example starts retrieving results from page 5. ```python request_options = TSC.RequestOptions(pagenumber=5) all_workbooks = list(TSC.Pager(server.workbooks, request_options)) ``` -------------------------------- ### Create a GroupSetItem Instance Source: https://tableau.github.io/server-client-python/docs/api-ref Shows how to instantiate a GroupSetItem, which is required before creating a new group set on the server. ```python new_groupset = TSC.GroupSetItem('My Group Set') # call groupsets.create() with new group set groupset = server.groupsets.create(new_groupset) ``` -------------------------------- ### Update an existing subscription Source: https://tableau.github.io/server-client-python/docs/api-ref Modifies an existing subscription on the server. First, retrieve the subscription using `get_by_id` or `get`, then update its properties, and finally call the `update` method. This example shows updating the subject, attachment settings, page options, suspension status, and schedule. ```python # Fetch an existing subscription from server. You can also use the subscriptions.get() method sub = server.subscriptions.get_by_id('59cec1ec-15a0-4eb3-bc9d-056b87aa0a18') # Set update-able fields. Any of these can be added or removed. sub.subject = "Updated subject" sub.attach_image = True sub.attach_pdf = True sub.page_orientation = TSC.PDFRequestOptions.Orientation.Landscape sub.page_size_option = TSC.PDFRequestOptions.PageType.Folio sub.suspended = True sub.schedule_id = 'cf2f4465-9c4b-4536-b7cc-59994e9b7dde' sub.send_if_view_empty = True # Create the new subscription on the site you are logged in. sub = server.subscriptions.update(sub) print(new_sub.subject) ``` -------------------------------- ### Install TSC with Pip Source: https://tableau.github.io/server-client-python/docs Installs the latest stable version of the Tableau Server Client (TSC) library using pip. Ensure pip is up-to-date before installing TSC. ```bash pip install --upgrade pip pip install tableauserverclient ``` -------------------------------- ### Get All Groups on Site Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves information about all groups on the site. To get user information within a group, use `groups.populate_users`. ```python # import tableauserverclient as TSC # tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD') # server = TSC.Server('https://SERVERURL') with server.auth.sign_in(tableau_auth): # get the groups on the server all_groups, pagination_item = server.groups.get() # print the names of the first 100 groups for group in all_groups : print(group.name, group.id) ``` -------------------------------- ### Add and Update a User Source: https://tableau.github.io/server-client-python/docs/api-ref Demonstrates how to create a new user, update their information, and then persist the changes to the server. ```python server = TSC.Server('https://SERVERURL') with server.auth.sign_in(tableau_auth): # create a new user_item user1 = TSC.UserItem('temp', 'Viewer') # add new user user1 = server.users.add(user1) print(user1.name, user1.site_role, user1.id) # modify user info user1.name = 'Laura' user1.fullname = 'Laura Rodriguez' user1.email = 'laura@example.com' # update user user1 = server.users.update(user1) print("\Updated user info:") print(user1.name, user1.fullname, user1.email, user1.id) ``` -------------------------------- ### Create a new SubscriptionItem Source: https://tableau.github.io/server-client-python/docs/api-ref Demonstrates how to create a new subscription item by setting various optional fields like image attachment, PDF options, and message content. The subscription is then created on the server. ```python new_sub = TSC.SubscriptionItem('My Subscription', schedule_id, user_id, target) # (Optional) Set other fields. Any of these can be added or removed. new_sub.attach_image = False new_sub.attach_pdf = True new_sub.message = "You have an alert!" new_sub.page_orientation = TSC.PDFRequestOptions.Orientation.Landscape new_sub.page_size_option = TSC.PDFRequestOptions.PageType.B4 new_sub.send_if_view_empty = True # Create the new subscription on the site you are logged in. new_sub = server.subscriptions.create(new_sub) print(new_sub.subject) ``` -------------------------------- ### Access Tableau Server Resources Source: https://tableau.github.io/server-client-python/docs/api-ref After signing in, access various server resources like views, users, sites, and workbooks as members of the Server instance. For example, `server.views.get()` retrieves all views. ```python server.views.get() ``` -------------------------------- ### Get All Views for a Site Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a list of all views on a site. Use this to iterate through all views or to get pagination information. The default behavior does not include usage statistics. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('username', 'password') server = TSC.Server('https://servername') with server.auth.sign_in(tableau_auth): all_views, pagination_item = server.views.get() print([view.name for view in all_views]) ``` -------------------------------- ### Get All Users on Tableau Site Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a list of all users on the specified Tableau site. Use the `req_options` parameter to filter results. To get workbook information for users, use the `populate_workbooks` method. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD') server = TSC.Server('https://SERVERURL') with server.auth.sign_in(tableau_auth): all_users, pagination_item = server.users.get() print("\nThere are {} user on site: ".format(pagination_item.total_available)) print([user.name for user in all_users]) ``` -------------------------------- ### Get All Schedules Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves all schedule items from the Tableau Server. ```python schedules.get() ``` -------------------------------- ### jobs.get_by_id Source: https://tableau.github.io/server-client-python/docs/api-ref Gets information about the specified job using its unique ID. ```APIDOC ## jobs.get_by_id ### Description Gets information about the specified job. ### Method jobs.get_by_id(job_id) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Name | Description ---|--- `job_id` | The `job_id` specifies the id of the job that is returned from an asynchronous task, such as extract refresh, or an import or update to groups using Active Directory ### Exceptions Error | Description ---|--- `404018 Resource Not Found` | Raises an error if the `job_id` is not found. ### Response #### Success Response Returns the `JobItem` requested. #### Response Example ```json { "example": "" } ``` ### Request Example ```python # import tableauserverclient as TSC # tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD') # server = TSC.Server('https://SERVERURL') with server.auth.sign_in(tableau_auth): # get the id of the job from response to extract refresh task, # or another asynchronous REST API call. # in this case, "576b616d-341a-4539-b32c-1ed0eb9db548" myJobId = '576b616d-341a-4539-b32c-1ed0eb9db548' jobinfo = server.jobs.get_by_id(myJobId) print(jobinfo) ``` ``` -------------------------------- ### Basic Filtering and Sorting with Tableau Server Client Source: https://tableau.github.io/server-client-python/docs/filter-sort Demonstrates how to retrieve all workbooks and then apply filters by project name, owner name, and size. It also shows how to chain multiple filters and apply sorting by creation date in descending order. Query execution is deferred until iteration. ```python # Return queryset with no filters workbooks = server.workbooks.all() # filters can be appended in new lines workbooks = workbooks.filter(project_name=project_name) # multiple filters can be added in a single line workbooks = workbooks.filter(project_name=project_name, owner_name=owner_name, size__gte=1000) # Multiple filters can be added through chaining. workbooks = workbooks.filter(project_name=project_name).filter(owner_name=owner_name).filter(size__gte=1000) # Find all views in a project, with a specific tag views = server.views.filter(project_name=project_name, tags="stale") # sort can take multiple args, with desc direction added as a (-) prefix workbooks = server.workbooks.order_by("project_name", "-created_at") # query is executed at time of iteration for workbook in workbooks: print(workbook) # pagination item is still accessible print(workbooks.total_available, workbooks.page_size, workbooks.page_number) # methods can be chained all_workbooks = server.workbooks.filter(project_name=project_name).order_by("-project_name") ``` -------------------------------- ### Get Webhook by ID Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves information about a specific webhook using its ID. Requires authentication. ```python # import tableauserverclient as TSC # server = TSC.Server('https://SERVER') # sign in . For authentication examples, see https://github.com/tableau/server-client-python/blob/master/samples/login.py with server.auth.sign_in(tableau_auth): webhook = server.webhooks.get_by_id ('7d60d364-b9f5-4a9c-8aa5-4bdaa38c5dd3') print (webhook.name, webhook.url) ``` -------------------------------- ### Initialize Tableau Server Client Source: https://tableau.github.io/server-client-python/docs/api-ref Create an instance of the Server class to represent your Tableau Server or Tableau Cloud. This instance is used for subsequent sign-in and resource access operations. ```python import tableauserverclient as TSC # create a instance of server server = TSC.Server('https://MY-SERVER') ``` -------------------------------- ### sites.list_auth_configurations Source: https://tableau.github.io/server-client-python/docs/api-ref Lists the authentication configurations for the current site. ```APIDOC ## sites.list_auth_configurations ### Description Lists the authentication configurations for the current site. ### Method `sites.list_auth_configurations()` ### Returns Returns a list of authentication configurations for the current site. ### Request Example ```python # import tableauserverclient as TSC # server = TSC.Server('https://MY-SERVER') # sign in, etc. # List authentication configurations auth_configs = server.sites.list_auth_configurations() # Display configuration details for config in auth_configs: print(f"ID: {config.idp_configuration_id}") print(f"Name: {config.idp_configuration_name}") print(f"Type: {config.auth_setting}") print(f"Enabled: {config.enabled}") print(f"Provider: {config.known_provider_alias}") ``` ``` -------------------------------- ### Get All Webhooks Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a list of all webhooks for a site. Pagination items are also returned. Requires authentication. ```python # import tableauserverclient as TSC # server = TSC.Server('https://SERVER') # sign in . For authentication examples, see https://github.com/tableau/server-client-python/blob/master/samples/login.py # get a list of all the webhooks on a site with server.auth.sign_in(tableau_auth): all_webhooks, pagination_item = server.webhooks.get() print("\nThere are {} webhooks on site: ".format(pagination_item.total_available)) print(["Webhook Name:"+ webhook.name+ ";" + "ID:" + webhook.id for webhook in all_webhooks]) ``` -------------------------------- ### Initialize ConnectionCredentials Source: https://tableau.github.io/server-client-python/docs/api-ref Used for workbook and data source publish requests. Contains authentication details for the connection. ```python ConnectionCredentials(name, password, embed=True, oauth=False) ``` -------------------------------- ### Get All Group Sets Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves information about all group sets on a specified site. Supports filtering and pagination. ```APIDOC ## groupsets.get ```python groupsets.get(req_options=None, result_level=None) ``` Returns information about the group sets on the specified site. REST API: Get Group Sets **Version** This endpoint is available with REST API version 3.22 and up. **Parameters** Name | Description ---|--- `req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. Filter parameters can include `page_size` and `page_number`. `result_level` | (Optional) Specifies the level of detail in the response. Can be `"members"` to include member groups, or `"local"` for local group sets only. **Returns** Returns a list of `GroupSetItem` objects and a `PaginationItem` object. **Example** ```python all_groupsets, pagination_item = server.groupsets.get() for groupset in all_groupsets: print(groupset.id, groupset.name) ``` ``` -------------------------------- ### List Site Authentication Configurations Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves and prints details about authentication configurations for all sites. Requires server connection and sign-in. ```python # server = TSC.Server('https://MY-SERVER') # sign in, etc. auth_configs = server.sites.list_auth_configurations() for config in auth_configs: print(f"IDP Configuration ID: {config.idp_configuration_id}") print(f"Name: {config.idp_configuration_name}") print(f"Type: {config.auth_setting}") print(f"Enabled: {config.enabled}") ``` -------------------------------- ### users.populate_groups Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves the groups a user belongs to. This corresponds to the REST API's 'Get Groups for a User' endpoint. ```APIDOC ## users.populate_groups(user_item, req_options=None) ### Description Returns the groups that the user belongs to. This method populates the `user_item.groups` attribute. ### Parameters #### Path Parameters - **user_item** (UserItem) - Required - The `user_item` specifies the user to populate with group membership. - **req_options** (dict) - Optional - Request options for pagination and filtering. ### Exceptions - **User item missing ID.** - Raises an error if the `user_item` is unspecified. ### Returns - A list of `GroupItem` objects. - A `PaginationItem` that points to `user_item.groups`. ### Request Example ```python # first get all users, call server.users.get() # get groups for user[0] ... page_n = server.users.populate_groups(all_users[0]) print("\nUser {0} is a member of {1} groups".format(all_users[0].name, page_n.total_available)) print("\nThe groups are:") for group in all_users[0].groups : print(group.name) ... ``` ``` -------------------------------- ### sites.list_auth_configurations Source: https://tableau.github.io/server-client-python/docs/api-ref Lists authentication configurations for a site. ```APIDOC ## sites.list_auth_configurations ### Description Lists authentication configurations for a site. ### Method Not specified (assumed to be part of a client object) ### Endpoint Not specified ### Parameters Not specified ``` -------------------------------- ### Get User by ID Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves information about a specific user using their ID. Requires a valid user ID. ```python user1 = server.users.get_by_id('9f9e9d9c-8b8a-8f8e-7d7c-7b7a6f6d6e6d') print(user1.name) ``` -------------------------------- ### projects.get Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a list of all project items for a given site. Requires signing into the site using TableauAuth. ```APIDOC ## projects.get ### Description Return a list of project items for a site. To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. ### Method `projects.get()` ### Parameters None. ### Request Example ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL') server = TSC.Server('https://SERVER') with server.auth.sign_in(tableau_auth): # get all projects on site all_project_items, pagination_item = server.projects.get() print([proj.name for proj in all_project_items]) ``` ### Response #### Success Response (200) - **list[ProjectItem]** - Returns a list of all `ProjectItem` objects. - **PaginationItem** - Returns a `PaginationItem` object for pagination. #### Response Example ```json [ { "id": "1f2f3e4e-5d6d-7c8c-9b0b-1a2a3f4f5e6e", "name": "Example Project 1" }, { "id": "2f3e4d5c-6d7c-8b9a-0b1a-2a3f4f5e6e7f", "name": "Example Project 2" } ] ``` ``` -------------------------------- ### server_info.get Method Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves server build and version information. This method is unauthenticated and does not require a sign-in or token. ```APIDOC ### ServerInfo methods The TSC library provides a method to access the build and version information from Tableau Server. #### server_info.get ``` server_info.get() ``` Retrieve the build and version information for the server. This method makes an unauthenticated call, so no sign in or authentication token is required. REST API: Server Info ### Parameters None ### Exceptions Error | Description ---|--- `404003 UNKNOWN_RESOURCE` | Raises an exception if the server info endpoint is not found. ### Example ```python import tableauserverclient as TSC ``` -------------------------------- ### Get Schedule by ID Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a specific schedule using its unique identifier. Optional request options can be provided. ```python schedules.get_by_id(schedule_id) ``` -------------------------------- ### Get Group Set by ID Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves detailed information about a specific group set using its unique identifier. ```APIDOC ## groupsets.get_by_id ```python groupsets.get_by_id(groupset_id) ``` Returns information about the specified group set. REST API: Get Group Set **Version** This endpoint is available with REST API version 3.22 and up. **Parameters** Name | Description ---|--- `groupset_id` | The id of the group set. **Returns** Returns a `GroupSetItem` object. **Example** ```python groupset = server.groupsets.get_by_id('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d') print(groupset.name) ``` ``` -------------------------------- ### sites.create Source: https://tableau.github.io/server-client-python/docs/api-ref Creates a new site on Tableau Server. ```APIDOC ## sites.create ### Description Creates a new site on Tableau Server. ### Method Not specified (assumed to be part of a client object) ### Endpoint Not specified ### Parameters Not specified ``` -------------------------------- ### Sign in with TableauAuth Source: https://tableau.github.io/server-client-python/docs/api-ref Use the TableauAuth class to create sign-in credentials with a username and password. Pass this object to the server.auth.sign_in method. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL') server = TSC.Server('https://SERVER_URL', use_server_version=True) server.auth.sign_in(tableau_auth) ``` -------------------------------- ### Create DatasourceItem Instance Source: https://tableau.github.io/server-client-python/docs/api-ref Instantiates a DatasourceItem object, requiring a project ID. This is a prerequisite for publishing or managing a data source. ```python import tableauserverclient as TSC # Create new datasource_item with project id '3a8b6148-493c-11e6-a621-6f3499394a39' new_datasource = TSC.DatasourceItem('3a8b6148-493c-11e6-a621-6f3499394a39') ``` -------------------------------- ### workbooks.populate_views Source: https://tableau.github.io/server-client-python/docs/api-ref Populates (or gets) a list of views for a workbook. You must first call this method to populate views before you can iterate through the views. ```APIDOC ## workbooks.populate_views ### Description Populates (or gets) a list of views for a workbook. You must first call this method to populate views before you can iterate through the views. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **workbook_item** (WorkbookItem) - Required - The `workbook_item` specifies the workbook to populate with views information. See WorkbookItem class. ### Request Example ```python # import tableauserverclient as TSC # server = TSC.Server('https://SERVERURL') # ... # workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d') # server.workbooks.populate_views(workbook) # for view in workbook.views: # print(view.name) ``` ### Response #### Success Response (200) None. A list of `ViewItem` objects are added to the workbook (`workbook_item.views`). ### Exceptions - **Workbook item missing ID. Workbook must be retrieved from server first.** - Raises an error if the `workbook_item` is unspecified. You can retrieve the workbook items using the `workbooks.get()` and `workbooks.get_by_id()` methods. ``` -------------------------------- ### Create a Tableau Project Source: https://tableau.github.io/server-client-python/docs/api-ref Use this method to create a new project on a Tableau site. Instantiate a ProjectItem with desired properties and pass it to the create method. Authentication with site ID is required. ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL') server = TSC.Server('https://SERVER') with server.auth.sign_in(tableau_auth): # create project item new_project = TSC.ProjectItem(name='Example Project', content_permissions='LockedToProject', description='Project created for testing') # create the project new_project = server.projects.create(new_project) ``` -------------------------------- ### virtual_connections.download Source: https://tableau.github.io/server-client-python/docs/api-ref Downloads the JSON definition of a virtual connection as a string. This corresponds to the REST API 'Get Virtual Connection' endpoint. ```APIDOC ## virtual_connections.download ### Description Downloads the JSON definition of a virtual connection as a string. ### Method GET (implied by REST API 'Get Virtual Connection') ### Endpoint (Not explicitly provided in source, but implied by REST API) ### Parameters #### Path Parameters None explicitly defined for this method signature. #### Query Parameters None explicitly defined for this method signature. #### Request Body None ### Request Example ```python content_json = server.virtual_connections.download(vc) with open('vc_backup.json', 'w') as f: f.write(content_json) ``` ### Response #### Success Response (200) - **content** (string) - The virtual connection definition as a JSON string. #### Response Example ```json { "virtualConnection": { "id": "example-vc-id", "name": "Example Virtual Connection", "description": "A sample virtual connection" } } ``` ``` -------------------------------- ### Get Group Set by ID Source: https://tableau.github.io/server-client-python/docs/api-ref Fetches a specific group set using its unique identifier. Returns a GroupSetItem object. ```python groupset = server.groupsets.get_by_id('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d') print(groupset.name) ``` -------------------------------- ### schedules.create Source: https://tableau.github.io/server-client-python/docs/api-ref Creates a new schedule. ```APIDOC ## schedules.create ### Description Creates a new schedule. ### Method Not specified (assumed to be part of a client object) ### Endpoint Not specified ### Parameters Not specified ``` -------------------------------- ### tasks.create Source: https://tableau.github.io/server-client-python/docs/api-ref Creates a new task. ```APIDOC ## tasks.create ### Description Creates a new task. ### Method Not specified (assumed to be part of a client object) ### Endpoint Not specified ### Parameters Not specified ``` -------------------------------- ### webhook.create Source: https://tableau.github.io/server-client-python/docs/api-ref Creates a new webhook. ```APIDOC ## webhook.create ### Description Creates a new webhook. ### Method Not specified (assumed to be part of a client object) ### Endpoint Not specified ### Parameters Not specified ``` -------------------------------- ### Create Daily Schedule Source: https://tableau.github.io/server-client-python/docs/api-ref Creates a daily schedule that runs every day at 12:30 AM. Requires importing TSC and datetime.time. ```python import tableauserverclient as TSC from datetime import time # sign in, etc. # Create a daily interval to run every day at 12:30AM daily_interval = TSC.DailyInterval(start_time=time(0, 30)) # Create schedule item using daily interval daily_schedule = TSC.ScheduleItem("Daily-Schedule", 60, TSC.ScheduleItem.Type.Subscription, TSC.ScheduleItem.ExecutionOrder.Serial, daily_interval) # Create daily schedule daily_schedule = server.schedules.create(daily_schedule) ``` -------------------------------- ### sites.create Source: https://tableau.github.io/server-client-python/docs/api-ref Creates a new site on the server. This method is only available for Tableau Server. ```APIDOC ## sites.create ### Description Creates a new site on the server for the specified site item object. Tableau Server only. ### Method `sites.create(site_item)` ### Parameters - **site_item** (SiteItem) - Required - The settings for the site that you want to create. You need to create an instance of `SiteItem` and pass it to the `create` method. ### Returns Returns a new instance of `SiteItem`. ### Request Example ```python import tableauserverclient as TSC # create an instance of server server = TSC.Server('https://MY-SERVER') # create shortcut for admin mode content_users=TSC.SiteItem.AdminMode.ContentAndUsers # create a new SiteItem new_site = TSC.SiteItem(name='Tableau', content_url='tableau', admin_mode=content_users, user_quota=15, storage_quota=1000, disable_subscriptions=True) # call the sites create method with the SiteItem new_site = server.sites.create(new_site) ``` ``` -------------------------------- ### views.get_by_id Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves the details of a specific view using its unique ID. This method corresponds to the 'Get View' REST API endpoint. ```APIDOC ## views.get_by_id ### Description Returns the details of a specific view. This method corresponds to the REST API endpoint 'Get View'. ### Method Signature ```python views.get_by_id(view_id) ``` ### Parameters - `view_id` (string): The unique identifier of the view to retrieve. ### Returns A single `ViewItem` object representing the requested view. ### Example ```python import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('username', 'password') server = TSC.Server('https://servername') with server.auth.sign_in(tableau_auth): view = server.views.get_by_id('d79634e1-6063-4ec9-95ff-50acbf609ff5') print(view.name) ``` ``` -------------------------------- ### schedules.get_by_id Source: https://tableau.github.io/server-client-python/docs/api-ref Retrieves a specific schedule item from Tableau Server using its ID. This corresponds to the 'Get Schedule' REST API endpoint. ```APIDOC ## schedules.get_by_id ### Description Returns the specified schedule. ### Method Signature schedules.get_by_id(schedule_id) ### Parameters #### Path Parameters * `schedule_id` (string) - Required - The identifier of the schedule to retrieve. #### Query Parameters * `req_options` (dict) - Optional - Additional request options to send to the endpoint. ### Returns Returns a `ScheduleItem` object. ```