8000 update samples page, add workbook.refresh, adddatasource.refresh · rmagier1/server-client-python@09da89f · GitHub
[go: up one dir, main page]

Skip to content

Commit 09da89f

Browse files
committed
update samples page, add workbook.refresh, adddatasource.refresh
1 parent 079bf08 commit 09da89f

File tree

2 files changed

+128
-12
lines changed

2 files changed

+128
-12
lines changed

docs/api-ref.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,53 @@ The `DatasourceItem` for the data source that was added or appended to.
564564
<br>
565565
<br>
566566

567+
#### datasources.refresh
568+
569+
```py
570+
datasource.refresh(datasource_item)
571+
```
572+
573+
Refreshes the data of the specified extract.
574+
575+
REST API: [Refresh Datasource](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_datasources.htm#update_data_source_now){:target="_blank"}
576+
577+
**Parameters**
578+
579+
Name | Description
580+
:--- | : ---
581+
`datasource_item` | The `datasource_item` specifies the data source to update.
582+
583+
584+
585+
**Exceptions**
586+
587+
Error | Description
588+
:--- | : ---
589+
`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.
590+
591+
592+
**Returns**
593+
594+
An refreshed `DatasourceItem`.
595+
596+
597+
**Example**
598+
599+
```py
600+
# import tableauserverclient as TSC
601+
# server = TSC.Server('https://SERVERURL')
602+
# sign in ...
603+
604+
# get the data source item to update
605+
datasource = server.datasources.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b')
606+
607+
# call the refresh method with the data source item
608+
refreshed_datasource = server.datasources.refresh(datasource)
609+
610+
```
611+
<br>
612+
<br>
613+
567614
#### datasources.update
568615

569616
```py
@@ -3570,6 +3617,52 @@ with server.auth.sign_in(tableau_auth):
35703617
<br>
35713618
<br>
35723619

3620+
#### workbooks.refresh
3621+
3622+
```py
3623+
workbooks.refresh(workbook_item)
3624+
```
3625+
3626+
3627+
Refreshes the extract of an existing workbook. The workbook item must include the workbook ID and overrides the existing settings.
3628+
3629+
REST API: [Update Workbook Now](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_workbooksviews.htm#update_workbook_now){:target="_blank"}
3630+
3631+
**Parameters**
3632+
3633+
Name | Description
3634+
:--- | :---
3635+
`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).
3636+
3637+
3638+
**Exceptions**
3639+
3640+
Error | Description
3641+
:--- | :---
3642+
`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.
3643+
3644+
3645+
```py
3646+
3647+
import tableauserverclient as TSC
3648+
tableau_auth = TSC.TableauAuth('username', 'password', site_id='site')
3649+
server = TSC.Server('https://servername')
3650+
3651+
with server.auth.sign_in(tableau_auth):
3652+
3653+
# get the workbook item from the site
3654+
workbook = server.workbooks.get_by_id('1a1b1c1d-2e2f-2a2b-3c3d-3e3f4a4b4c4d')
3655+
3656+
# call the update method
3657+
workbook = server.workbooks.refresh(workbook)
3658+
print("\nThe data of workbook {0} is refreshed.".format(workbook.name))
3659+
3660+
3661+
```
3662+
3663+
3664+
<br>
3665+
<br>
357 6D40 33666

35743667
#### workbooks.update
35753668

docs/samples.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Samples
33
layout: docs
44
---
55

6-
The TSC samples are included in the `samples` directory of the TSC repository [on Github](https://github.com/tableau/server-client-python).
6+
The TSC samples are included in the `samples` directory of the TSC repository [on Github](https://github.com/tableau/server-client-python/tree/master/samples).
77

88
* TOC
99
{:toc}
@@ -32,24 +32,47 @@ publish.
3232

3333
The following list describes the samples available in the repository:
3434

35-
* `create_group.py`. Create a user group.
35+
* `create_group.py` Create a user group.
3636

37-
* `create_schedules.py`. Create schedules for extract refreshes and subscriptions.
37+
* `create_project.py` Creates a project in a site.
3838

39-
* `explore_datasource.py`. Queries datasources, selects a datasource, populates connections for the datasource, then updates the datasource.
39+
* `create_schedules.py` Create schedules for extract refreshes and subscriptions.
4040

41-
* `explore_workbook.py`. Queries workbooks, selects a workbook, populates the connections and views for a workbook, then updates the workbook.
41+
* `download_view_image.py` Downloads an image of a specified view.
4242

43-
* `move_workbook_projects.py`. Updates the properties of a workbook to move the workbook from one project to another.
43+
* `explore_datasource.py` Queries datasources, selects a datasource, populates connections for the datasource, then updates the datasource.
4444

45-
* `move_workbook_sites.py`. Downloads a workbook, stores it in-memory, and uploads it to another site.
45+
* `explore_workbook.py` Queries workbooks, selects a workbook, populates the connections and views for a workbook, then updates the workbook.
4646

47-
* `pagination_sample.py`. Use the Pager generator to iterate over all the items on the server.
47+
* `export.py` Exports a view as an image, pdf, or csv.
4848

49-
* `publish_workbook.py`. Publishes a Tableau workbook.
49+
* `export_wb.py` Exports a pdf containing all views in a workbook.
5050

51-
* `set_http_options.py`. Sets HTTP options for the server and specifically for downloading workbooks.
51+
* `filter_sort_groups.py` Demonstrates selecting user groups as filters.
5252

53-
**Note**: For all of the samples, ensure that your Tableau Server user account has permission to access the resources
54-
requested by the samples.
53+
* `initialize_server.py` Sets up an existing server instance with site, workbooks and datasources.
54+
55+
* `kill_all_jobs.py` Kills all running jobs.
56+
57+
* `list.py` Lists all datasources or workbooks of a site.
58+
59+
* `move_workbook_projects.py` Updates the properties of a workbook to move the workbook from one project to another.
60+
61+
* `move_workbook_sites.py` Downloads a workbook, stores it in-memory, and uploads it to another site.
62+
63+
* `pagination_sample.py` Use the Pager generator to iterate over all the items on the server.
64+
65+
* `publish_workbook.py` Publishes a Tableau workbook.
66+
67+
* `refresh.py` Refreshes a datasource or workbook.
68+
69+
* `refresh_tasks.py` Lists and runs configured tasks on a server.
70+
71+
* `set_http_options.py` Sets HTTP options for the server and specifically for downloading workbooks.
72+
73+
* `set_refresh_schedule.py` Sets the schedule to refresh a datasource or workbook.
74+
75+
* `update_connection.py` Updates and embeds connection credentials of a datasource.
76+
77+
**Note**: For all of the samples, ensure that your Tableau Server user account has permission to access the resources.
5578

0 commit comments

Comments
 (0)
0