8000 docs: task docstrings (#1527) · tableau/server-client-python@9ba445b · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ba445b

Browse files
authored
docs: task docstrings (#1527)
Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent 7a45224 commit 9ba445b

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

tableauserverclient/models/task_item.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,36 @@
99

1010

1111
class TaskItem:
12+
"""
13+
Represents a task item in Tableau Server. To create new tasks, see Schedules.
14+
15+
Parameters
16+
----------
17+
id_ : str
18+
The ID of the task.
19+
20+
task_type : str
21+
Type of task. See TaskItem.Type for possible values.
22+
23+
priority : int
24+
The priority of the task on the server.
25+
26+
consecutive_failed_count : int
27+
The number of consecutive times the task has failed.
28+
29+
schedule_id : str, optional
30+
The ID of the schedule that the task is associated with.
31+
32+
schedule_item : ScheduleItem, optional
33+
The schedule item that the task is associated with.
34+
35+
last_run_at : datetime, optional
36+
The last time the task was run.
37+
38+
target : Target, optional
39+
The target of the task. This can be a workbook or a datasource.
40+
"""
41+
1242
class Type:
1343
ExtractRefresh = "extractRefresh"
1444
DataAcceleration = "dataAcceleration"

tableauserverclient/server/endpoint/tasks_endpoint.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ def __normalize_task_type(self, task_type: str) -> str:
3131
def get(
3232
self, req_options: Optional["RequestOptions"] = None, task_type: str = TaskItem.Type.ExtractRefresh
3333
) -> tuple[list[TaskItem], PaginationItem]:
34+
"""
35+
Returns information about tasks on the specified site.
36+
37+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_jobs_tasks_and_schedules.htm#list_extract_refresh_tasks
38+
39+
Parameters
40+
----------
41+
req_options : RequestOptions, optional
42+
Options for the request, such as filtering, sorting, and pagination.
43+
44+
task_type : str, optional
45+
The type of task to query. See TaskItem.Type for possible values.
46+
47+
Returns
48+
-------
49+
tuple[list[TaskItem], PaginationItem]
50+
51+
"""
3452
if task_type == TaskItem.Type.DataAcceleration:
3553
self.parent_srv.assert_at_least_version("3.8", "Data Acceleration Tasks")
3654

@@ -45,6 +63,20 @@ def get(
4563

4664
@api(version="2.6")
4765
def get_by_id(self, task_id: str) -> TaskItem:
66+
"""
67+
Returns information about the specified task.
68+
69+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_jobs_tasks_and_schedules.htm#get_extract_refresh_task
70+
71+
Parameters
72+
----------
73+
task_id : str
74+
The ID of the task to query.
75+
76+
Returns
77+
-------
78+
TaskItem
79+
"""
4880
if not task_id:
4981
error = "No Task ID provided"
5082
raise ValueError(error)
@@ -59,6 +91,21 @@ def get_by_id(self, task_id: str) -> TaskItem:
5991

6092
@api(version="3.19")
6193
def create(self, extract_item: TaskItem) -> TaskItem:
94+
"""
95+
Creates a custom schedule for an extract refresh on Tableau Cloud. For
96+
Tableau Server, use the Schedules endpoint to create a schedule.
97+
98+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#create_cloud_extract_refresh_task
99+
100+
Parameters
101+
----------
102+
extract_item : TaskItem
103+
The extract refresh task to create.
104+
105+
Returns
106+
-------
107+
TaskItem
108+
"""
62109
if not extract_item:
63110
error = "No extract refresh provided"
64111
raise ValueError(error)
@@ -70,6 +117,20 @@ def create(self, extract_item: TaskItem) -> TaskItem:
70117

71118
@api(version="2.6")
72119
def run(self, task_item: TaskItem) -> bytes:
120+
"""
121+
Runs the specified extract refresh task.
122+
123+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_jobs_tasks_and_schedules.htm#run_extract_refresh_task
124+
125+
Parameters
126+
----------
127+
task_item : TaskItem
128+
The task to run.
129+
130+
Returns
131+
-------
132+
bytes
133+
"""
73134
if not task_item.id:
74135
error = "Task item missing ID."
75136
raise MissingRequiredFieldError(error)
@@ -86,6 +147,23 @@ def run(self, task_item: TaskItem) -> bytes:
86147
# Delete 1 task by id
87148
@api(version="3.6")
88149
def delete(self, task_id: str, task_type: str = TaskItem.Type.ExtractRefresh) -> None:
150+
"""
151+
Deletes the specified extract refresh task on Tableau Server or Tableau Cloud.
152+
153+
REST API: https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#delete_extract_refresh_task
154+
155+
Parameters
156+
----------
157+
task_id : str
158+
The ID of the task to delete.
159+
160+
task_type : str, default TaskItem.Type.ExtractRefresh
161+
The type of task to query. See TaskItem.Type for possible values.
162+
163+
Returns
164+
-------
165+
None
166+
"""
89167
if task_type == TaskItem.Type.DataAcceleration:
90168
self.parent_srv.assert_at_least_version("3.8", "Data Acceleration Tasks")
91169

0 commit comments

Comments
 (0)
0