-
Notifications
You must be signed in to change notification settings - Fork 446
Tasks Documentation #525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tasks Documentation #525
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2709,6 +2709,215 @@ The `SubscriptionItem`. See [SubscriptionItem class](#subscriptionitem-class) | |
| <br> | ||
| <br> | ||
|
|
||
| --- | ||
|
|
||
| ## Tasks | ||
|
|
||
| Using the TSC library, you can get information about all the tasks on a site and you can remove tasks. To create new tasks see [Schedules](#schedules). | ||
|
|
||
| The task resources for Tableau Server are defined in the `TaskItem` class. The class corresponds to the task resources you can access using the Tableau Server REST API. The task methods are based upon the endpoints for tasks in the REST API and operate on the `TaskItem` class. | ||
|
|
||
| ### TaskItem class | ||
|
|
||
| ```py | ||
| TaskItem(id, task_type, priority, consecutive_failed_count=0, schedule_id=None, target=None) | ||
| ``` | ||
|
|
||
| **Attributes** | ||
|
|
||
| Name | Description | ||
| :--- | :--- | ||
| `consecutive_failed_count` | The number of failed consecutive executions. | ||
| `id` | The id of the task on the site. | ||
| `priority` | The priority of the task on the server. | ||
| `schedule_id` | The id of the schedule on the site. | ||
| `target` | An object, `datasource` or `workbook` which is associated to the task. Source file: models/target.py | ||
| `task_type` | Type of extract task - full or incremental refresh. | ||
|
|
||
|
|
||
| **Example** | ||
|
|
||
| ```py | ||
| # import tableauserverclient as TSC | ||
| # server = TSC.Server('server') | ||
|
|
||
| task = server.tasks.get_by_id('9f9e9d9c-8b8a-8f8e-7d7c-7b7a6f6d6e6d') | ||
| print(task) | ||
|
|
||
| ``` | ||
|
|
||
| Source file: models/task_item.py | ||
|
|
||
| <br> | ||
| <br> | ||
|
|
||
|
|
||
| ### Tasks methods | ||
|
|
||
| The Tableau Server Client provides several methods for interacting with task resources, or endpoints. These methods correspond to endpoints in the Tableau Server REST API. | ||
|
|
||
| Source file: server/endpoint/tasks_endpoint.py | ||
| <br> | ||
| <br> | ||
|
|
||
| #### tasks.get | ||
|
|
||
| ```py | ||
| tasks.get(req_options=None) | ||
| ``` | ||
|
|
||
| Returns information about the tasks on the specified site. | ||
|
|
||
| REST API: [Get Extract Refresh Tasks on Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#get_extract_refresh_tasks){:target="_blank"} | ||
|
|
||
|
|
||
| **Parameters** | ||
|
|
||
| Name | Description | ||
| :--- | : --- | ||
| `req_option` | (Optional) You can pass the method a request object that contains additional parameters to filter the request. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be req_options plural to match |
||
|
|
||
|
|
||
| **Returns** | ||
|
|
||
| Returns a list of `TaskItem` objects and a `PaginationItem` object. Use these values to iterate through the results. | ||
|
|
||
|
|
||
| **Example** | ||
|
|
||
|
|
||
| ```py | ||
| import tableauserverclient as TSC | ||
| tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD') | ||
| server = TSC.Server('https://SERVERURL') | ||
|
|
||
| with server.auth.sign_in(tableau_auth): | ||
| all_tasks, pagination_item = server.tasks.get() | ||
| print("\nThere are {} tasks on site: ".format(pagination_item.total_available)) | ||
| print([task.id for task in all_tasks]) | ||
| ``` | ||
|
|
||
| <br> | ||
| <br> | ||
|
|
||
| #### tasks.get_by_id | ||
|
|
||
|
|
||
| ```py | ||
| tasks.get_by_id(task_id) | ||
| ``` | ||
|
|
||
| Returns information about the specified task. | ||
|
|
||
| REST API: [Query Extract Refresh Task On Site](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#get_extract_refresh_task){:target="_blank"} | ||
|
|
||
|
|
||
| **Parameters** | ||
|
|
||
| Name | Description | ||
| :--- | : --- | ||
| `task_id` | The `task_id` specifies the task to query. | ||
|
|
||
|
|
||
| **Exceptions** | ||
|
|
||
| Error | Description | ||
| :--- | : --- | ||
| `Task ID undefined.` | Raises an exception if a valid `task_id` is not provided. | ||
|
|
||
|
|
||
| **Returns** | ||
|
|
||
| The `TaskItem`. See [TaskItem class](#taskitem-class) | ||
|
|
||
|
|
||
| **Example** | ||
|
|
||
| ```py | ||
| task1 = server.tasks.get_by_id('9f9e9d9c-8b8a-8f8e-7d7c-7b7a6f6d6e6d') | ||
| print(task1.task_type) | ||
|
|
||
| ``` | ||
|
|
||
| <br> | ||
| <br> | ||
|
|
||
| #### tasks.run | ||
|
|
||
|
|
||
| ```py | ||
| tasks.run(task_item) | ||
| ``` | ||
|
|
||
| Runs the specified extract refresh task. | ||
|
|
||
| To run a extract refresh task you need to first lookup the task `task_item` (`TaskItem` class). | ||
|
|
||
| REST API: [Run Extract Refresh Task](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#run_extract_refresh_task){:target="_blank"} | ||
|
|
||
|
|
||
| **Parameters** | ||
|
|
||
| Name | Description | ||
| :--- | : --- | ||
| `task_item` | You can pass the method a task object. | ||
|
|
||
|
|
||
| **Returns** | ||
|
|
||
| Returns the REST API response. | ||
|
|
||
| **Example** | ||
|
|
||
| ```py | ||
| # import tableauserverclient as TSC | ||
| # server = TSC.Server('server') | ||
| # login, etc. | ||
|
|
||
| task = server.tasks.get_by_id('9f9e9d9c-8b8a-8f8e-7d7c-7b7a6f6d6e6d') | ||
| server.tasks.run(task) | ||
|
|
||
| ``` | ||
|
|
||
| <br> | ||
| <br> | ||
|
|
||
| #### tasks.delete | ||
|
|
||
|
|
||
| ```py | ||
| tasks.delete(task_id) | ||
| ``` | ||
|
|
||
| Deletes an extract refresh task. | ||
|
|
||
| REST API: [Run Extract Refresh Task](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_jobstasksschedules.htm#delete_workbook){:target="_blank"} | ||
|
|
||
| **Parameters** | ||
|
|
||
| Name | Description | ||
| :--- | : --- | ||
| `task_id` | The `task_id` specifies the task to delete. | ||
|
|
||
|
|
||
| **Exceptions** | ||
|
|
||
| Error | Description | ||
| :--- | : --- | ||
| `Task ID undefined.` | Raises an exception if a valid `task_id` is not provided. | ||
|
|
||
|
|
||
| **Example** | ||
|
|
||
| ```py | ||
| server.tasks.delete('9f9e9d9c-8b8a-8f8e-7d7c-7b7a6f6d6e6d') | ||
|
|
||
| ``` | ||
|
|
||
| <br> | ||
| <br> | ||
|
|
||
|
|
||
| --- | ||
|
|
||
| ## Users | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest reordering these to be in the order shown in TaskItem class above, so id, task_type, ...).