diff --git a/_includes/docs_menu.html b/_includes/docs_menu.html index 5693ee67e..e627e8f44 100644 --- a/_includes/docs_menu.html +++ b/_includes/docs_menu.html @@ -22,6 +22,9 @@
  • Samples
  • +
  • + Troubleshooting +
  • Developer Guide
  • diff --git a/assets/fiddler.png b/assets/fiddler.png new file mode 100644 index 000000000..cb5fde8e6 Binary files /dev/null and b/assets/fiddler.png differ diff --git a/docs/api-ref.md b/docs/api-ref.md index 4b95a1277..19840915e 100644 --- a/docs/api-ref.md +++ b/docs/api-ref.md @@ -5,21 +5,21 @@ layout: docs
    Important: More coming soon! This section is under active construction and might not reflect all the available functionality of the TSC library. - -
    - - + + + + The Tableau Server Client (TSC) is a Python library for the Tableau Server REST API. Using the TSC library, you can manage and change many of the Tableau Server and Tableau Online resources programmatically. You can use this library to create your own custom applications. -The TSC API reference is organized by resource. The TSC library is modeled after the REST API. The methods, for example, `workbooks.get()`, correspond to the endpoints for resources, such as [workbooks](#workbooks), [users](#users), [views](#views), and [data sources](#data-sources). The model classes (for example, the [WorkbookItem class](#workbookitem-class) have attributes that represent the fields (`name`, `id`, `owner_id`) that are in the REST API request and response packages, or payloads. +The TSC API reference is organized by resource. The TSC library is modeled after the REST API. The methods, for example, `workbooks.get()`, correspond to the endpoints for resources, such as [workbooks](#workbooks), [users](#users), [views](#views), and [data sources](#data-sources). The model classes (for example, the [WorkbookItem class](#workbookitem-class) have attributes that represent the fields (`name`, `id`, `owner_id`) that are in the REST API request and response packages, or payloads. -|:--- | +|:--- | | **Note:** Some methods and features provided in the REST API might not be currently available in the TSC library (and in some cases, the opposite is true). In addition, the same limitations apply to the TSC library that apply to the REST API with respect to resources on Tableau Server and Tableau Online. For more information, see the [Tableau Server REST API Reference](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm).| - -* TOC + +* TOC {:toc }
    @@ -29,29 +29,29 @@ The TSC API reference is organized by resource. The TSC library is modeled after ## Authentication -You can use the TSC library to sign in and sign out of Tableau Server and Tableau Online. The credentials for signing in are defined in the `TableauAuth` class and they correspond to the attributes you specify when you sign in using the Tableau Server REST API. +You can use the TSC library to sign in and sign out of Tableau Server and Tableau Online. The credentials for signing in are defined in the `TableauAuth` class and they correspond to the attributes you specify when you sign in using the Tableau Server REST API.
    -
    +
    ### TableauAuth class ```py TableauAuth(username, password, site_id='', user_id_to_impersonate=None) ``` -The `TableauAuth` class defines the information you can set in a sign-in request. The class members correspond to the attributes of a server request or response payload. To use this class, create a new instance, supplying user name, password, and site information if necessary, and pass the request object to the [Auth.sign_in](#auth.sign-in) method. +The `TableauAuth` class defines the information you can set in a sign-in request. The class members correspond to the attributes of a server request or response payload. To use this class, create a new instance, supplying user name, password, and site information if necessary, and pass the request object to the [Auth.sign_in](#auth.sign-in) method. + - - **Note:** In the future, there might be support for additional forms of authorization and authentication (for example, OAuth). + **Note:** In the future, there might be support for additional forms of authorization and authentication (for example, OAuth). -**Attributes** +**Attributes** -Name | Description -:--- | :--- -`username` | The name of the user whose credentials will be used to sign in. -`password` | The password of the user. -`site_id` | This corresponds to the `contentUrl` attribute in the Tableau REST API. The `site_id` is the portion of the URL that follows the `/site/` in the URL. For example, "MarketingTeam" is the `site_id` in the following URL *MyServer*/#/site/**MarketingTeam**/projects. To specify the default site on Tableau Server, you can use an empty string `''` (single quotes, no space). For Tableau Online, you must provide a value for the `site_id`. -`user_id_to_impersonate` | Specifies the id (not the name) of the user to sign in as. +Name | Description +:--- | :--- +`username` | The name of the user whose credentials will be used to sign in. +`password` | The password of the user. +`site_id` | This corresponds to the `contentUrl` attribute in the Tableau REST API. The `site_id` is the portion of the URL that follows the `/site/` in the URL. For example, "MarketingTeam" is the `site_id` in the following URL *MyServer*/#/site/**MarketingTeam**/projects. To specify the default site on Tableau Server, you can use an empty string `''` (single quotes, no space). For Tableau Online, you must provide a value for the `site_id`. +`user_id_to_impersonate` | Specifies the id (not the name) of the user to sign in as. Source file: models/tableau_auth.py @@ -59,25 +59,55 @@ Source file: models/tableau_auth.py ```py import tableauserverclient as TSC -# create a new instance of a TableauAuth object for authentication tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL') - -# create a server instance -# pass the "tableau_auth" object to the server.auth.sign_in() method +server = TSC.Server('https://SERVER_URL', use_server_version=True) +server.auth.sign_in(tableau_auth) ```
    -
    +
    + +### PersonalAccessTokenAuth class + +```py +PersonalAccessTokenAuth(token_name, personal_access_token, site_id='') +``` +The `PersonalAccessTokenAuth` class serves the same purpose and is used in the same way as `TableauAuth`, but using Personal Access Tokens](https://help.tableau.com/current/server/en-us/security_personal_access_tokens.htm) instead of username and password. + +**Attributes** + +Name | Description +:--- | :--- +`token_name` | The personal access token name. +`personal_access_token` | The personal access token value. +`site_id` | This corresponds to the `contentUrl` attribute in the Tableau REST API. The `site_id` is the portion of the URL that follows the `/site/` in the URL. For example, "MarketingTeam" is the `site_id` in the following URL *MyServer*/#/site/**MarketingTeam**/projects. To specify the default site on Tableau Server, you can use an empty string `''` (single quotes, no space). For Tableau Online, you must provide a value for the `site_id`. + +Source file: models/personal_access_token_auth.py + +**Example** + +```py +import tableauserverclient as TSC +tableau_auth = TSC.PersonalAccessToken('TOKEN-NAME', 'TOKEN-VALUE', site_id='CONTENTURL') +server = TSC.Server('https://SERVER_URL', use_server_version=True) +server.auth.sign_in(tableau_auth) +``` + +
    +
    ### Auth methods The Tableau Server Client provides two methods for interacting with authentication resources. These methods correspond to the sign in and sign out endpoints in the Tableau Server REST API. - Source file: server/endpoint/auth_endpoint.py +**See Also** +[Sign in and Out](sign-in-out) +[Server](#server) + +

    -
    #### auth.sign_in @@ -94,7 +124,7 @@ REST API: [Sign In](https://help.tableau.com/current/api/rest_api/en-us/REST/res **Parameters** -`auth_req` : The `TableauAuth` object that holds the sign-in credentials for the site. +`auth_req` : The `TableauAuth` object that holds the sign-in credentials for the site. **Example** @@ -110,14 +140,8 @@ server = TSC.Server('https://SERVER_URL') # call the sign-in method with the auth object server.auth.sign_in(tableau_auth) - ``` - -**See Also** -[Sign in and Out](sign-in-out) -[Server](#server) -

    @@ -136,18 +160,36 @@ REST API: [Sign Out](https://help.tableau.com/current/api/rest_api/en-us/REST/re **Example** ```py - server.auth.sign_out() +``` + +
    +
    +#### auth.switch_site +```py +auth.switch_site(site_id) ``` +Switch to a different site on the current Tableau Server. +Switching avoids the need for reauthenticating to the same server. (Note: This method is not available in Tableau Online.) +REST API: [Switch Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_authentication.htm#switch_site) -**See Also** -[Sign in and Out](sign-in-out) -[Server](#server) +**Parameters** + +`site_item` | The site that you want to switch to. This should be a `SiteItem` retrieved from `sites.get()`, `sites.get_by_id()` or `sites.get_by_name{}`. + + +**Example** + +```py +# find and then switch auth to another site on the same server +site = server.sites.get_by_id('9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d') +server.auth.switch_site(site) +```

    @@ -157,7 +199,7 @@ server.auth.sign_out() ## Connections -The connections for Tableau Server data sources and workbooks are represented by a `ConnectionItem` class. You can call data source and workbook methods to query or update the connection information. The `ConnectionCredentials` class represents the connection information you can update. +The connections for Tableau Server data sources and workbooks are represented by a `ConnectionItem` class. You can call data source and workbook methods to query or update the connection information. The `ConnectionCredentials` class represents the connection information you can update. ### ConnectionItem class @@ -167,23 +209,23 @@ ConnectionItem() The `ConnectionItem` class corresponds to workbook and data source connections. -In the Tableau Server REST API, there are separate endpoints to query and update workbook and data source connections. +In the Tableau Server REST API, there are separate endpoints to query and update workbook and data source connections. -**Attributes** +**Attributes** -Name | Description - :--- | : --- -`datasource_id` | The identifier of the data source. +Name | Description + :--- | : --- +`datasource_id` | The identifier of the data source. `datasource_name` | The name of the data source. `id` | The identifier of the connection. -`connection_type` | The type of connection. -`username` | The username for the connection. -`password` | The password used for the connection. -`embed_password` | (Boolean) Determines whether to embed the password (`True`) for the workbook or data source connection or not (`False`). -`server_address` | The server address for the connection. -`server_port` | The port used for the connection. +`connection_type` | The type of connection. +`username` | The username for the connection. +`password` | The password used for the connection. +`embed_password` | (Boolean) Determines whether to embed the password (`True`) for the workbook or data source connection or not (`False`). +`server_address` | The server address for the connection. +`server_port` | The port used for the connection. -Source file: models/connection_item.py +Source file: models/connection_item.py

    @@ -197,7 +239,7 @@ ConnectionCredentials(name, password, embed=True, oauth=False) ``` -The `ConnectionCredentials` class is used for workbook and data source publish requests. +The `ConnectionCredentials` class is used for workbook and data source publish requests. @@ -206,10 +248,10 @@ The `ConnectionCredentials` class is used for workbook and data source publish r Attribute | Description :--- | :--- `name` | The username for the connection. -`embed_password` | (Boolean) Determines whether to embed the passowrd (`True`) for the workbook or data source connection or not (`False`). -`password` | The password used for the connection. -`server_address` | The server address for the connection. -`server_port` | The port used by the server. +`embed_password` | (Boolean) Determines whether to embed the passowrd (`True`) for the workbook or data source connection or not (`False`). +`password` | The password used for the connection. +`server_address` | The server address for the connection. +`server_port` | The port used by the server. `ouath` | (Boolean) Specifies whether OAuth is used for the data source of workbook connection. For more information, see [OAuth Connections](https://help.tableau.com/current/server/en-us/protected_auth.htm). @@ -222,8 +264,8 @@ Source file: models/connection_credentials.py ## Data sources -Using the TSC library, you can get all the data sources on a site, or get the data sources for a specific project. -The data source resources for Tableau Server are defined in the `DatasourceItem` class. The class corresponds to the data source resources you can access using the Tableau Server REST API. For example, you can gather information about the name of the data source, its type, its connections, and the project it is associated with. The data source methods are based upon the endpoints for data sources in the REST API and operate on the `DatasourceItem` class. +Using the TSC library, you can get all the data sources on a site, or get the data sources for a specific project. +The data source resources for Tableau Server are defined in the `DatasourceItem` class. The class corresponds to the data source resources you can access using the Tableau Server REST API. For example, you can gather information about the name of the data source, its type, its connections, and the project it is associated with. The data source methods are based upon the endpoints for data sources in the REST API and operate on the `DatasourceItem` class.
    @@ -235,23 +277,23 @@ DatasourceItem(project_id, name=None) The `DatasourceItem` represents the data source resources on Tableau Server. This is the information that can be sent or returned in the response to an REST API request for data sources. When you create a new `DatasourceItem` instance, you must specify the `project_id` that the data source is associated with. -**Attributes** +**Attributes** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `connections` | The list of data connections (`ConnectionItem`) for the specified data source. You must first call the `populate_connections` method to access this data. See the [ConnectionItem class](#connectionitem-class). -`content_url` | The name of the data source as it would appear in a URL. +`content_url` | The name of the data source as it would appear in a URL. `created_at` | The date and time when the data source was created. `certified` | A Boolean value that indicates whether the data source is certified. -`certification_note` | The optional note that describes the certified data source. -`datasource_type` | The type of data source, for example, `sqlserver` or `excel-direct`. -`id` | The identifier for the data source. You need this value to query a specific data source or to delete a data source with the `get_by_id` and `delete` methods. -`name` | The name of the data source. If not specified, the name of the published data source file is used. +`certification_note` | The optional note that describes the certified data source. +`datasource_type` | The type of data source, for example, `sqlserver` or `excel-direct`. +`id` | The identifier for the data source. You need this value to query a specific data source or to delete a data source with the `get_by_id` and `delete` methods. +`name` | The name of the data source. If not specified, the name of the published data source file is used. `owner_id` | The identifier of the owner of the data source. `project_id` | The identifier of the project associated with the data source. You must provide this identifier when you create an instance of a `DatasourceItem`. -`project_name` | The name of the project associated with the data source. -`tags` | The tags (list of strings) that have been added to the data source. -`updated_at` | The date and time when the data source was last updated. +`project_name` | The name of the project associated with the data source. +`tags` | The tags (list of strings) that have been added to the data source. +`updated_at` | The date and time when the data source was last updated. **Example** @@ -267,44 +309,44 @@ Name | Description Source file: models/datasource_item.py -
    +

    ### Datasources methods -The Tableau Server Client provides several methods for interacting with data source resources, or endpoints. These methods correspond to endpoints in the Tableau Server REST API. +The Tableau Server Client provides several methods for interacting with data source resources, or endpoints. These methods correspond to endpoints in the Tableau Server REST API. Source file: server/endpoint/datasources_endpoint.py -
    +

    -#### datasources.delete +#### datasources.delete ```py datasources.delete(datasource_id) ``` -Removes the specified data source from Tableau Server. +Removes the specified data source from Tableau Server. -**Parameters** +**Parameters** -Name | Description -:--- | :--- -`datasource_id` | The identifier (`id`) for the `DatasourceItem` that you want to delete from the server. +Name | Description +:--- | :--- +`datasource_id` | The identifier (`id`) for the `DatasourceItem` that you want to delete from the server. **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `Datasource ID undefined` | Raises an exception if a valid `datasource_id` is not provided. REST API: [Delete Datasource](https://help.tableau.com/v0.0/api/rest_api/en-us/REST/rest_api_ref.htm#delete_data_source) -
    +

    @@ -320,23 +362,23 @@ REST API: [Download Datasource](https://help.tableau.com/current/api/rest_api/en **Parameters** -Name | Description -:--- | :--- -`datasource_id` | The identifier (`id`) for the `DatasourceItem` that you want to download from the server. -`filepath` | (Optional) Downloads the file to the location you specify. If no location is specified (the default is `Filepath=None`), the file is downloaded to the current working directory. +Name | Description +:--- | :--- +`datasource_id` | The identifier (`id`) for the `DatasourceItem` that you want to download from the server. +`filepath` | (Optional) Downloads the file to the location you specify. If no location is specified (the default is `Filepath=None`), the file is downloaded to the current working directory. `include_extract` | (Optional) Specifies whether to download the file with the extract. The default is to include the extract, if present (`include_extract=True`). When the data source has an extract, if you set the parameter `include_extract=False`, the extract is not included. You can use this parameter to improve performance if you are downloading data sources that have large extracts. Available starting with Tableau Server REST API version 2.5. -`no_extract` | (**Deprecated**) Use `include_extract` instead. The default value is to ignore this parameter (`no_extract=None`). If you set the parameter to `no_extract=True`, the download will not include an extract (if there is one). If set to `no_extract=False`, the download will include the extract (if there is one). Available starting with Tableau Server REST API version 2.5. +`no_extract` | (**Deprecated**) Use `include_extract` instead. The default value is to ignore this parameter (`no_extract=None`). If you set the parameter to `no_extract=True`, the download will not include an extract (if there is one). If set to `no_extract=False`, the download will include the extract (if there is one). Available starting with Tableau Server REST API version 2.5. **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `Datasource ID undefined` | Raises an exception if a valid `datasource_id` is not provided. -**Returns** +**Returns** -The file path to the downloaded data source. The data source is downloaded in `.tdsx` or `.hyper` format. +The file path to the downloaded data source. The data source is downloaded in `.tdsx` or `.hyper` format. **Example** @@ -347,7 +389,7 @@ The file path to the downloaded data source. The data source is downloaded in `. ``` - +

    @@ -357,7 +399,7 @@ The file path to the downloaded data source. The data source is downloaded in `. datasources.get(req_options=None) ``` -Returns all the data sources for the site. +Returns all the data sources for the site. To get the connection information for each data source, you must first populate the `DatasourceItem` with connection information using the [populate_connections(*datasource_item*)](#populate-connections-datasource) method. For more information, see [Populate Connections and Views](populate-connections-views#populate-connections-for-data-sources) @@ -365,9 +407,9 @@ REST API: [Query Datasources](https://help.tableau.com/current/api/rest_api/en-u **Parameters** -Name | Description -:--- | :--- -`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific data source, you could specify the name of the project or its id. +Name | Description +:--- | :--- +`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific data source, you could specify the name of the project or its id. **Returns** @@ -402,22 +444,22 @@ with server.auth.sign_in(tableau_auth): datasources.get_by_id(datasource_id) ``` -Returns the specified data source item. +Returns the specified data source item. REST API: [Query Datasource](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_data_source) **Parameters** -Name | Description -:--- | :--- -`datasource_id` | The `datasource_id` specifies the data source to query. +Name | Description +:--- | :--- +`datasource_id` | The `datasource_id` specifies the data source to query. **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `Datasource ID undefined` | Raises an exception if a valid `datasource_id` is not provided. @@ -436,8 +478,8 @@ print(datasource.name) ``` -
    -
    +
    +
    @@ -449,14 +491,14 @@ datasources.populate_connections(datasource_item) Populates the connections for the specified data source. -This method retrieves the connection information for the specified data source. The REST API is designed to return only the information you ask for explicitly. When you query for all the data sources, the connection information is not included. Use this method to retrieve the connections. The method adds the list of data connections to the data source item (`datasource_item.connections`). This is a list of `ConnectionItem` objects. +This method retrieves the connection information for the specified data source. The REST API is designed to return only the information you ask for explicitly. When you query for all the data sources, the connection information is not included. Use this method to retrieve the connections. The method adds the list of data connections to the data source item (`datasource_item.connections`). This is a list of `ConnectionItem` objects. REST API: [Query Datasource Connections](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_data_source_connections) **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `datasource_item` | The `datasource_item` specifies the data source to populate with connection information. @@ -464,14 +506,14 @@ Name | Description **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `Datasource item missing ID. Datasource must be retrieved from server first.` | Raises an error if the datasource_item is unspecified. **Returns** -None. A list of `ConnectionItem` objects are added to the data source (`datasource_item.connections`). +None. A list of `ConnectionItem` objects are added to the data source (`datasource_item.connections`). **Example** @@ -480,14 +522,14 @@ None. A list of `ConnectionItem` objects are added to the data source (`datasour # import tableauserverclient as TSC # server = TSC.Server('https://SERVERURL') -# - ... +# + ... # get the data source datasource = server.datasources.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b') -# get the connection information +# get the connection information server.datasources.populate_connections(datasource) # print the information about the first connection item @@ -500,8 +542,8 @@ None. A list of `ConnectionItem` objects are added to the data source (`datasour ``` -
    -
    +
    +
    #### datasources.publish @@ -509,35 +551,35 @@ None. A list of `ConnectionItem` objects are added to the data source (`datasour datasources.publish(datasource_item, file_path, mode, connection_credentials=None) ``` -Publishes a data source to a server, or appends data to an existing data source. +Publishes a data source to a server, or appends data to an existing data source. -This method checks the size of the data source and automatically determines whether the publish the data source in multiple parts or in one opeation. +This method checks the size of the data source and automatically determines whether the publish the data source in multiple parts or in one opeation. REST API: [Publish Datasource](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#publish_data_source) **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `datasource_item` | The `datasource_item` specifies the new data source you are adding, or the data source you are appending to. If you are adding a new data source, you need to create a new `datasource_item` with a `project_id` of an existing project. The name of the data source will be the name of the file, unless you also specify a name for the new data source when you create the instance. See [DatasourceItem](#datasourceitem-class). -`file_path` | The path and name of the data source to publish. +`file_path` | The path and name of the data source to publish. `mode` | Specifies whether you are publishing a new data source (`CreateNew`), overwriting an existing data source (`Overwrite`), or appending data to a data source (`Append`). If you are appending to a data source, the data source on the server and the data source you are publishing must be be extracts (.tde files) and they must share the same schema. You can also use the publish mode attributes, for example: `TSC.Server.PublishMode.Overwrite`. -`connection_credentials` | (Optional) The credentials required to connect to the data source. The `ConnectionCredentials` object contains the authentication information for the data source (user name and password, and whether the credentials are embedded or OAuth is used). - +`connection_credentials` | (Optional) The credentials required to connect to the data source. The `ConnectionCredentials` object contains the authentication information for the data source (user name and password, and whether the credentials are embedded or OAuth is used). + **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `File path does not lead to an existing file.` | Raises an error of the file path is incorrect or if the file is missing. -`Invalid mode defined.` | Raises an error if the publish mode is not one of the defined options. -`Only .tds, tdsx, .tde, or .hyper files can be published as datasources.` | Raises an error if the type of file specified is not supported. +`Invalid mode defined.` | Raises an error if the publish mode is not one of the defined options. +`Only .tds, tdsx, .tde, or .hyper files can be published as datasources.` | Raises an error if the type of file specified is not supported. **Returns** -The `DatasourceItem` for the data source that was added or appended to. +The `DatasourceItem` for the data source that was added or appended to. **Example** @@ -546,12 +588,12 @@ The `DatasourceItem` for the data source that was added or appended to. import tableauserverclient as TSC server = TSC.Server('https://SERVERURL') - + ... project_id = '3a8b6148-493c-11e6-a621-6f3499394a39' file_path = r'C:\temp\WorldIndicators.tde' - + # Use the project id to create new datsource_item new_datasource = TSC.DatasourceItem(project_id) @@ -563,8 +605,8 @@ The `DatasourceItem` for the data source that was added or appended to. ... ``` -
    -
    +
    +
    #### datasources.refresh @@ -572,22 +614,22 @@ The `DatasourceItem` for the data source that was added or appended to. datasource.refresh(datasource_item) ``` -Refreshes the data of the specified extract. +Refreshes the data of the specified extract. REST API: [Update Data Source Now](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_datasources.htm#update_data_source_now) **Parameters** -Name | Description - :--- | : --- +Name | Description + :--- | : --- `datasource_item` | The `datasource_item` specifies the data source to update. **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `Datasource item missing ID. Datasource must be retrieved from server first.` | Raises an error if the datasource_item is unspecified. Use the `Datasources.get()` method to retrieve that identifies for the data sources on the server. @@ -598,14 +640,14 @@ A refreshed `DatasourceItem`. **Example** -```py +```py # import tableauserverclient as TSC # server = TSC.Server('https://SERVERURL') -# sign in ... - +# sign in ... + # get the data source item to update datasource = server.datasources.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b') - + # call the refresh method with the data source item refreshed_datasource = server.datasources.refresh(datasource) @@ -625,16 +667,16 @@ REST API: [Update Datasource](https://help.tableau.com/current/api/rest_api/en-u **Parameters** -Name | Description - :--- | : --- +Name | Description + :--- | : --- `datasource_item` | The `datasource_item` specifies the data source to update. **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `Datasource item missing ID. Datasource must be retrieved from server first.` | Raises an error if the datasource_item is unspecified. Use the `Datasources.get()` method to retrieve that identifies for the data sources on the server. @@ -645,15 +687,15 @@ An updated `DatasourceItem`. **Example** -```py +```py # import tableauserverclient as TSC # server = TSC.Server('https://SERVERURL') -# sign in ... - +# sign in ... + # get the data source item to update datasource = server.datasources.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b') - -# do some updating + +# do some updating datasource.owner_id = 'New Owner ID' # call the update method with the data source item @@ -678,10 +720,10 @@ REST API: [Update Datasource Connection](https://help.tableau.com/current/api/re **Parameters** -Name | Description - :--- | : --- -`datasource_item` | The `datasource_item` specifies the data source to update. -`connection_item` | The `connection_item` that has the information you want to update. +Name | Description + :--- | : --- +`datasource_item` | The `datasource_item` specifies the data source to update. +`connection_item` | The `connection_item` that has the information you want to update. **Returns** @@ -693,12 +735,12 @@ An updated `ConnectionItem` for the data source. See the `update_connection.py` sample in the Samples directory. -
    -
    +
    +
    ## Filters -The TSC library provides a `Filter` class that you can use to filter results returned from the server. +The TSC library provides a `Filter` class that you can use to filter results returned from the server. You can use the `Filter` and `RequestOptions` classes to filter and sort the following endpoints: @@ -707,23 +749,23 @@ You can use the `Filter` and `RequestOptions` classes to filter and sort the fol - Workbooks - Views -For more information, see [Filter and Sort](filter-sort). +For more information, see [Filter and Sort](filter-sort). ### Filter class -```py +```py Filter(field, operator, value) ``` -The `Filter` class corresponds to the *filter expressions* in the Tableau REST API. +The `Filter` class corresponds to the *filter expressions* in the Tableau REST API. **Attributes** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `Field` | Defined in the `RequestOptions.Field` class. `Operator` | Defined in the `RequestOptions.Operator` class `Value` | The value to compare with the specified field and operator. @@ -732,8 +774,8 @@ Name | Description -
    -
    +
    +
    --- @@ -743,8 +785,8 @@ Using the TSC library, you can get information about all the groups on a site, y The group resources for Tableau Server are defined in the `GroupItem` class. The class corresponds to the group resources you can access using the Tableau Server REST API. The group methods are based upon the endpoints for groups in the REST API and operate on the `GroupItem` class. -
    -
    +
    +
    ### GroupItem class @@ -758,11 +800,11 @@ Source file: models/group_item.py **Attributes** -Name | Description -:--- | :--- -`domain_name` | The name of the Active Directory domain (`local` if local authentication is used). -`id` | The id of the group. -`users` | The list of users (`UserItem`). +Name | Description +:--- | :--- +`domain_name` | The name of the Active Directory domain (`local` if local authentication is used). +`id` | The id of the group. +`users` | The list of users (`UserItem`). `name` | The name of the group. The `name` is required when you create an instance of a group. @@ -778,8 +820,8 @@ Name | Description -
    -
    +
    +
    ### Groups methods @@ -789,8 +831,8 @@ The Tableau Server Client provides several methods for interacting with group re Source file: server/endpoint/groups_endpoint.py -
    -
    +
    +
    #### groups.add_user @@ -798,24 +840,24 @@ Source file: server/endpoint/groups_endpoint.py groups.add_user(group_item, user_id): ``` -Adds a user to the specified group. +Adds a user to the specified group. REST API [Add User to Group](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#add_user_to_group) **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `group_item` | The `group_item` specifies the group to update. -`user_id` | The id of the user. +`user_id` | The id of the user. **Returns** -None. +None. **Example** @@ -836,7 +878,7 @@ None. ``` -
    +

    #### groups.create @@ -845,7 +887,7 @@ None. create(group_item) ``` -Creates a new group in Tableau Server. +Creates a new group in Tableau Server. REST API: [Create Group](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#create_group) @@ -853,15 +895,15 @@ REST API: [Create Group](https://help.tableau.com/current/api/rest_api/en-us/RES **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `group_item` | The `group_item` specifies the group to add. You first create a new instance of a `GroupItem` and pass that to this method. **Returns** -Adds new `GroupItem`. +Adds new `GroupItem`. **Example** @@ -887,8 +929,8 @@ Adds new `GroupItem`. print(group.name, group.id) ``` -
    -
    +
    +
    #### groups.delete @@ -896,22 +938,22 @@ Adds new `GroupItem`. groups.delete(group_id) ``` -Deletes the group on the site. +Deletes the group on the site. REST API: [Delete Group](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#remove_user_from_site) -**Parameters** +**Parameters** -Name | Description -:--- | :--- -`group_id` | The identifier (`id`) for the group that you want to remove from the server. +Name | Description +:--- | :--- +`group_id` | The identifier (`id`) for the group that you want to remove from the server. **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `Group ID undefined` | Raises an exception if a valid `group_id` is not provided. @@ -928,7 +970,7 @@ Error | Description server.groups.delete('1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d') ``` -
    +

    #### groups.get @@ -937,24 +979,24 @@ Error | Description groups.get(req_options=None) ``` -Returns information about the groups on the site. +Returns information about the groups on the site. -To get information about the users in a group, you must first populate the `GroupItem` with user information using the [groups.populate_users](api-ref#groupspopulate_users) method. +To get information about the users in a group, you must first populate the `GroupItem` with user information using the [groups.populate_users](api-ref#groupspopulate_users) method. REST API: [Get Users on Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#get_users_on_site) **Parameters** -Name | Description -:--- | :--- -`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific group, you could specify the name of the group or the group id. +Name | Description +:--- | :--- +`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific group, you could specify the name of the group or the group id. **Returns** -Returns a list of `GroupItem` objects and a `PaginationItem` object. Use these values to iterate through the results. +Returns a list of `GroupItem` objects and a `PaginationItem` object. Use these values to iterate through the results. **Example** @@ -976,8 +1018,8 @@ Returns a list of `GroupItem` objects and a `PaginationItem` object. Use these ``` -
    -
    +
    +
    #### groups.populate_users @@ -985,17 +1027,17 @@ Returns a list of `GroupItem` objects and a `PaginationItem` object. Use these groups.populate_users(group_item, req_options=None) ``` -Populates the `group_item` with the list of users. +Populates the `group_item` with the list of users. REST API: [Get Users in Group](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#get_users_in_group) **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `group_item` | The `group_item` specifies the group to populate with user information. -`req_options` | (Optional) Additional request options to send to the endpoint. +`req_options` | (Optional) Additional request options to send to the endpoint. @@ -1006,7 +1048,7 @@ Name | Description **Returns** -None. A list of `UserItem` objects are added to the group (`group_item.users`). +None. A list of `UserItem` objects are added to the group (`group_item.users`). **Example** @@ -1015,28 +1057,28 @@ None. A list of `UserItem` objects are added to the group (`group_item.users`). # import tableauserverclient as TSC # server = TSC.Server('https://SERVERURL') -# - ... +# + ... # get the group all_groups, pagination_item = server.groups.get() mygroup = all_groups[1] -# get the user information +# get the user information pagination_item = server.groups.populate_users(mygroup) # print the names of the users for user in mygroup.users : - print(user.name) - + print(user.name) + ``` -
    -
    +
    +
    #### groups.remove_user @@ -1054,23 +1096,23 @@ REST API: [Remove User from Group](https://help.tableau.com/current/api/rest_api **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `group_item` | The `group_item` specifies the group to remove the user from. -`user_id` | The id for the user. +`user_id` | The id for the user. **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `Group must be populated with users first.` | Raises an error if the `group_item` is unpopulated. **Returns** -None. The user is removed from the group. +None. The user is removed from the group. **Example** @@ -1092,7 +1134,7 @@ None. The user is removed from the group. ``` -
    +

    --- @@ -1117,16 +1159,16 @@ The `JobItem` class contains information about the specified job running on Tabl Source file: models/job_item.py -**Attributes** +**Attributes** Name | Description -:--- | :--- -`id` | The `id` of the job. -`type` | The type of task. The types correspond to the job type categories listed for the [Query Job](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_job) REST API. +:--- | :--- +`id` | The `id` of the job. +`type` | The type of task. The types correspond to the job type categories listed for the [Query Job](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_job) REST API. `created_at` | The time the job was created. -`started_at` | The time the job started. -`completed_at` | The time the job finished. -`finish_code` | The return code from job. +`started_at` | The time the job started. +`completed_at` | The time the job finished. +`finish_code` | The return code from job. ### Jobs methods @@ -1138,7 +1180,7 @@ The Jobs methods are based upon the endpoints for jobs in the REST API and opera Source files: server/endpoint/jobs_endpoint.py
    -
    +
    #### jobs.get @@ -1149,15 +1191,15 @@ jobs.get(job_id) ``` -Gets information about the specified job. +Gets information about the specified job. REST API: [Query Job](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_job) **Parameters** -Name | Description -:--- | :--- +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 @@ -1165,8 +1207,8 @@ Name | Description **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `404018 Resource Not Found` | Raises an error if the `job_id` is not found. @@ -1187,7 +1229,7 @@ Returns the `JobItem` requested. 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. + # or another asynchronous REST API call. # in this case, "576b616d-341a-4539-b32c-1ed0eb9db548" @@ -1196,10 +1238,10 @@ Returns the `JobItem` requested. print(jobinfo) - # - + # + + - ``` @@ -1219,44 +1261,44 @@ The project resources for Tableau are defined in the `ProjectItem` class. The cl -
    +
    -### ProjectItem class +### ProjectItem class ```py ProjectItem(name, description=None, content_permissions=None, parent_id=None) ``` -The project resources for Tableau are defined in the `ProjectItem` class. The class corresponds to the project resources you can access using the Tableau Server REST API. +The project resources for Tableau are defined in the `ProjectItem` class. The class corresponds to the project resources you can access using the Tableau Server REST API. -**Attributes** +**Attributes** Name | Description -:--- | :--- +:--- | :--- `content_permissions` | Sets or shows the permissions for the content in the project. The options are either `LockedToProject` or `ManagedByOwner`. `name` | Name of the project. -`description` | The description of the project. +`description` | The description of the project. `id` | The project id. `parent_id` | The id of the parent project. Use this option to create project hierarchies. For information about managing projects, project hierarchies, and permissions, see [Use Projects to Manage Content Access](https://help.tableau.com/current/server/en-us/projects.htm). -Source file: models/project_item.py +Source file: models/project_item.py #### ProjectItem.ContentPermissions The `ProjectItem` class has a sub-class that defines the permissions for the project (`ProjectItem.ContentPermissions`). The options are `LockedToProject` and `ManagedByOwner`. For information on these content permissions, see [Lock Content Permissions to the Project](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#create_project). -Name | Description -:--- | :--- -`ProjectItem.ContentPermissions.LockedToProject` | Locks all content permissions to the project. -`ProjectItem.ContentPermissions.ManagedByOwner` | Users can manage permissions for content that they own. This is the default. +Name | Description +:--- | :--- +`ProjectItem.ContentPermissions.LockedToProject` | Locks all content permissions to the project. +`ProjectItem.ContentPermissions.ManagedByOwner` | Users can manage permissions for content that they own. This is the default. **Example** -```py +```py # import tableauserverclient as TSC # server = TSC.Server('https://MY-SERVER') @@ -1272,7 +1314,7 @@ print(by_owner) # prints 'ManagedByOwner' -# pass the content_permissions to new instance of the project item. +# 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') ``` @@ -1280,7 +1322,7 @@ new_project = TSC.ProjectItem(name='My Project', content_permissions=by_owner, d

    -### Project methods +### Project methods The project methods are based upon the endpoints for projects in the REST API and operate on the `ProjectItem` class. @@ -1295,12 +1337,12 @@ Source files: server/endpoint/projects_endpoint.py ```py projects.create(project_item) -``` +``` Creates a project on the specified site. -To create a project, you first create a new instance of a `ProjectItem` and pass it to the create method. To specify the site to create the new project, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). +To create a project, you first create a new instance of a `ProjectItem` and pass it to the create method. To specify the site to create the new project, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). REST API: [Create Project](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#create_project) @@ -1308,12 +1350,12 @@ REST API: [Create Project](https://help.tableau.com/current/api/rest_api/en-us/R **Parameters** Name | Description -:--- | :--- -`project_item` | Specifies the properties for the project. The `project_item` is the request package. To create the request package, create a new instance of `ProjectItem`. +:--- | :--- +`project_item` | Specifies the properties for the project. The `project_item` is the request package. To create the request package, create a new instance of `ProjectItem`. **Returns** -Returns the new project item. +Returns the new project item. @@ -1324,51 +1366,51 @@ 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): +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 + # create the project new_project = server.projects.create(new_project) ```
    -
    +
    #### projects.get ```py -projects.get() +projects.get() ``` -Return a list of project items for a site. +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. See the [TableauAuth class](#tableauauth-class). +To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). REST API: [Query Projects](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_projects) -**Parameters** +**Parameters** None. -**Returns** +**Returns** Returns a list of all `ProjectItem` objects and a `PaginationItem`. Use these values to iterate through the results. - - **Example** -```py -import tableauserverclient as TSC -tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL') -server = TSC.Server('https://SERVER') + **Example** + +```py +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): +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]) @@ -1376,7 +1418,7 @@ with server.auth.sign_in(tableau_auth): ```
    -
    +
    #### projects.update @@ -1385,33 +1427,33 @@ with server.auth.sign_in(tableau_auth): projects.update(project_item) ``` -Modify the project settings. +Modify the project settings. -You can use this method to update the project name, the project description, or the project permissions. To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). +You can use this method to update the project name, the project description, or the project permissions. To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). REST API: [Update Project](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#update_project) **Parameters** -Name | Description -:--- | :--- -`project_item` | The project item object must include the project ID. The values in the project item override the current project settings. +Name | Description +:--- | :--- +`project_item` | The project item object must include the project ID. The values in the project item override the current project settings. -**Exceptions** +**Exceptions** -Error | Description - :--- | : --- -`Project item missing ID.` | Raises an exception if the project item does not have an ID. The project ID is sent to the server as part of the URI. +Error | Description + :--- | : --- +`Project item missing ID.` | Raises an exception if the project item does not have an ID. The project ID is sent to the server as part of the URI. **Returns** -Returns the updated project information. +Returns the updated project information. See [ProjectItem class](#projectitem-class) -**Example** +**Example** ```py # import tableauserverclient as TSC @@ -1421,23 +1463,23 @@ See [ProjectItem class](#projectitem-class) ... # get list of projects all_project_items, pagination_item = server.projects.get() - + # update project item #7 with new name, etc. my_project = all_projects[7] my_project.name ='New name' - my_project.description = 'New description' - - # call method to update project + my_project.description = 'New description' + + # call method to update project updated_project = server.projects.update(my_project) - - + + ```
    -
    - +
    + #### projects.delete @@ -1448,7 +1490,7 @@ projects.delete(project_id) Deletes a project by ID. -To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). +To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). REST API: [Delete Project](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#delete_project) @@ -1456,40 +1498,40 @@ REST API: [Delete Project](https://help.tableau.com/current/api/rest_api/en-us/R **Parameters** -Name | Description -:--- | :--- -`project_id` | The ID of the project to delete. +Name | Description +:--- | :--- +`project_id` | The ID of the project to delete. - -**Exceptions** -Error | Description -:--- | :--- -`Project ID undefined.` | Raises an exception if the project item does not have an ID. The project ID is sent to the server as part of the URI. +**Exceptions** +Error | Description +:--- | :--- +`Project ID undefined.` | Raises an exception if the project item does not have an ID. The project ID is sent to the server as part of the URI. + + +**Example** -**Example** - ```py -# import tableauserverclient as TSC -# server = TSC.Server('https://MY-SERVER') -# sign in, etc. +# import tableauserverclient as TSC +# server = TSC.Server('https://MY-SERVER') +# sign in, etc. server.projects.delete('1f2f3e4e-5d6d-7c8c-9b0b-1a2a3f4f5e6e') -``` +```
    -
    +
    --- ## Requests -The TSC library provides a `RequestOptions` class that you can use to filter results returned from the server. +The TSC library provides a `RequestOptions` class that you can use to filter results returned from the server. You can use the `Sort` and `RequestOptions` classes to filter and sort the following endpoints: @@ -1497,21 +1539,21 @@ You can use the `Sort` and `RequestOptions` classes to filter and sort the follo - Datasources - Groups - Workbooks -- Views +- Views + +You can use the `ImageRequestOptions` and `PDFRequestOptions` to set options for views returned as images and PDF files. -You can use the `ImageRequestOptions` and `PDFRequestOptions` to set options for views returned as images and PDF files. +For more information about filtering and sorting, see [Filter and Sort](filter-sort). -For more information about filtering and sorting, see [Filter and Sort](filter-sort). - -
    +
    ### RequestOptions class -```py +```py RequestOptions(pagenumber=1, pagesize=100) ``` @@ -1520,12 +1562,12 @@ RequestOptions(pagenumber=1, pagesize=100) **Attributes** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `pagenumber` | The page number of the returned results. The default value is 1. `pagesize` | The number of items to return with each page (the default value is 100). -`sort()` | Returns a iterable set of `Sort` objects. -`filter()` | Returns an iterable set of `Filter` objects. +`sort()` | Returns a iterable set of `Sort` objects. +`filter()` | Returns an iterable set of `Filter` objects.

    @@ -1536,12 +1578,12 @@ Name | Description The `RequestOptions.Field` class corresponds to the fields used in filter expressions in the Tableau REST API. For more information, see [Filtering and Sorting](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_filtering_and_sorting.htm) in the Tableau REST API. -**Attributes** +**Attributes** -**Attributes** +**Attributes** Field | Description -:--- | :--- +:--- | :--- `CreatedAt` | Same as 'createdAt' in the REST API. TSC. `RequestOptions.Field.CreatedAt` `LastLogin` | Same as 'lastLogin' in the REST API. `RequestOptions.Field.LastLogin` `Name` | Same as 'name' in the REST API. `RequestOptions.Field.Name` @@ -1561,10 +1603,10 @@ Field | Description Specifies the operators you can use to filter requests. -**Attributes** +**Attributes** Operator | Description -:--- | :--- +:--- | :--- `Equals` | Sets the operator to equals (same as `eq` in the REST API). `TSC.RequestOptions.Operator.Equals` `GreaterThan` | Sets the operator to greater than (same as `gt` in the REST API). `TSC.RequestOptions.Operator.GreaterThan` `GreaterThanOrEqual` | Sets the operator to greater than or equal (same as `gte` in the REST API). `TSC.RequestOptions.Operator.GreaterThanOrEqual` @@ -1573,7 +1615,7 @@ Operator | Description `In` | Sets the operator to in (same as `in` in the REST API). `TSC.RequestOptions.Operator.In`
    -
    +
    @@ -1582,12 +1624,12 @@ Operator | Description Specifies the direction to sort the returned fields. -**Attributes** +**Attributes** Name | Description -:--- | :--- +:--- | :--- `Asc` | Sets the sort direction to ascending (`TSC.RequestOptions.Direction.Asc`) -`Desc` | Sets the sort direction to descending (`TSC.RequestOptions.Direction.Desc`). +`Desc` | Sets the sort direction to descending (`TSC.RequestOptions.Direction.Desc`).

    @@ -1601,8 +1643,8 @@ Use this class to specify view filters to be applied when the CSV data is genera **Attributes** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `maxage` | Optional. The maximum number of minutes the CSV data will be cached on the server before being refreshed. The value must be an integer between `1` and `240` minutes. `0` will be interpreted as 1 minute on server, as that is the shortest interval allowed. By default, `maxage` is set to `-1`, indicating the default behavior configured in server settings. **Example** @@ -1623,15 +1665,15 @@ server.views.populate_csv(view_item, csv_req_option) ### ImageRequestOptions class -```py +```py ImageRequestOptions(imageresolution=None, maxage=-1) ``` Use this class to specify the resolution of the view and, optionally, the maximum age of the image cached on the server. You can also use this class to specify view filters to be applied when the image is generated. See `views.populate_image`. **Attributes** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `imageresolution` | The resolution of the view returned as an image. You set this option with the `Resolution` class. If unspecified, the `views.populate_image` method returns an image with standard resolution (the width of the returned image is 784 pixels). If you set this parameter value to high (`Resolution.High`), the width of the returned image is 1568 pixels. For both resolutions, the height varies to preserve the aspect ratio of the view. `maxage` | Optional. The maximum number of minutes the image will be cached on the server before being refreshed. The value must be an integer between `1` and `240` minutes. `0` will be interpreted as 1 minute on server, as that is the shortest interval allowed. By default, `maxage` is set to `-1`, indicating the default behavior configured in server settings. @@ -1642,11 +1684,11 @@ You can use the `vf('filter_name', 'filter_value')` method to add view filters. **Example** ```py -# import tableauserverclient as TSC -# server = TSC.Server('https://MY-SERVER') -# sign in, get a specific view, etc. +# import tableauserverclient as TSC +# server = TSC.Server('https://MY-SERVER') +# sign in, get a specific view, etc. -# set the image request option +# set the image request option image_req_option = TSC.ImageRequestOptions(imageresolution=TSC.ImageRequestOptions.Resolution.High, maxage=1) # (optional) set a view filter @@ -1659,15 +1701,15 @@ server.views.populate_image(view_item, image_req_option) ### PDFRequestOptions class -```py +```py PDFRequestOptions(page_type=None, orientation=None, maxage=-1) ``` -Use this class to specify the format of the PDF that is returned for the view. Optionally, you can specify the maximum age of the rendered PDF that is cached on the server by providing a `maxage` value. See `views.populate_pdf`. +Use this class to specify the format of the PDF that is returned for the view. Optionally, you can specify the maximum age of the rendered PDF that is cached on the server by providing a `maxage` value. See `views.populate_pdf`. **Attributes** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `page_type` | The type of page returned in PDF format for the view. The page_type is set using the `PageType` class:
    `PageType.A3`
    `PageType.A4`
    `PageType.A5`
    `PageType.B5`
    `PageType.Executive`
    `PageType.Folio`
    `PageType.Ledger`
    `PageType.Legal`
    `PageType.Letter`
    `PageType.Note`
    `PageType.Quarto`
    `PageType.Tabloid` `orientation` | The orientation of the page. The options are portrait and landscape. The options are set using the `Orientation` class:
    `Orientation.Portrait`
    `Orientation.Landscape` `maxage` | Optional. The maximum number of minutes the rendered PDF will be cached on the server before being refreshed. The value must be an integer between `1` and `240` minutes. `0` will be interpreted as 1 minute on server, as that is the shortest interval allowed. By default, `maxage` is set to `-1`, indicating the default behavior configured in server settings. @@ -1678,9 +1720,9 @@ You can use the `vf('filter_name', 'filter_value')` method to add view filters. **Example** ```py -# import tableauserverclient as TSC -# server = TSC.Server('https://MY-SERVER') -# sign in, get a specific view, etc. +# import tableauserverclient as TSC +# server = TSC.Server('https://MY-SERVER') +# sign in, get a specific view, etc. # set the PDF request options pdf_req_option = TSC.PDFRequestOptions(page_type=TSC.PDFRequestOptions.PageType.A4, @@ -1697,13 +1739,13 @@ server.views.populate_pdf(view_item, pdf_req_option)
    -
    +
    --- -## Schedules +## Schedules -Using the TSC library, you can schedule extract refresh or subscription tasks on Tableau Server. You can also get and update information about the scheduled tasks, or delete scheduled tasks. +Using the TSC library, you can schedule extract refresh or subscription tasks on Tableau Server. You can also get and update information about the scheduled tasks, or delete scheduled tasks. If you have the identifer of the job, you can use the TSC library to find out the status of the asynchronous job. @@ -1721,33 +1763,33 @@ The `ScheduleItem` class contains information about the specified schedule runni Source file: models/schedule_item.py -**Attributes** +**Attributes** Name | Description -:--- | :--- -`name` | The `name` of the schedule. -`id` | The identifier for the schedule. Use the `schedules.get()` method to get the identifiers of the schedules on the server. -`schedule_type` | The type of task. The types are either an `Extract` for an extract refresh task or a `Subscription` for a scheduled subscription. -`execution_order` | Specifies how the scheduled task should run. The choices are `Parallel`which uses all available background processes for this scheduled task, or `Serial`, which limits this schedule to one background process. -`interval_item` | Specifies the frequency that the scheduled task should run. The `interval_item` is an instance of the `IntervalItem` class. The `interval_item` has properties for frequency (hourly, daily, weekly, monthly), and what time and date the scheduled item runs. You set this value by declaring an `IntervalItem` object that is one of the following: `HourlyInterval`, `DailyInterval`, `WeeklyInterval`, or `MonthlyInterval`. - +:--- | :--- +`name` | The `name` of the schedule. +`id` | The identifier for the schedule. Use the `schedules.get()` method to get the identifiers of the schedules on the server. +`schedule_type` | The type of task. The types are either an `Extract` for an extract refresh task or a `Subscription` for a scheduled subscription. +`execution_order` | Specifies how the scheduled task should run. The choices are `Parallel`which uses all available background processes for this scheduled task, or `Serial`, which limits this schedule to one background process. +`interval_item` | Specifies the frequency that the scheduled task should run. The `interval_item` is an instance of the `IntervalItem` class. The `interval_item` has properties for frequency (hourly, daily, weekly, monthly), and what time and date the scheduled item runs. You set this value by declaring an `IntervalItem` object that is one of the following: `HourlyInterval`, `DailyInterval`, `WeeklyInterval`, or `MonthlyInterval`. + #### IntervalItem class -This class sets the frequency and start time of the scheduled item. This class contains the classes for the hourly, daily, weekly, and monthly intervals. This class mirrors the options you can set using the REST API and the Tableau Server interface. +This class sets the frequency and start time of the scheduled item. This class contains the classes for the hourly, daily, weekly, and monthly intervals. This class mirrors the options you can set using the REST API and the Tableau Server interface. -**Attributes** +**Attributes** Name | Description -:--- | :--- +:--- | :--- `HourlyInterval` | Runs scheduled item hourly. To set the hourly interval, you create an instance of the `HourlyInterval` class and assign the following values: `start_time`, `end_time`, and `interval_value`. To set the `start_time` and `end_time`, assign the time value using this syntax: `start_time=time(`*hour*`,` *minute*`)` and `end_time=time(`*hour*`,` *minute*`)`. The *hour* is specified in 24 hour time. The `interval_value` specifies how often the to run the task within the start and end time. The options are expressed in hours. For example, `interval_value=.25` is every 15 minutes. The values are `.25`, `.5`, `1`, `2`, `4`, `6`, `8`, `12`. Hourly schedules that run more frequently than every 60 minutes must have start and end times that are on the hour. -`DailyInterval` | Runs the scheduled item daily. To set the daily interval, you create an instance of the `DailyInterval` and assign the `start_time`. The start time uses the syntax `start_time=time(`*hour*`,` *minute*`)`. -`WeeklyInterval` | Runs the scheduled item once a week. To set the weekly interval, you create an instance of the `WeeklyInterval` and assign the start time and multiple instances for the `interval_value` (days of week and start time). The start time uses the syntax `time(`*hour*`,` *minute*`)`. The `interval_value` is the day of the week, expressed as a `IntervalItem`. For example `TSC.IntervalItem.Day.Monday` for Monday. -`MonthlyInterval` | Runs the scheduled item once a month. To set the monthly interval, you create an instance of the `MonthlyInterval` and assign the start time and day. The +`DailyInterval` | Runs the scheduled item daily. To set the daily interval, you create an instance of the `DailyInterval` and assign the `start_time`. The start time uses the syntax `start_time=time(`*hour*`,` *minute*`)`. +`WeeklyInterval` | Runs the scheduled item once a week. To set the weekly interval, you create an instance of the `WeeklyInterval` and assign the start time and multiple instances for the `interval_value` (days of week and start time). The start time uses the syntax `time(`*hour*`,` *minute*`)`. The `interval_value` is the day of the week, expressed as a `IntervalItem`. For example `TSC.IntervalItem.Day.Monday` for Monday. +`MonthlyInterval` | Runs the scheduled item once a month. To set the monthly interval, you create an instance of the `MonthlyInterval` and assign the start time and day. The -### Schedule methods +### Schedule methods The schedule methods are based upon the endpoints for schedules in the REST API and operate on the `ScheduleItem` class. @@ -1759,136 +1801,136 @@ Source files: server/endpoint/schedules_endpoint.py ```py schedule.create(schedule_item) ``` -Creates a new schedule for an extract refresh or a subscription. +Creates a new schedule for an extract refresh or a subscription. REST API: [Create Schedule](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#create_schedule) -**Parameters** - -Name | Description -:--- | :--- -`schedule_item` | The settings for the schedule that you want to create. You need to create an instance of `schedule_item` and pass it to the `create` method. The `schedule_item` includes the `interval_item` which specifies the frequency, or interval, that the schedule should run. See `ScheduleItem` and `IntervalItem`. +**Parameters** + +Name | Description +:--- | :--- +`schedule_item` | The settings for the schedule that you want to create. You need to create an instance of `schedule_item` and pass it to the `create` method. The `schedule_item` includes the `interval_item` which specifies the frequency, or interval, that the schedule should run. See `ScheduleItem` and `IntervalItem`. -**Returns** +**Returns** Returns a new instance of `schedule_item`. **Exceptions** -Error | Description -:--- | :--- -`Interval item must be defined.` | Raises an exception if the `schedule_item.interval_item` is not specified. The interval item specifies whether the interval is hourly, daily, weekly, or monthly. +Error | Description +:--- | :--- +`Interval item must be defined.` | Raises an exception if the `schedule_item.interval_item` is not specified. The interval item specifies whether the interval is hourly, daily, weekly, or monthly. **Example** ```py import tableauserverclient as TSC -# sign in, etc. +# sign in, etc. # 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) + # Create schedule + hourly_schedule = server.schedules.create(hourly_schedule) ```
    -
    +
    #### schedule.delete ```py schedule.delete(schedule_id) -``` +``` -Deletes an existing schedule for an extract refresh or a subscription. +Deletes an existing schedule for an extract refresh or a subscription. REST API: [Delete Schedule](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#delete_schedule) -**Parameters** - -Name | Description -:--- | :--- -`schedule_id` | The identifier (`schedule_item.id`) of the schedule to delete. Use the `schedule.get()` method to get the identifiers of the schedules on the server. +**Parameters** + +Name | Description +:--- | :--- +`schedule_id` | The identifier (`schedule_item.id`) of the schedule to delete. Use the `schedule.get()` method to get the identifiers of the schedules on the server. -**Returns** +**Returns** None. **Exceptions** -Error | Description -:--- | :--- -`Schedule ID undefined` | The identifier is not a valid identifier for a schedule on the server. +Error | Description +:--- | :--- +`Schedule ID undefined` | The identifier is not a valid identifier for a schedule on the server. #### schedule.get ```py schedule.get([req_options=None]) -``` +``` -Returns all schedule items from the server. +Returns all schedule items from the server. REST API: [Query Schedules](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_schedules) -**Parameters** - -Name | Description -:--- | :--- +**Parameters** + +Name | Description +:--- | :--- `req_options` | (Optional) Additional request options to send to the endpoint. #### schedule.update
    -
    +
    **Hourly schedule example** ```py import tableauserverclient as TSC -# sign in, etc. +# sign in, etc. # 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) + # Create schedule + hourly_schedule = server.schedules.create(hourly_schedule) ``` **Daily schedule example** ```py import tableauserverclient as TSC -# sign in, etc. +# 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 + # Create daily schedule daily_schedule = server.schedules.create(daily_schedule) - + ``` **Weekly schedule example** ```py import tableauserverclient as TSC -# sign in, etc. +# sign in, etc. # 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, @@ -1896,9 +1938,9 @@ import tableauserverclient as TSC TSC.IntervalItem.Day.Friday) # Create schedule item using weekly interval weekly_schedule = TSC.ScheduleItem("Weekly-Schedule", 70, - TSC.ScheduleItem.Type.Extract, + TSC.ScheduleItem.Type.Extract, TSC.ScheduleItem.ExecutionOrder.Serial, weekly_interval) - # Create weekly schedule + # Create weekly schedule weekly_schedule = server.schedules.create(weekly_schedule) ``` @@ -1906,7 +1948,7 @@ import tableauserverclient as TSC **Monthly schedule example** ```py import tableauserverclient as TSC -# sign in, etc. +# sign in, etc. # 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) @@ -1921,19 +1963,19 @@ import tableauserverclient as TSC
    -
    +
    --- ## Server -In the Tableau REST API, the server (`https://MY-SERVER/`) is the base or core of the URI that makes up the various endpoints or methods for accessing resources on the server (views, workbooks, sites, users, data sources, etc.) -The TSC library provides a `Server` class that represents the server. You create a server instance to sign in to the server and to call the various methods for accessing resources. +In the Tableau REST API, the server (`https://MY-SERVER/`) is the base or core of the URI that makes up the various endpoints or methods for accessing resources on the server (views, workbooks, sites, users, data sources, etc.) +The TSC library provides a `Server` class that represents the server. You create a server instance to sign in to the server and to call the various methods for accessing resources.
    -
    +
    ### Server class @@ -1941,13 +1983,13 @@ The TSC library provides a `Server` class that represents the server. You create ```py 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. +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 Online (for example, `https://MY-SERVER/`). +`server_address` | Specifies the address of the Tableau Server or Tableau Online (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](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm). @@ -1958,7 +2000,7 @@ Attribute | Description import tableauserverclient as TSC -# create a instance of server +# create a instance of server server = TSC.Server('https://MY-SERVER') # sign in, etc. @@ -1966,48 +2008,48 @@ server = TSC.Server('https://MY-SERVER') # change the REST API version to match the server server.use_server_version() -# or change the REST API version to match a specific version +# or change the REST API version to match a specific version # for example, 2.8 -# server.version = '2.8' +# server.version = '2.8' ``` -#### Server.*Resources* +#### 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()` +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 - :--- | : --- +Resource | Description + :--- | : --- *server*.auth | Sets authentication for sign in and sign out. See [Auth](#authentication) | -*server*.views | Access the server views and methods. See [Views](#views) -*server*.users | Access the user resources and methods. See [Users](#users) -*server*.sites | Access the sites. See [Sites](#sites) -*server*.groups | Access the groups resources and methods. See [Groups](#groups) -*server*.jobs | Access the jobs resources and methods. See [Jobs](#jobs) +*server*.views | Access the server views and methods. See [Views](#views) +*server*.users | Access the user resources and methods. See [Users](#users) +*server*.sites | Access the sites. See [Sites](#sites) +*server*.groups | Access the groups resources and methods. See [Groups](#groups) +*server*.jobs | Access the jobs resources and methods. See [Jobs](#jobs) *server*.workbooks | Access the resources and methods for workbooks. See [Workbooks](#workbooks) *server*.datasources | Access the resources and methods for data sources. See [Data Sources](#data-sources) *server*.projects | Access the resources and methods for projects. See [Projects](#projects) *server*.schedules | Access the resources and methods for schedules. See [Schedules](#schedules) *server*.subscriptions | Access the resources and methods for subscriptions. See [Subscriptions](#subscriptions) -*server*.server_info | Access the resources and methods for server information. See [ServerInfo class](#serverinfoitem-class) +*server*.server_info | Access the resources and methods for server information. See [ServerInfo class](#serverinfoitem-class)

    #### Server.PublishMode -The `Server` class has `PublishMode` class that enumerates the options that specify what happens when you publish a workbook or data source. The options are `Overwrite`, `Append`, or `CreateNew`. +The `Server` class has `PublishMode` class that enumerates the options that specify what happens when you publish a workbook or data source. The options are `Overwrite`, `Append`, or `CreateNew`. -**Properties** +**Properties** -Resource | Description - :--- | : --- -`PublishMode.Overwrite` | Overwrites the workbook or data source. +Resource | Description + :--- | : --- +`PublishMode.Overwrite` | Overwrites the workbook or data source. `PublishMode.Append` | Appends to the workbook or data source. -`PublishMode.CreateNew` | Creates a new workbook or data source. +`PublishMode.CreateNew` | Creates a new workbook or data source. **Example** @@ -2018,7 +2060,7 @@ Resource | Description print(TSC.Server.PublishMode.Overwrite) # prints 'Overwrite' - + overwrite_true = TSC.Server.PublishMode.Overwrite ... @@ -2039,15 +2081,15 @@ Resource | Description ```py ServerInfoItem(product_version, build_number, rest_api_version) ``` -The `ServerInfoItem` class contains the build and version information for Tableau Server. The server information is accessed with the `server_info.get()` method, which returns an instance of the `ServerInfo` class. +The `ServerInfoItem` class contains the build and version information for Tableau Server. The server information is accessed with the `server_info.get()` method, which returns an instance of the `ServerInfo` class. -**Attributes** +**Attributes** -Name | Description -:--- | :--- -`product_version` | Shows the version of the Tableau Server or Tableau Online (for example, 10.2.0). +Name | Description +:--- | :--- +`product_version` | Shows the version of the Tableau Server or Tableau Online (for example, 10.2.0). `build_number` | Shows the specific build number (for example, 10200.17.0329.1446). -`rest_api_version` | Shows the supported REST API version number. Note that this might be different from the default value specified for the server, with the `Server.version` attribute. To take advantage of new features, you should query the server and set the `Server.version` to match the supported REST API version number. +`rest_api_version` | Shows the supported REST API version number. Note that this might be different from the default value specified for the server, with the `Server.version` attribute. To take advantage of new features, you should query the server and set the `Server.version` to match the supported REST API version number.
    @@ -2056,40 +2098,40 @@ Name | Description ### ServerInfo methods -The TSC library provides a method to access the build and version information from Tableau Server. +The TSC library provides a method to access the build and version information from Tableau Server. -
    +
    #### server_info.get ```py server_info.get() - + ``` -Retrieve the build and version information for the server. +Retrieve the build and version information for the server. -This method makes an unauthenticated call, so no sign in or authentication token is required. +This method makes an unauthenticated call, so no sign in or authentication token is required. REST API: [Server Info](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#server_info) - -**Parameters** - None - + +**Parameters** + None + **Exceptions** -Error | Description -:--- | :--- -`404003 UNKNOWN_RESOURCE` | Raises an exception if the server info endpoint is not found. +Error | Description +:--- | :--- +`404003 UNKNOWN_RESOURCE` | Raises an exception if the server info endpoint is not found. **Example** ```py import tableauserverclient as TSC -# create a instance of server +# create a instance of server server = TSC.Server('https://MY-SERVER') -# set the version number > 2.3 +# set the version number > 2.3 # the server_info.get() method works in 2.4 and later server.version = '2.5' @@ -2099,13 +2141,13 @@ print("\tProduct version: {0}".format(s_info.product_version)) print("\tREST API version: {0}".format(s_info.rest_api_version)) print("\tBuild number: {0}".format(s_info.build_number)) -``` +```

    ---- +--- ## Sites @@ -2113,8 +2155,8 @@ Using the TSC library, you can query a site or sites on a server, or create or d The site resources for Tableau Server and Tableau Online are defined in the `SiteItem` class. The class corresponds to the site resources you can access using the Tableau Server REST API. The site methods are based upon the endpoints for sites in the REST API and operate on the `SiteItem` class. -
    -
    +
    +
    ### SiteItem class @@ -2129,16 +2171,16 @@ The `SiteItem` class contains the members or attributes for the site resources o Attribute | Description :--- | :--- -`name` | The name of the site. The name of the default site is "". -`content_url` | The path to the site. +`name` | The name of the site. The name of the default site is "". +`content_url` | The path to the site. `admin_mode` | (Optional) For Tableau Server only. Specify `ContentAndUsers` to allow site administrators to use the server interface and **tabcmd** commands to add and remove users. (Specifying this option does not give site administrators permissions to manage users using the REST API.) Specify `ContentOnly` to prevent site administrators from adding or removing users. (Server administrators can always add or remove users.) `user_quota`| (Optional) Specifies the maximum number of users for the site. If you do not specify this value, the limit depends on the type of licensing configured for the server. For user-based license, the maximum number of users is set by the license. For core-based licensing, there is no limit to the number of users. If you specify a maximum value, only licensed users are counted and server administrators are excluded. `storage_quota` | (Optional) Specifies the maximum amount of space for the new site, in megabytes. If you set a quota and the site exceeds it, publishers will be prevented from uploading new content until the site is under the limit again. -`disable_subscriptions` | (Optional) Specify `true` to prevent users from being able to subscribe to workbooks on the specified site. The default is `false`. -`subscribe_others_enabled` | (Optional) Specify `false` to prevent server administrators, site administrators, and project or content owners from being able to subscribe other users to workbooks on the specified site. The default is `true`. -`revision_history_enabled` | (Optional) Specify `true` to enable revision history for content resources (workbooks and datasources). The default is `false`. -`revision_limit` | (Optional) Specifies the number of revisions of a content source (workbook or data source) to allow. On Tableau Server, the default is 25. -`state` | Shows the current state of the site (`Active` or `Suspended`). +`disable_subscriptions` | (Optional) Specify `true` to prevent users from being able to subscribe to workbooks on the specified site. The default is `false`. +`subscribe_others_enabled` | (Optional) Specify `false` to prevent server administrators, site administrators, and project or content owners from being able to subscribe other users to workbooks on the specified site. The default is `true`. +`revision_history_enabled` | (Optional) Specify `true` to enable revision history for content resources (workbooks and datasources). The default is `false`. +`revision_limit` | (Optional) Specifies the number of revisions of a content source (workbook or data source) to allow. On Tableau Server, the default is 25. +`state` | Shows the current state of the site (`Active` or `Suspended`). **Example** @@ -2151,21 +2193,21 @@ new_site = TSC.SiteItem(name='Tableau', content_url='tableau', admin_mode='Conte ``` -Source file: models/site_item.py +Source file: models/site_item.py
    -
    +
    ### Site methods -The TSC library provides methods that operate on sites for Tableau Server and Tableau Online. These methods correspond to endpoints or methods for sites in the Tableau REST API. +The TSC library provides methods that operate on sites for Tableau Server and Tableau Online. These methods correspond to endpoints or methods for sites in the Tableau REST API. -Source file: server/endpoint/sites_endpoint.py +Source file: server/endpoint/sites_endpoint.py
    -
    +
    #### sites.create @@ -2173,23 +2215,23 @@ Source file: server/endpoint/sites_endpoint.py sites.create(site_item) ``` -Creates a new site on the server for the specified site item object. +Creates a new site on the server for the specified site item object. -Tableau Server only. +Tableau Server only. REST API: [Create Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#create_site) -**Parameters** - -Name | Description -:--- | :--- +**Parameters** + +Name | Description +:--- | :--- `site_item` | 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** Returns a new instance of `SiteItem`. @@ -2199,7 +2241,7 @@ Returns a new instance of `SiteItem`. ```py import tableauserverclient as TSC -# create an instance of server +# create an instance of server server = TSC.Server('https://MY-SERVER') # create shortcut for admin mode @@ -2212,7 +2254,7 @@ new_site = TSC.SiteItem(name='Tableau', content_url='tableau', admin_mode=conten new_site = server.sites.create(new_site) ```
    -
    +
    #### sites.get @@ -2220,7 +2262,7 @@ new_site = server.sites.create(new_site) sites.get() ``` -Queries all the sites on the server. +Queries all the sites on the server. REST API: [Query Sites](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_sites) @@ -2230,9 +2272,9 @@ REST API: [Query Sites](https://help.tableau.com/current/api/rest_api/en-us/REST None. -**Returns** - -Returns a list of all `SiteItem` objects and a `PaginationItem`. Use these values to iterate through the results. +**Returns** + +Returns a list of all `SiteItem` objects and a `PaginationItem`. Use these values to iterate through the results. **Example** @@ -2268,26 +2310,26 @@ Queries the site with the given ID. REST API: [Query Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_site) -**Parameters** +**Parameters** -Name | Description -:--- | :--- -`site_id` | The id for the site you want to query. +Name | Description +:--- | :--- +`site_id` | The id for the site you want to query. -**Exceptions** +**Exceptions** -Error | Description - :--- | : --- -`Site ID undefined.` | Raises an error if an id is not specified. +Error | Description + :--- | : --- +`Site ID undefined.` | Raises an error if an id is not specified. -**Returns** +**Returns** + +Returns the `SiteItem`. -Returns the `SiteItem`. - -**Example** +**Example** ```py @@ -2296,7 +2338,7 @@ Returns the `SiteItem`. # sign in, etc. a_site = server.sites.get_by_id('9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d') - print("\nThe site with id '9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d' is: {0}".format(a_site.name)) + print("\nThe site with id '9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d' is: {0}".format(a_site.name)) ``` @@ -2314,26 +2356,26 @@ Queries the site with the specified name. REST API: [Query Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_site) -**Parameters** +**Parameters** + +Name | Description +:--- | :--- +`site_name` | The name of the site you want to query. -Name | Description -:--- | :--- -`site_name` | The name of the site you want to query. +**Exceptions** -**Exceptions** +Error | Description + :--- | : --- +`Site Name undefined.` | Raises an error if an name is not specified. -Error | Description - :--- | : --- -`Site Name undefined.` | Raises an error if an name is not specified. +**Returns** -**Returns** +Returns the `SiteItem`. -Returns the `SiteItem`. - -**Example** +**Example** ```py @@ -2357,7 +2399,7 @@ Returns the `SiteItem`. sites.update(site_item) ``` -Modifies the settings for site. +Modifies the settings for site. The site item object must include the site ID and overrides all other settings. @@ -2366,27 +2408,27 @@ The site item object must include the site ID and overrides all other settings. REST API: [Update Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#update_site) -**Parameters** +**Parameters** -Name | Description -:--- | :--- -`site_item` | The site item that you want to update. The settings specified in the site item override the current site settings. +Name | Description +:--- | :--- +`site_item` | The site item that you want to update. The settings specified in the site item override the current site settings. **Exceptions** Error | Description -:--- | :--- -`Site item missing ID.` | The site id must be present and must match the id of the site you are updating. +:--- | :--- +`Site item missing ID.` | The site id must be present and must match the id of the site you are updating. `You cannot set admin_mode to ContentOnly and also set a user quota` | To set the `user_quota`, the `AdminMode` must be set to `ContentAndUsers` -**Returns** +**Returns** -Returns the updated `site_item`. +Returns the updated `site_item`. -**Example** +**Example** ```py ... @@ -2420,22 +2462,22 @@ REST API: [Delete Site](https://help.tableau.com/current/api/rest_api/en-us/REST **Parameters** - -Name | Description - :--- | : --- -`site_id` | The id of the site that you want to delete. - +Name | Description + :--- | : --- +`site_id` | The id of the site that you want to delete. + + **Exceptions** -Error | Description -:--- | :--- -`Site ID Undefined.` | The site id must be present and must match the id of the site you are deleting. +Error | Description +:--- | :--- +`Site ID Undefined.` | The site id must be present and must match the id of the site you are deleting. - -**Example** + +**Example** ```py @@ -2450,38 +2492,38 @@ server.sites.delete('9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d')

    ---- +--- ## Sort -The `Sort` class is used with request options (`RequestOptions`) where you can filter and sort on the results returned from the server. +The `Sort` class is used with request options (`RequestOptions`) where you can filter and sort on the results returned from the server. You can use the sort and request options to filter and sort the following endpoints: - Users - Datasources - Workbooks -- Views +- Views ### Sort class ```py sort(field, direction) -``` +``` -**Attributes** +**Attributes** Name | Description -:--- | :--- -`field` | Sets the field to sort on. The fields are defined in the `RequestOption` class. +:--- | :--- +`field` | Sets the field to sort on. The fields are defined in the `RequestOption` class. `direction` | The direction to sort, either ascending (`Asc`) or descending (`Desc`). The options are defined in the `RequestOptions.Direction` class. -**Example** +**Example** -```py +```py # create a new instance of a request option object req_option = TSC.RequestOptions() @@ -2495,10 +2537,10 @@ for wb in matching_workbooks: print(wb.name) ``` -For information about using the `Sort` class, see [Filter and Sort](filter-sort). +For information about using the `Sort` class, see [Filter and Sort](filter-sort).
    -
    +
    --- @@ -2517,11 +2559,11 @@ SubscriptionItem(subject, schedule_id, user_id, target) **Attributes** -Name | Description -:--- | :--- -`id` | The id of the subscription on the site. -`subject`| The subject of the subscription. This is the description that you provide to identify the subscription. -`schedule_id` | The identifier associated with the specific subscription. +Name | Description +:--- | :--- +`id` | The id of the subscription on the site. +`subject`| The subject of the subscription. This is the description that you provide to identify the subscription. +`schedule_id` | The identifier associated with the specific subscription. `user_id` | The identifier of the user (person) who receives the subscription. `target` | The target of the subscription, that is, the content that is subscribed to (view, workbook). The target is an instance of the `target` class. The `target` has two properties, the `id` of the workbook or view (`target.id`), and the `type` (`target.type`), which can either `view` or `workbook`. @@ -2557,14 +2599,14 @@ REST API: [Create Subscription](https://help.tableau.com/current/api/rest_api/en **Parameters** -Name | Description - :--- | : --- -`subscription_item` | Specifies the user to subscribe, the content to subscribe to, the schedule to associate the subscription with, and the subject, or description for the subscription. +Name | Description + :--- | : --- +`subscription_item` | Specifies the user to subscribe, the content to subscribe to, the schedule to associate the subscription with, and the subject, or description for the subscription. **Returns** -Returns the new `SubscriptionItem` object. +Returns the new `SubscriptionItem` object. @@ -2578,7 +2620,7 @@ Returns the new `SubscriptionItem` object. # login, etc. -# create the target (content) of the subscription +# create the target (content) of the subscription # in this case, id of the workbook and the target type "workbook" target = TSC.Target('c7a9327e-1cda-4504-b026-ddb43b976d1d', 'workbook') @@ -2594,7 +2636,7 @@ Returns the new `SubscriptionItem` object. newSub = server.subscriptions.create(newSub) print(newSub.subject) -``` +```
    @@ -2605,27 +2647,27 @@ Returns the new `SubscriptionItem` object. #### subscriptions.delete ```py -subscriptions.delete(subscription_id) +subscriptions.delete(subscription_id) ``` -Deletes the specified subscription from the site. +Deletes the specified subscription from the site. REST API: [Delete Subscription](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#delete_subscription) **Parameters** -Name | Description - :--- | : --- -`subscription_id` | The identifier (`id`) for the subscription that you want to remove from the site. +Name | Description + :--- | : --- +`subscription_id` | The identifier (`id`) for the subscription that you want to remove from the site. **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `Subscription ID undefined` | Raises an exception if a valid `subscription_id` is not provided. @@ -2643,7 +2685,7 @@ Error | Description server.subscriptions.delete('9f9e9d9c-8b8a-8f8e-7d7c-7b7a6f6d6e6d') ``` -
    +


    @@ -2661,13 +2703,13 @@ REST API: [Query Subscriptions](https://help.tableau.com/current/api/rest_api/en **Parameters** -Name | Description - :--- | : --- -`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific subscription, you could specify the subject of the subscription or the id of the subscription. +Name | Description + :--- | : --- +`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific subscription, you could specify the subject of the subscription or the id of the subscription. **Returns** -Returns a list of `SubscriptionItem` objects and a `PaginationItem` object. Use these values to iterate through the results. +Returns a list of `SubscriptionItem` objects and a `PaginationItem` object. Use these values to iterate through the results.
    @@ -2680,23 +2722,23 @@ Returns a list of `SubscriptionItem` objects and a `PaginationItem` object. Use subscription.get_by_id(subscription_id) ``` -Returns information about the specified subscription. +Returns information about the specified subscription. REST API: [Query Subscription](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_subscription) **Parameters** -Name | Description - :--- | : --- -`subscription_id` | The `subscription_id` specifies the subscription to query. +Name | Description + :--- | : --- +`subscription_id` | The `subscription_id` specifies the subscription to query. **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `No Subscription ID provided.` | Raises an exception if a valid `subscription_id` is not provided. @@ -2726,7 +2768,7 @@ The `SubscriptionItem`. See [SubscriptionItem class](#subscriptionitem-class) Using the TSC library, you can get information about all the users on a site, and you can add or remove users, or update user information. -The user resources for Tableau Server are defined in the `UserItem` class. The class corresponds to the user resources you can access using the Tableau Server REST API. The user methods are based upon the endpoints for users in the REST API and operate on the `UserItem` class. +The user resources for Tableau Server are defined in the `UserItem` class. The class corresponds to the user resources you can access using the Tableau Server REST API. The user methods are based upon the endpoints for users in the REST API and operate on the `UserItem` class. ### UserItem class @@ -2735,22 +2777,22 @@ The user resources for Tableau Server are defined in the `UserItem` class. The c UserItem(name, site_role, auth_setting=None) ``` -The `UserItem` class contains the members or attributes for the view resources on Tableau Server. The `UserItem` class defines the information you can request or query from Tableau Server. The class members correspond to the attributes of a server request or response payload. +The `UserItem` class contains the members or attributes for the view resources on Tableau Server. The `UserItem` class defines the information you can request or query from Tableau Server. The class members correspond to the attributes of a server request or response payload. **Attributes** -Name | Description -:--- | :--- -`auth_setting` | (Optional) This attribute is only for Tableau Online. The new authentication type for the user. You can assign the following values for this attribute: `SAML` (the user signs in using SAML) or `ServerDefault` (the user signs in using the authentication method that's set for the server). These values appear in the **Authentication** tab on the **Settings** page in Tableau Online -- the `SAML` attribute value corresponds to **Single sign-on**, and the `ServerDefault` value corresponds to **TableauID**. -`domain_name` | The name of the site. -`external_auth_user_id` | Represents ID stored in Tableau's single sign-on (SSO) system. The `externalAuthUserId` value is returned for Tableau Online. For other server configurations, this field contains null. -`id` | The id of the user on the site. -`last_login` | The date and time the user last logged in. -`workbooks` | The workbooks the user owns. You must run the populate_workbooks method to add the workbooks to the `UserItem`. -`email` | The email address of the user. -`fullname` | The full name of the user. -`name` | The name of the user. This attribute is required when you are creating a `UserItem` instance. -`site_role` | The role the user has on the site. This attribute is required with you are creating a `UserItem` instance. The specific roles vary depending upon the version of the REST API. For example, for version 2.8 and earlier, the `site_role` can be one of the following: `Interactor`, `Publisher`, `ServerAdministrator`, `SiteAdministrator`, `Unlicensed`, `UnlicensedWithPublish`, `Viewer`, `ViewerWithPublish`, `Guest`. For REST API 3.0 and later, the `site_role` can be one of the following `Creator`, `Explorer`, `ExplorerCanPublish`, `ReadOnly` *(viewers from previous API versions who do not have v3.0+ viewer permissions)*, `Viewer`, `SiteAdministratorCreator`, `SiteAdministratorExplorer`, `UnlicensedWithPublish`. +Name | Description +:--- | :--- +`auth_setting` | (Optional) This attribute is only for Tableau Online. The new authentication type for the user. You can assign the following values for this attribute: `SAML` (the user signs in using SAML) or `ServerDefault` (the user signs in using the authentication method that's set for the server). These values appear in the **Authentication** tab on the **Settings** page in Tableau Online -- the `SAML` attribute value corresponds to **Single sign-on**, and the `ServerDefault` value corresponds to **TableauID**. +`domain_name` | The name of the site. +`external_auth_user_id` | Represents ID stored in Tableau's single sign-on (SSO) system. The `externalAuthUserId` value is returned for Tableau Online. For other server configurations, this field contains null. +`id` | The id of the user on the site. +`last_login` | The date and time the user last logged in. +`workbooks` | The workbooks the user owns. You must run the populate_workbooks method to add the workbooks to the `UserItem`. +`email` | The email address of the user. +`fullname` | The full name of the user. +`name` | The name of the user. This attribute is required when you are creating a `UserItem` instance. +`site_role` | The role the user has on the site. This attribute is required with you are creating a `UserItem` instance. The specific roles vary depending upon the version of the REST API. For example, for version 2.8 and earlier, the `site_role` can be one of the following: `Interactor`, `Publisher`, `ServerAdministrator`, `SiteAdministrator`, `Unlicensed`, `UnlicensedWithPublish`, `Viewer`, `ViewerWithPublish`, `Guest`. For REST API 3.0 and later, the `site_role` can be one of the following `Creator`, `Explorer`, `ExplorerCanPublish`, `ReadOnly` *(viewers from previous API versions who do not have v3.0+ viewer permissions)*, `Viewer`, `SiteAdministratorCreator`, `SiteAdministratorExplorer`, `UnlicensedWithPublish`. **Example** @@ -2761,14 +2803,14 @@ Name | Description # create a new UserItem object. newU = TSC.UserItem('Monty', 'Publisher') - + print(newU.name, newU.site_role) ``` Source file: models/user_item.py -
    +

    @@ -2777,7 +2819,7 @@ Source file: models/user_item.py The Tableau Server Client provides several methods for interacting with user resources, or endpoints. These methods correspond to endpoints in the Tableau Server REST API. Source file: server/endpoint/users_endpoint.py -
    +

    #### users.add @@ -2786,7 +2828,7 @@ Source file: server/endpoint/users_endpoint.py users.add(user_item) ``` -Adds the user to the site. +Adds the user to the site. To add a new user to the site you need to first create a new `user_item` (from `UserItem` class). When you create a new user, you specify the name of the user and their site role. For Tableau Online, you also specify the `auth_setting` attribute in your request. When you add user to Tableau Online, the name of the user must be the email address that is used to sign in to Tableau Online. After you add a user, Tableau Online sends the user an email invitation. The user can click the link in the invitation to sign in and update their full name and password. @@ -2794,14 +2836,14 @@ REST API: [Add User to Site](https://help.tableau.com/current/api/rest_api/en-us **Parameters** -Name | Description - :--- | : --- -`user_item` | You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific user, you could specify the name of the user or the user's id. +Name | Description + :--- | : --- +`user_item` | You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific user, you could specify the name of the user or the user's id. **Returns** -Returns the new `UserItem` object. +Returns the new `UserItem` object. @@ -2830,21 +2872,21 @@ users.get(req_options=None) Returns information about the users on the specified site. -To get information about the workbooks a user owns or has view permission for, you must first populate the `UserItem` with workbook information using the [populate_workbooks(*user_item*)](#populate-workbooks-user) method. +To get information about the workbooks a user owns or has view permission for, you must first populate the `UserItem` with workbook information using the [populate_workbooks(*user_item*)](#populate-workbooks-user) method. REST API: [Get Users on Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#get_users_on_site) **Parameters** -Name | Description - :--- | : --- -`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific user, you could specify the name of the user or the user's id. +Name | Description + :--- | : --- +`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific user, you could specify the name of the user or the user's id. **Returns** -Returns a list of `UserItem` objects and a `PaginationItem` object. Use these values to iterate through the results. +Returns a list of `UserItem` objects and a `PaginationItem` object. Use these values to iterate through the results. **Example** @@ -2871,22 +2913,22 @@ with server.auth.sign_in(tableau_auth): users.get_by_id(user_id) ``` -Returns information about the specified user. +Returns information about the specified user. REST API: [Query User On Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_user_on_site) **Parameters** -Name | Description - :--- | : --- -`user_id` | The `user_id` specifies the user to query. +Name | Description + :--- | : --- +`user_id` | The `user_id` specifies the user to query. **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `User ID undefined.` | Raises an exception if a valid `user_id` is not provided. @@ -2903,12 +2945,12 @@ The `UserItem`. See [UserItem class](#useritem-class) ``` -
    -
    +
    +
    #### users.populate_favorites - + ```py users.populate_favorites(user_item) ``` @@ -2917,8 +2959,8 @@ Returns the list of favorites (views, workbooks, and data sources) for a user. *Not currently implemented* -
    -
    +
    +
    #### users.populate_workbooks @@ -2927,17 +2969,17 @@ Returns the list of favorites (views, workbooks, and data sources) for a user. users.populate_workbooks(user_item, req_options=None): ``` -Returns information about the workbooks that the specified user owns and has Read (view) permissions for. +Returns information about the workbooks that the specified user owns and has Read (view) permissions for. -This method retrieves the workbook information for the specified user. The REST API is designed to return only the information you ask for explicitly. When you query for all the users, the workbook information for each user is not included. Use this method to retrieve information about the workbooks that the user owns or has Read (view) permissions. The method adds the list of workbooks to the user item object (`user_item.workbooks`). +This method retrieves the workbook information for the specified user. The REST API is designed to return only the information you ask for explicitly. When you query for all the users, the workbook information for each user is not included. Use this method to retrieve information about the workbooks that the user owns or has Read (view) permissions. The method adds the list of workbooks to the user item object (`user_item.workbooks`). REST API: [Query Datasource Connections](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_data_source_connections) **Parameters** -Name | Description - :--- | : --- +Name | Description + :--- | : --- `user_item` | The `user_item` specifies the user to populate with workbook information. @@ -2945,16 +2987,16 @@ Name | Description **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `User item missing ID.` | Raises an error if the `user_item` is unspecified. **Returns** -A list of `WorkbookItem` +A list of `WorkbookItem` -A `PaginationItem` that points (`user_item.workbooks`). See [UserItem class](#useritem-class) +A `PaginationItem` that points (`user_item.workbooks`). See [UserItem class](#useritem-class) **Example** @@ -2976,33 +3018,33 @@ A `PaginationItem` that points (`user_item.workbooks`). See [UserItem class](#us -
    +

    #### users.remove ```py -users.remove(user_id) +users.remove(user_id) ``` -Removes the specified user from the site. +Removes the specified user from the site. REST API: [Remove User from Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#remove_user_from_site) **Parameters** -Name | Description - :--- | : --- -`user_id` | The identifier (`id`) for the user that you want to remove from the server. +Name | Description + :--- | : --- +`user_id` | The identifier (`id`) for the user that you want to remove from the server. **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `User ID undefined` | Raises an exception if a valid `user_id` is not provided. @@ -3019,19 +3061,19 @@ Error | Description server.users.remove('9f9e9d9c-8b8a-8f8e-7d7c-7b7a6f6d6e6d') ``` -
    +

    -#### users.update +#### users.update ```py users.update(user_item, password=None) ``` -Updates information about the specified user. +Updates information about the specified user. The information you can modify depends upon whether you are using Tableau Server or Tableau Online, and whether you have configured Tableau Server to use local authentication or Active Directory. For more information, see [Update User](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#update_user). @@ -3041,18 +3083,18 @@ REST API: [Update User](https://help.tableau.com/current/api/rest_api/en-us/REST **Parameters** -Name | Description - :--- | : --- +Name | Description + :--- | : --- `user_item` | The `user_item` specifies the user to update. -`password` | (Optional) The new password for the user. +`password` | (Optional) The new password for the user. **Exceptions** -Error | Description - :--- | : --- -`User item missing ID.` | Raises an error if the `user_item` is unspecified. +Error | Description + :--- | : --- +`User item missing ID.` | Raises an error if the `user_item` is unspecified. **Returns** @@ -3069,10 +3111,10 @@ An updated `UserItem`. See [UserItem class](#useritem-class) # 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) @@ -3081,7 +3123,7 @@ An updated `UserItem`. See [UserItem class](#useritem-class) user1.name = 'Laura' user1.fullname = 'Laura Rodriguez' user1.email = 'laura@example.com' - + # update user user1 = server.users.update(user1) print("\Updated user info:") @@ -3092,8 +3134,8 @@ An updated `UserItem`. See [UserItem class](#useritem-class) -
    -
    +
    +
    --- @@ -3119,10 +3161,10 @@ Source file: models/view_item.py **Attributes** Name | Description -:--- | :--- +:--- | :--- `content_url` | The name of the view as it would appear in a URL. `csv` | The CSV data of the view. You must first call the `views.populate_csv` method to access the CSV data. -`id` | The identifier of the view item. +`id` | The identifier of the view item. `image` | The image of the view. You must first call the `views.populate_image`method to access the image. `name` | The name of the view. `owner_id` | The ID for the owner of the view. @@ -3133,7 +3175,7 @@ Name | Description `workbook_id` | The ID of the workbook associated with the view. -
    +

    @@ -3143,7 +3185,7 @@ The Tableau Server Client provides methods for interacting with view resources, Source file: server/endpoint/views_endpoint.py -
    +

    #### views.get @@ -3162,10 +3204,10 @@ This endpoint is available with REST API version 2.0 and up. **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific view, you could specify the name of the view or its ID. -`usage` | (Optional) If true (`usage=True`) returns the usage statistics for the views. The default is `usage=False`. +`usage` | (Optional) If true (`usage=True`) returns the usage statistics for the views. The default is `usage=False`. @@ -3196,7 +3238,7 @@ for view in TSC.Pager(server.views): See [ViewItem class](#viewitem-class) -
    +

    #### views.populate_preview_image @@ -3217,15 +3259,15 @@ This endpoint is available with REST API version 2.0 and up. **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `view_item` | Specifies the view to populate. **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `View item missing ID or workbook ID` | Raises an error if the ID of the view or workbook is missing. @@ -3245,7 +3287,7 @@ with open('./view_preview_image.png', 'wb') as f: See [ViewItem class](#viewitem-class) -
    +

    #### views.populate_image @@ -3406,34 +3448,34 @@ The project resources for Tableau are defined in the `WorkbookItem` class. The c
    -
    +
    + +### WorkbookItem class -### WorkbookItem class +```py -```py - WorkbookItem(project_id, name=None, show_tabs=False) - + ``` The workbook resources for Tableau are defined in the `WorkbookItem` class. The class corresponds to the workbook resources you can access using the Tableau REST API. Some workbook methods take an instance of the `WorkbookItem` class as arguments. The workbook item specifies the project -**Attributes** +**Attributes** Name | Description -:--- | :--- +:--- | :--- `connections` | The list of data connections (`ConnectionItem`) for the data sources used by the workbook. You must first call the [workbooks.populate_connections](#workbooks.populate_connections) method to access this data. See the [ConnectionItem class](#connectionitem-class). -`content_url` | The name of the data source as it would appear in a URL. -`created_at` | The date and time when the data source was created. -`id` | The identifier for the workbook. You need this value to query a specific workbook or to delete a workbook with the `get_by_id` and `delete` methods. -`name` | The name of the workbook. +`content_url` | The name of the data source as it would appear in a URL. +`created_at` | The date and time when the data source was created. +`id` | The identifier for the workbook. You need this value to query a specific workbook or to delete a workbook with the `get_by_id` and `delete` methods. +`name` | The name of the workbook. `owner_id` | The ID of the owner. -`preview_image` | The thumbnail image for the view. You must first call the [workbooks.populate_preview_image](#workbooks.populate_preview_image) method to access this data. +`preview_image` | The thumbnail image for the view. You must first call the [workbooks.populate_preview_image](#workbooks.populate_preview_image) method to access this data. `project_id` | The project id. `project_name` | The name of the project. -`size` | The size of the workbook (in megabytes). +`size` | The size of the workbook (in megabytes). `show_tabs` | (Boolean) Determines whether the workbook shows tabs for the view. -`tags` | The tags that have been added to the workbook. +`tags` | The tags that have been added to the workbook. `updated_at` | The date and time when the workbook was last updated. `views` | The list of views (`ViewItem`) for the workbook. You must first call the [workbooks.populate_views](#workbooks.populate_views) method to access this data. See the [ViewItem class](#viewitem-class). `webpage_url` | The full URL of the workbook. @@ -3444,9 +3486,9 @@ Name | Description **Example** -```py +```py # creating a new instance of a WorkbookItem -# +# import tableauserverclient as TSC # Create new workbook_item with project id '3a8b6148-493c-11e6-a621-6f3499394a39' @@ -3456,15 +3498,15 @@ import tableauserverclient as TSC ```` -Source file: models/workbook_item.py +Source file: models/workbook_item.py
    -
    +
    ### Workbook methods -The Tableau Server Client (TSC) library provides methods for interacting with workbooks. These methods correspond to endpoints in the Tableau Server REST API. For example, you can use the library to publish, update, download, or delete workbooks on the site. -The methods operate on a workbook object (`WorkbookItem`) that represents the workbook resources. +The Tableau Server Client (TSC) library provides methods for interacting with workbooks. These methods correspond to endpoints in the Tableau Server REST API. For example, you can use the library to publish, update, download, or delete workbooks on the site. +The methods operate on a workbook object (`WorkbookItem`) that represents the workbook resources. @@ -3473,13 +3515,13 @@ Source files: server/endpoint/workbooks_endpoint.py

    -#### workbooks.get +#### workbooks.get ```py workbooks.get(req_options=None) ``` -Queries the server and returns information about the workbooks the site. +Queries the server and returns information about the workbooks the site. @@ -3490,8 +3532,8 @@ REST API: [Query Workbooks for Site](https://help.tableau.com/current/api/rest_a **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. For example, if you were searching for a specific workbook, you could specify the name of the workbook or the name of the owner. See [Filter and Sort](filter-sort) @@ -3502,7 +3544,7 @@ Returns a list of all `WorkbookItem` objects and a `PaginationItem`. Use these v **Example** -```py +```py import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('username', 'password', site_id='site') @@ -3518,7 +3560,7 @@ with server.auth.sign_in(tableau_auth): ```
    -
    +
    @@ -3535,15 +3577,15 @@ REST API: [Query Workbook](https://help.tableau.com/current/api/rest_api/en-us/R **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `workbook_id` | The `workbook_id` specifies the workbook to query. The ID is a LUID (64-bit hexadecimal string). **Exceptions** -Error | Description - :--- | : --- +Error | Description + :--- | : --- `Workbook ID undefined` | Raises an exception if a `workbook_id` is not provided. @@ -3562,24 +3604,24 @@ print(workbook.name) ``` -
    -
    +
    +
    #### workbooks.publish ```py -workbooks.publish(workbook_item, file_path, publish_mode) +workbooks.publish(workbook_item, file_path, publish_mode) ``` -Publish a workbook to the specified site. +Publish a workbook to the specified site. **Note:** The REST API cannot automatically include extracts or other resources that the workbook uses. Therefore, a .twb file that uses data from an Excel or csv file on a local computer cannot be published, -unless you package the data and workbook in a .twbx file, or publish the data source separately. +unless you package the data and workbook in a .twbx file, or publish the data source separately. -For workbooks that are larger than 64 MB, the publish method automatically takes care of chunking the file in parts for uploading. Using this method is considerably more convenient than calling the publish REST APIs directly. +For workbooks that are larger than 64 MB, the publish method automatically takes care of chunking the file in parts for uploading. Using this method is considerably more convenient than calling the publish REST APIs directly. REST API: [Publish Workbook](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#publish_workbook), [Initiate File Upload](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#initiate_file_upload), [Append to File Upload](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#append_to_file_upload) @@ -3587,30 +3629,30 @@ REST API: [Publish Workbook](https://help.tableau.com/current/api/rest_api/en-us **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `workbook_item` | The `workbook_item` specifies the workbook you are publishing. When you are adding a workbook, you need to first create a new instance of a `workbook_item` that includes a `project_id` of an existing project. The name of the workbook will be the name of the file, unless you also specify a name for the new workbook when you create the instance. See [WorkbookItem](#workbookitem-class). -`file_path` | The path and name of the workbook to publish. +`file_path` | The path and name of the workbook to publish. `mode` | Specifies whether you are publishing a new workbook (`CreateNew`) or overwriting an existing workbook (`Overwrite`). You cannot appending workbooks. You can also use the publish mode attributes, for example: `TSC.Server.PublishMode.Overwrite`. -`connection_credentials` | (Optional) The credentials (if required) to connect to the workbook's data source. The `ConnectionCredentials` object contains the authentication information for the data source (user name and password, and whether the credentials are embeded or OAuth is used). - +`connection_credentials` | (Optional) The credentials (if required) to connect to the workbook's data source. The `ConnectionCredentials` object contains the authentication information for the data source (user name and password, and whether the credentials are embeded or OAuth is used). + **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `File path does not lead to an existing file.` | Raises an error of the file path is incorrect or if the file is missing. -`Invalid mode defined.` | Raises an error if the publish mode is not one of the defined options. -`Workbooks cannot be appended.` | The `mode` must be set to `Overwrite` or `CreateNew`. -`Only .twb or twbx files can be published as workbooks.` | Raises an error if the type of file specified is not supported. +`Invalid mode defined.` | Raises an error if the publish mode is not one of the defined options. +`Workbooks cannot be appended.` | The `mode` must be set to `Overwrite` or `CreateNew`. +`Only .twb or twbx files can be published as workbooks.` | Raises an error if the type of file specified is not supported. See the REST API [Publish Workbook](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#publish_workbook) for additional error codes. **Returns** -The `WorkbookItem` for the workbook that was published. - +The `WorkbookItem` for the workbook that was published. + **Example** @@ -3628,7 +3670,7 @@ with server.auth.sign_in(tableau_auth): ```
    -
    +
    #### workbooks.refresh @@ -3637,24 +3679,24 @@ workbooks.refresh(workbook_item) ``` -Refreshes the extract of an existing workbook. +Refreshes the extract of an existing workbook. REST API: [Update Workbook Now](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooksviews.htm#update_workbook_now) **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `workbook_item` | The `workbook_item` specifies the settings for the workbook you are refreshing. **Exceptions** -Error | Description -:--- | :--- -`Workbook item missing ID. Workbook must be retrieved from server first.` | Raises an error if the `workbook_item` is unspecified. Use the `workbooks.get()` or `workbooks.get_by_id()` methods to retrieve the workbook item from the server. +Error | Description +:--- | :--- +`Workbook item missing ID. Workbook must be retrieved from server first.` | Raises an error if the `workbook_item` is unspecified. Use the `workbooks.get()` or `workbooks.get_by_id()` methods to retrieve the workbook item from the server. -```py +```py import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('username', 'password', site_id='site') @@ -3674,7 +3716,7 @@ with server.auth.sign_in(tableau_auth):
    -
    +
    #### workbooks.update @@ -3689,19 +3731,19 @@ REST API: [Update Workbooks](https://help.tableau.com/current/api/rest_api/en-us **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `workbook_item` | The `workbook_item` specifies the settings for the workbook you are updating. You can change the `owner_id`, `project_id`, and the `show_tabs` values. See [WorkbookItem](#workbookitem-class). **Exceptions** -Error | Description -:--- | :--- -`Workbook item missing ID. Workbook must be retrieved from server first.` | Raises an error if the `workbook_item` is unspecified. Use the `workbooks.get()` or `workbooks.get_by_id()` methods to retrieve the workbook item from the server. +Error | Description +:--- | :--- +`Workbook item missing ID. Workbook must be retrieved from server first.` | Raises an error if the `workbook_item` is unspecified. Use the `workbooks.get()` or `workbooks.get_by_id()` methods to retrieve the workbook item from the server. -```py +```py import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('username', 'password', site_id='site') @@ -3726,7 +3768,7 @@ with server.auth.sign_in(tableau_auth):
    -
    +
    @@ -3740,7 +3782,7 @@ Deletes a workbook with the specified ID. -To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). +To specify the site, create a `TableauAuth` instance using the content URL for the site (`site_id`), and sign in to that site. See the [TableauAuth class](#tableauauth-class). REST API: [Delete Workbook](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#delete_workbook1) @@ -3748,34 +3790,34 @@ REST API: [Delete Workbook](https://help.tableau.com/current/api/rest_api/en-us/ **Parameters** -Name | Description -:--- | :--- -`workbook_id` | The ID of the workbook to delete. +Name | Description +:--- | :--- +`workbook_id` | The ID of the workbook to delete. -**Exceptions** +**Exceptions** + +Error | Description +:--- | :--- +`Workbook ID undefined.` | Raises an exception if the project item does not have an ID. The project ID is sent to the server as part of the URI. -Error | Description -:--- | :--- -`Workbook ID undefined.` | Raises an exception if the project item does not have an ID. The project ID is sent to the server as part of the URI. +**Example** -**Example** - ```py -# import tableauserverclient as TSC -# server = TSC.Server('https://MY-SERVER') -# tableau_auth sign in, etc. +# import tableauserverclient as TSC +# server = TSC.Server('https://MY-SERVER') +# tableau_auth sign in, etc. server.workbooks.delete('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d') -``` +```
    -
    +
    #### workbooks.download @@ -3792,9 +3834,9 @@ REST API: [Download Workbook](https://help.tableau.com/current/api/rest_api/en-u **Parameters** -Name | Description -:--- | :--- -`workbook_id` | The ID for the `WorkbookItem` that you want to download from the server. +Name | Description +:--- | :--- +`workbook_id` | The ID for the `WorkbookItem` that you want to download from the server. `filepath` | (Optional) Downloads the file to the location you specify. If no location is specified, the file is downloaded to the current working directory. The default is `Filepath=None`. `no_extract` | (Optional) Specifies whether to download the file without the extract. When the workbook has an extract, if you set the parameter `no_extract=True`, the extract is not included. You can use this parameter to improve performance if you are downloading workbooks that have large extracts. The default is to include the extract, if present (`no_extract=False`). Available starting with Tableau Server REST API version 2.5. @@ -3802,14 +3844,14 @@ Name | Description **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `Workbook ID undefined` | Raises an exception if a valid `datasource_id` is not provided. -**Returns** +**Returns** -The file path to the downloaded workbook. +The file path to the downloaded workbook. **Example** @@ -3823,7 +3865,7 @@ The file path to the downloaded workbook.
    -
    +
    #### workbooks.populate_views @@ -3832,18 +3874,18 @@ The file path to the downloaded workbook. workbooks.populate_views(workbook_item) ``` -Populates (or gets) a list of views for a workbook. +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. -This method retrieves the view information for the specified workbook. The REST API is designed to return only the information you ask for explicitly. When you query for all the data sources, the view information is not included. Use this method to retrieve the views. The method adds the list of views to the workbook item (`workbook_item.views`). This is a list of `ViewItem`. +This method retrieves the view information for the specified workbook. The REST API is designed to return only the information you ask for explicitly. When you query for all the data sources, the view information is not included. Use this method to retrieve the views. The method adds the list of views to the workbook item (`workbook_item.views`). This is a list of `ViewItem`. REST API: [Query Views for Workbook](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_views_for_workbook) **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `workbook_item` | The `workbook_item` specifies the workbook to populate with views information. See [WorkbookItem class](#workbookitem-class). @@ -3851,14 +3893,14 @@ Name | Description **Exceptions** -Error | Description -:--- | :--- -`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. +Error | Description +:--- | :--- +`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. **Returns** -None. A list of `ViewItem` objects are added to the workbook (`workbook_item.views`). +None. A list of `ViewItem` objects are added to the workbook (`workbook_item.views`). **Example** @@ -3867,14 +3909,14 @@ None. A list of `ViewItem` objects are added to the workbook (`workbook_item.vie # import tableauserverclient as TSC # server = TSC.Server('https://SERVERURL') -# - ... +# + ... # get the workbook item workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d') -# get the view information +# get the view information server.workbooks.populate_views(workbook) # print information about the views for the work item @@ -3886,27 +3928,27 @@ None. A list of `ViewItem` objects are added to the workbook (`workbook_item.vie ```
    -
    +
    #### workbooks.populate_connections -```py +```py workbooks.populate_connections(workbook_item) -``` +``` -Populates a list of data source connections for the specified workbook. +Populates a list of data source connections for the specified workbook. You must populate connections before you can iterate through the connections. -This method retrieves the data source connection information for the specified workbook. The REST API is designed to return only the information you ask for explicitly. When you query all the workbooks, the data source connection information is not included. Use this method to retrieve the connection information for any data sources used by the workbook. The method adds the list of data connections to the workbook item (`workbook_item.connections`). This is a list of `ConnectionItem`. +This method retrieves the data source connection information for the specified workbook. The REST API is designed to return only the information you ask for explicitly. When you query all the workbooks, the data source connection information is not included. Use this method to retrieve the connection information for any data sources used by the workbook. The method adds the list of data connections to the workbook item (`workbook_item.connections`). This is a list of `ConnectionItem`. REST API: [Query Workbook Connections](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_workbook_connections) **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `workbook_item` | The `workbook_item` specifies the workbook to populate with data connection information. @@ -3914,14 +3956,14 @@ Name | Description **Exceptions** -Error | Description -:--- | :--- +Error | Description +:--- | :--- `Workbook item missing ID. Workbook must be retrieved from server first.` | Raises an error if the `workbook_item` is unspecified. **Returns** -None. A list of `ConnectionItem` objects are added to the data source (`workbook_item.connections`). +None. A list of `ConnectionItem` objects are added to the data source (`workbook_item.connections`). **Example** @@ -3930,14 +3972,14 @@ None. A list of `ConnectionItem` objects are added to the data source (`workbook # import tableauserverclient as TSC # server = TSC.Server('https://SERVERURL') -# - ... +# + ... # get the workbook item workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d') -# get the connection information +# get the connection information server.workbooks.populate_connections(workbook) # print information about the data connections for the workbook item @@ -3950,7 +3992,7 @@ None. A list of `ConnectionItem` objects are added to the data source (`workbook ```
    -
    +
    #### workbooks.populate_preview_image @@ -3959,31 +4001,31 @@ None. A list of `ConnectionItem` objects are added to the data source (`workbook workbooks.populate_preview_image(workbook_item) ``` -This method gets the preview image (thumbnail) for the specified workbook item. +This method gets the preview image (thumbnail) for the specified workbook item. -The method uses the `view.id` and `workbook.id` to identify the preview image. The method populates the `workbook_item.preview_image`. +The method uses the `view.id` and `workbook.id` to identify the preview image. The method populates the `workbook_item.preview_image`. REST API: [Query View Preview Image](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#query_workbook_preview_image) -**Parameters** +**Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `view_item` | The view item specifies the `view.id` and `workbook.id` that identifies the preview image. - -**Exceptions** -Error | Description -:--- | :--- -`View item missing ID or workbook ID` | Raises an error if the ID for the view item or workbook is missing. +**Exceptions** + +Error | Description +:--- | :--- +`View item missing ID or workbook ID` | Raises an error if the ID for the view item or workbook is missing. + - **Returns** -None. The preview image is added to the view. +None. The preview image is added to the view. @@ -3995,7 +4037,7 @@ None. The preview image is added to the view. # server = TSC.Server('https://SERVERURL') - ... + ... # get the workbook item workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d') @@ -4004,18 +4046,18 @@ None. The preview image is added to the view. server.workbooks.populate_preview_image(workbook) -``` +```
    -
    +
    #### workbooks.update_connection ```py workbooks.update_conn(workbook_item, connection_item) -``` +``` -Updates a workbook connection information (server address, server port, user name, and password). +Updates a workbook connection information (server address, server port, user name, and password). The workbook connections must be populated before the strings can be updated. See [workbooks.populate_connections](#workbooks.populate_connections) @@ -4023,23 +4065,23 @@ REST API: [Update Workbook Connection](https://help.tableau.com/current/api/res **Parameters** -Name | Description -:--- | :--- +Name | Description +:--- | :--- `workbook_item` | The `workbook_item` specifies the workbook to populate with data connection information. -`connection_item` | The `connection_item` that has the information you want to update. +`connection_item` | The `connection_item` that has the information you want to update. **Returns** -None. The connection information is updated with the information in the `ConnectionItem`. +None. The connection information is updated with the information in the `ConnectionItem`. **Example** -```py +```py # query for workbook connections server.workbooks.populate_connections(workbook) @@ -4054,7 +4096,7 @@ server.workbooks.update_conn(workbook, connection) ```
    -
    +
    #### workbooks.populate_pdf ``` diff --git a/docs/dev-guide.md b/docs/dev-guide.md index 46c560d7b..ea68a523d 100644 --- a/docs/dev-guide.md +++ b/docs/dev-guide.md @@ -32,7 +32,7 @@ add your contributions to the **development** branch. git clone git@github.com:/server-client-python.git ``` -1. Run the tests to make sure everything is peachy: +1. Run the tests to make sure everything is passing: ```shell python setup.py test @@ -95,6 +95,9 @@ Here's a quick checklist to follow when coding to ensure a good pull request 1. Add a sample to show users how to use the new feature. +1. Add documentation (most likely in api-ref.md) in a separate pull request + (see more below). + ### Add tests All of our tests live under the `test/` folder in the repository. We use @@ -153,15 +156,15 @@ go together. To preview and run the documentation locally, these are the steps: -1. Install [Ruby](https://www.ruby-lang.org/en/downloads/) (v2.5.0 or higher) +1. Install [Ruby](https://www.ruby-lang.org/en/documentation/installation/) (v2.5.0 or higher). -1. Install [Bundler](https://bundler.io/) +1. Install [Bundler](https://bundler.io/). -1. Install [Jekyll](https://jekyllrb.com/docs/installation/) +1. Install the project dependencies (which includes Jekyll) by running `bundle install`. (In the future you can run `bundle update` to catch any new dependencies.) -1. Run the Jekyll site locally with `bundle exec jekyll serve` +1. Run the Jekyll site locally with `bundle exec jekyll serve`. -1. In your browser, connect to +1. In your browser, connect to to preview the changes. As long as the Jekyll serve process is running, it will rebuild any new file changes automatically. -For more details on the steps, see the GitHub Pages topic on +For more details, see the GitHub Pages topic on [testing locally](https://docs.github.com/en/github/working-with-github-pages/testing-your-github-pages-site-locally-with-jekyll). diff --git a/docs/index.md b/docs/index.md index 4687be3be..81728594f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -19,10 +19,9 @@ This section describes how to: Before you install TSC, confirm that you have the following dependencies installed: -* Python. You can use TSC with Python 3.5 or later. +* Python. You can use TSC with Python 3.5 or later. * Git. Optional, but recommended to download the samples or install from the source code. - ## Install TSC You can install TSC with pip or from the source code. @@ -31,7 +30,7 @@ You can install TSC with pip or from the source code. Run the following command to install the latest stable version of TSC: -``` +```shell pip install tableauserverclient ``` @@ -40,7 +39,7 @@ pip install tableauserverclient You can install from the development branch for a preview of upcoming features. Run the following command to install from the development branch: -``` +```shell pip install git+https://github.com/tableau/server-client-python.git@development ``` @@ -49,13 +48,15 @@ development version are subject to change at any time before the next stable rel ### Install on an offline machine -To install TSC onto a machine without internet connection, use the following steps: +To install TSC onto a machine without an internet connection, use the following steps: + +1) Ensure that Python 3.5 or higher is installed. -1) Download and manually install the **requests** python library (and its dependencies). +2) Download and manually install the `requests` Python library (and its dependencies). -2) Download the [setup package](https://pypi.org/project/tableauserverclient/#files){:target="_blank"}. +3) Download the [setup package](https://pypi.org/project/tableauserverclient/#files){:target="_blank"}. -3) Run `pip install ./downloads/tableauserverclient-x.x.tar.gz` +4) Run `pip install ./tableauserverclient-x.y.tar.gz` ## Get the samples diff --git a/docs/samples.md b/docs/samples.md index b9e9aae3d..ed6533e18 100644 --- a/docs/samples.md +++ b/docs/samples.md @@ -21,7 +21,7 @@ the arguments required by a particular sample, run the sample with the `-h` flag For example, if you run the following command: -``` +```shell python samples/publish_workbook.py -h ``` diff --git a/docs/sign-in-out.md b/docs/sign-in-out.md index d1bdc197f..8fd1c1b26 100644 --- a/docs/sign-in-out.md +++ b/docs/sign-in-out.md @@ -3,46 +3,117 @@ title: Sign In and Out layout: docs --- -To sign in and out of Tableau Server, call the server's `.auth.signin` method in a `with` block. +The first step to using the TSC library is to sign in to your Tableau Server (or Tableau Online). This page explains how to sign in, sign out, and switch sites, with examples for both Tableau Server and Tableau Online. + +* TOC +{:toc} + +## Sign In + +Signing in can be done two different ways: + +* Personal Access Tokens - In most cases this is the preferred method because it improves security by avoiding the need to use or store passwords directly. Access tokens also expire by default if not used after 15 consecutive days. This option is available for Tableau Server 2019.4 and newer. Refer to [Personal Access Tokens](https://help.tableau.com/current/server/en-us/security_personal_access_tokens.htm) for more details. +* Username and Password - Direct sign in with account username and password. + +Examples showing both of these cases are included below. + +**Note:** When you sign in, the TSC library manages the authenticated session for you. However, the validity of the underlying credentials token is limited by the maximum session length set on your Tableau Server (2 hours by default). + +### Sign in with Personal Access Token + +To sign in to Tableau Server or Tableau Online with a personal access token, you'll need the following values: + +Name | Description +:--- | :--- +TOKEN_NAME | The personal access token name (from the My Account settings page) +TOKEN_VALUE | The personal access token value (from the My Account settings page) +**Tableau Server** | +SITENAME | The Tableau Server site you are authenticating with; for example in the site URL http://MyServer/#/site/MarketingTeam/projects, the site name is MarketingTeam; in the REST API documentation this field is also referred to as contentUrl; this value can be omitted to connect with the Default site on the server +SERVER_URL | The Tableau Server you are authenticating with; if your server has SSL enabled, this should be an HTTPS link +**Tableau Online** | +SITENAME | The Tableau Online site you are authenticating with; for example in the site URL https://10ay.online.tableau.com/#/site/umbrellacorp816664/workbooks, the site name is umbrellacorp816664; in the REST API documentation this field is also referred to as contentUrl; this value is always required when connecting to Tableau Online +SERVER_URL | The Tableau Online instance you are authenticating with; in the example above the server URL would be https://10ay.online.tableau.com; this will always be an an HTTPS link + +This example illustrates using the above values to sign in with a personal access token, do some operations, and then sign out: + +```py +import tableauserverclient as TSC + +tableau_auth = TSC.PersonalAccessTokenAuth('TOKEN_NAME', 'TOKEN_VALUE', 'SITENAME') +server = TSC.Server('https://SERVER_URL', use_server_version=True) +server.auth.sign_in(tableau_auth) + +# Do awesome things here! + +server.auth.sign_out() +``` + +### Sign in with Username and Password + +To sign in to Tableau Server or Tableau Online with a username and password, you'll need the following values: + +Name | Description +:--- | :--- +USERNAME | The user name +PASSWORD | The user password +SITENAME | The same as described in the previous section +SERVER_URL | The same as described in the previous section + +This example illustrates using the above values to sign in with a username and password, do some operations, and then sign out: ```py import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', 'SITENAME') -# or for a personal access token -# tableau_auth = TSC.PersonalAccessTokenAuth('TOKEN_NAME', 'TOKEN_VALUE', 'SITENAME') -server = TSC.Server('https://SERVER_URL') +server = TSC.Server('https://SERVER_URL', use_server_version=True) +server.auth.sign_in(tableau_auth) -with server.auth.sign_in(tableau_auth): - # Do awesome things here! +# Do awesome things here! + +server.auth.sign_out() ``` -`SERVER_URL` is the URL of your Tableau server without subpaths. For local Tableau servers, an example would be: `https://www.MY_SERVER.com`. For Tableau Online, an example would be: `https://10ax.online.tableau.com/`. +## Sign Out -`SITENAME` is the subpath of your full site URL (also called `contentURL` in the REST API). `MYSITE` would be the site name of `https://10ax.online.tableau.com/MYSITE`. This parameter can be omitted when signing in to the Default site of an on-premise Tableau server. +Signing out cleans up the current session and invalidates the authentication token being held by the TSC library. -`TOKEN_NAME` and `TOKEN_VALUE` are your [Personal Access Token](https://help.tableau.com/current/server/en-us/security_personal_access_tokens.htm) values, generated in your Account Settings. +As shown in the examples above, the sign out call is simply: -Optionally, you can override the version of Tableau API you are authorizing against by adding `server.version = ''` before the `auth.signin` call. +```py +server.auth.sign_out() +``` -The TSC library signs you out of Tableau Server when you exit out of the `with` block. +## Simplify by using Python with block -
    - **Note:** When you sign in, the TSC library manages the authenticated session for you, however the validity of the underlying - credentials token is limited by the maximum session length set on your Tableau Server (2 hours by default). -
    +The sign in/out flow can be simplified (and handled in a more Python way) by using the built-in support for the `with` block. After the block execution completes, the sign out is called automatically. -An alternative to using a `with` block is to call the `Auth.sign_in` and `Auth.sign_out` functions explicitly: +For example: ```py import tableauserverclient as TSC -tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD') # with no site name, this will use the Default site -server = TSC.Server('http://SERVER_URL') +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) +``` -server.auth.sign_in(tableau_auth) +All of the samples provided in TSC library use this technique. -# Do awesome things here! +## Switch Site -server.auth.sign_out() +Tableau Server has a feature which enables switching to another site without having to authenticate again. (The user must have access permissions for the new site as well.) + +**Note:** This method is not available on Tableau Online. + +The following example will switch the authenticated user to the NEW_SITENAME site on the same server: + +```py +# assume we already have an authenticated server object + +server.auth.switch_site('NEW_SITENAME') ``` diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md new file mode 100644 index 000000000..16ae51a11 --- /dev/null +++ b/docs/troubleshooting.md @@ -0,0 +1,54 @@ +--- +title: Troubleshooting +layout: docs +--- + +This page covers some common troubleshooting tips for using the TSC library. + +
    + Warning: Do not post any debug logs or REST API request/response contents anywhere on GitHub. The contents may include sensitive data or authentication secrets. Instead you can post just edited snippets of relevant content after sanitizing (removing any sensitive values). +
    + +* TOC +{:toc} + +## Logging REST API communication with Tableau Server + +There may be cases where it's helpful to inspect the REST API calls the TSC library is making and the responses coming back from Tableau Server. Some examples might be: + +* The TSC library is throwing an error or the results are not coming through as expected +* The TSC library or the REST backend may have a bug which needs to be tracked down + +To enable logging, add the following to your Python script ahead of making any TSC calls: + +```py +import logging +logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + filename="tsc.log", level="DEBUG") +``` + +Now when your script executes, you'll see a set of debug messages in the `tsc.log` file. Each API call to the REST API will be included along with the XML responses. Depending on the problem being investigated, you can compare these requests/responses to the [REST API documentation](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api.htm) to track down the issue. + +## Capture REST API communication with local proxy + +Another approach for inspecting REST API traffic is to use a local debugging proxy server like [Fiddler Everywhere](https://www.telerik.com/fiddler). Fiddler Everywhere is free for basic use and has versions for Mac, Windows and Linux. + +These are the steps to send the API traffic through to a local proxy like Fiddler: + +1. Install Fiddler Everywhere and create a free account if needed +2. Launch the Fiddler app and click the settings (gear) icon to enable Capture HTTPS traffic. (Do not click Trust root certificate.) +3. Before running your script, set the following environment variables (on Windows, use SET commands instead): +```shell +export HTTP_PROXY=127.0.0.1:8866 +export HTTPS_PROXY=127.0.0.1:8866 +export CURL_CA_BUNDLE="" +export PYTHONWARNINGS="ignore:Unverified HTTPS request" +``` +4. Run your script +5. Check Fiddler Everywhere for the results + +The sample screenshot below shows the results of running a simple sign in/out sequence. The Capture pane includes one row for each HTTP request. Select the request to see the details on the right side: Request and Response. + +![Fiddler Everywhere Screenshot](../assets/fiddler.png) + +Proxy server applications other than Fiddler can be used as well. Just adjust the HTTP_PROXY and HTTPS_PROXY environment variables to use the proper IP address and port number. diff --git a/docs/versions.md b/docs/versions.md index 70076aa6e..b8f824f6e 100644 --- a/docs/versions.md +++ b/docs/versions.md @@ -6,6 +6,8 @@ layout: docs Because the TSC library is a client for the Tableau Server REST API, you need to confirm that the version of the TSC library that you use is compatible with the version of the REST API used by your installation of Tableau Server. +For reference, the [REST API and Resource Versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm) page has more details about versions. + * TOC {:toc} @@ -21,11 +23,11 @@ server = TSC.Server('http://SERVER_URL') print(server.version) ``` -For example, the code might display version `2.3`. +For example, the code might display version `2.3`. ## Use the REST API version supported by the server -There are two options for always using the the latest version of the REST API that is supported by the instance of Tableau Server you are connecting to. +There are two options for always using the the latest version of the REST API that is supported by the instance of Tableau Server you are connecting to. This could be necessary in cases where you're using an API feature that is only supported in a newer REST API version. The first method is to specify `use_server_version=True` as one of the arguments, for example: @@ -52,7 +54,7 @@ To use a specific version of the REST API, set the version like so: import tableauserverclient as TSC server = TSC.Server('http://SERVER_URL') -server.version = '2.6' +server.version = '3.6' ``` @@ -62,6 +64,7 @@ The current version of TSC only supports the following REST API and Tableau Serv |REST API version|Tableau Server version| |---|---| +|3.9|2020.3| |3.8|2020.2| |3.7|2020.1| |3.6|2019.4|