tasks
Creates, updates, deletes, gets or lists a tasks
resource.
Overview
Name | tasks |
Type | Resource |
Id | google.cloudtasks.tasks |
Fields
The following fields are returned by SELECT
queries:
- get
- list
Successful response
Name | Datatype | Description |
---|---|---|
name | string | Optionally caller-specified in CreateTask. The task name. The task name must have the following format: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID * PROJECT_ID can contain letters ([A-Za-z]), numbers ([0-9]), hyphens (-), colons (:), or periods (.). For more information, see Identifying projects * LOCATION_ID is the canonical ID for the task's location. The list of available locations can be obtained by calling ListLocations. For more information, see https://cloud.google.com/about/locations/. * QUEUE_ID can contain letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100 characters. * TASK_ID can contain only letters ([A-Za-z]), numbers ([0-9]), hyphens (-), or underscores (_). The maximum length is 500 characters. |
appEngineHttpRequest | object | HTTP request that is sent to the App Engine app handler. An App Engine task is a task that has AppEngineHttpRequest set. (id: AppEngineHttpRequest) |
createTime | string (google-datetime) | Output only. The time that the task was created. create_time will be truncated to the nearest second. |
dispatchCount | integer (int32) | Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response. |
dispatchDeadline | string (google-duration) | The deadline for requests sent to the worker. If the worker does not respond by this deadline then the request is cancelled and the attempt is marked as a DEADLINE_EXCEEDED failure. Cloud Tasks will retry the task according to the RetryConfig. Note that when the request is cancelled, Cloud Tasks will stop listening for the response, but whether the worker stops processing depends on the worker. For example, if the worker is stuck, it may not react to cancelled requests. The default and maximum values depend on the type of request: * For HTTP tasks, the default is 10 minutes. The deadline must be in the interval [15 seconds, 30 minutes]. * For App Engine tasks, 0 indicates that the request has the default deadline. The default deadline depends on the scaling type of the service: 10 minutes for standard apps with automatic scaling, 24 hours for standard apps with manual and basic scaling, and 60 minutes for flex apps. If the request deadline is set, it must be in the interval [15 seconds, 24 hours 15 seconds]. Regardless of the task's dispatch_deadline , the app handler will not run for longer than than the service's timeout. We recommend setting the dispatch_deadline to at most a few seconds more than the app handler's timeout. For more information see Timeouts. The value must be given as a string that indicates the length of time (in seconds) followed by s (for "seconds"). For more information on the format, see the documentation for Duration. dispatch_deadline will be truncated to the nearest millisecond. The deadline is an approximate deadline. |
firstAttempt | object | Output only. The status of the task's first attempt. Only dispatch_time will be set. The other Attempt information is not retained by Cloud Tasks. (id: Attempt) |
httpRequest | object | HTTP request that is sent to the worker. An HTTP task is a task that has HttpRequest set. (id: HttpRequest) |
lastAttempt | object | Output only. The status of the task's last attempt. (id: Attempt) |
responseCount | integer (int32) | Output only. The number of attempts which have received a response. |
scheduleTime | string (google-datetime) | The time when the task is scheduled to be attempted or retried. schedule_time will be truncated to the nearest microsecond. |
view | string | Output only. The view specifies which subset of the Task has been returned. |
Successful response
Name | Datatype | Description |
---|---|---|
name | string | Optionally caller-specified in CreateTask. The task name. The task name must have the following format: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID * PROJECT_ID can contain letters ([A-Za-z]), numbers ([0-9]), hyphens (-), colons (:), or periods (.). For more information, see Identifying projects * LOCATION_ID is the canonical ID for the task's location. The list of available locations can be obtained by calling ListLocations. For more information, see https://cloud.google.com/about/locations/. * QUEUE_ID can contain letters ([A-Za-z]), numbers ([0-9]), or hyphens (-). The maximum length is 100 characters. * TASK_ID can contain only letters ([A-Za-z]), numbers ([0-9]), hyphens (-), or underscores (_). The maximum length is 500 characters. |
appEngineHttpRequest | object | HTTP request that is sent to the App Engine app handler. An App Engine task is a task that has AppEngineHttpRequest set. (id: AppEngineHttpRequest) |
createTime | string (google-datetime) | Output only. The time that the task was created. create_time will be truncated to the nearest second. |
dispatchCount | integer (int32) | Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response. |
dispatchDeadline | string (google-duration) | The deadline for requests sent to the worker. If the worker does not respond by this deadline then the request is cancelled and the attempt is marked as a DEADLINE_EXCEEDED failure. Cloud Tasks will retry the task according to the RetryConfig. Note that when the request is cancelled, Cloud Tasks will stop listening for the response, but whether the worker stops processing depends on the worker. For example, if the worker is stuck, it may not react to cancelled requests. The default and maximum values depend on the type of request: * For HTTP tasks, the default is 10 minutes. The deadline must be in the interval [15 seconds, 30 minutes]. * For App Engine tasks, 0 indicates that the request has the default deadline. The default deadline depends on the scaling type of the service: 10 minutes for standard apps with automatic scaling, 24 hours for standard apps with manual and basic scaling, and 60 minutes for flex apps. If the request deadline is set, it must be in the interval [15 seconds, 24 hours 15 seconds]. Regardless of the task's dispatch_deadline , the app handler will not run for longer than than the service's timeout. We recommend setting the dispatch_deadline to at most a few seconds more than the app handler's timeout. For more information see Timeouts. The value must be given as a string that indicates the length of time (in seconds) followed by s (for "seconds"). For more information on the format, see the documentation for Duration. dispatch_deadline will be truncated to the nearest millisecond. The deadline is an approximate deadline. |
firstAttempt | object | Output only. The status of the task's first attempt. Only dispatch_time will be set. The other Attempt information is not retained by Cloud Tasks. (id: Attempt) |
httpRequest | object | HTTP request that is sent to the worker. An HTTP task is a task that has HttpRequest set. (id: HttpRequest) |
lastAttempt | object | Output only. The status of the task's last attempt. (id: Attempt) |
responseCount | integer (int32) | Output only. The number of attempts which have received a response. |
scheduleTime | string (google-datetime) | The time when the task is scheduled to be attempted or retried. schedule_time will be truncated to the nearest microsecond. |
view | string | Output only. The view specifies which subset of the Task has been returned. |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
get | select | projectsId , locationsId , queuesId , tasksId | responseView | Gets a task. |
list | select | projectsId , locationsId , queuesId | responseView , pageSize , pageToken | Lists the tasks in a queue. By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned. The tasks may be returned in any order. The ordering may change at any time. |
create | insert | projectsId , locationsId , queuesId | Creates a task and adds it to a queue. Tasks cannot be updated after creation; there is no UpdateTask command. * The maximum task size is 100KB. | |
delete | delete | projectsId , locationsId , queuesId , tasksId | Deletes a task. A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has executed successfully or permanently failed. | |
run | exec | projectsId , locationsId , queuesId , tasksId | Forces a task to run now. When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED. This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now. If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig. RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed. | |
buffer | exec | projectsId , locationsId , queuesId , taskId | Creates and buffers a new task without the need to explicitly define a Task message. The queue must have HTTP target. To create the task with a custom ID, use the following format and set TASK_ID to your desired ID: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer To create the task with an automatically generated ID, use the following format: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer. |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
locationsId | string | |
projectsId | string | |
queuesId | string | |
taskId | string | |
tasksId | string | |
pageSize | integer (int32) | |
pageToken | string | |
responseView | string |
SELECT
examples
- get
- list
Gets a task.
SELECT
name,
appEngineHttpRequest,
createTime,
dispatchCount,
dispatchDeadline,
firstAttempt,
httpRequest,
lastAttempt,
responseCount,
scheduleTime,
view
FROM google.cloudtasks.tasks
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND queuesId = '{{ queuesId }}' -- required
AND tasksId = '{{ tasksId }}' -- required
AND responseView = '{{ responseView }}';
Lists the tasks in a queue. By default, only the BASIC view is retrieved due to performance considerations; response_view controls the subset of information which is returned. The tasks may be returned in any order. The ordering may change at any time.
SELECT
name,
appEngineHttpRequest,
createTime,
dispatchCount,
dispatchDeadline,
firstAttempt,
httpRequest,
lastAttempt,
responseCount,
scheduleTime,
view
FROM google.cloudtasks.tasks
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND queuesId = '{{ queuesId }}' -- required
AND responseView = '{{ responseView }}'
AND pageSize = '{{ pageSize }}'
AND pageToken = '{{ pageToken }}';
INSERT
examples
- create
- Manifest
Creates a task and adds it to a queue. Tasks cannot be updated after creation; there is no UpdateTask command. * The maximum task size is 100KB.
INSERT INTO google.cloudtasks.tasks (
data__task,
data__responseView,
projectsId,
locationsId,
queuesId
)
SELECT
'{{ task }}',
'{{ responseView }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ queuesId }}'
RETURNING
name,
appEngineHttpRequest,
createTime,
dispatchCount,
dispatchDeadline,
firstAttempt,
httpRequest,
lastAttempt,
responseCount,
scheduleTime,
view
;
# Description fields are for documentation purposes
- name: tasks
props:
- name: projectsId
value: string
description: Required parameter for the tasks resource.
- name: locationsId
value: string
description: Required parameter for the tasks resource.
- name: queuesId
value: string
description: Required parameter for the tasks resource.
- name: task
value: object
description: >
A unit of scheduled work.
- name: responseView
value: string
description: >
The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) permission on the Task resource.
valid_values: ['VIEW_UNSPECIFIED', 'BASIC', 'FULL']
DELETE
examples
- delete
Deletes a task. A task can be deleted if it is scheduled or dispatched. A task cannot be deleted if it has executed successfully or permanently failed.
DELETE FROM google.cloudtasks.tasks
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND queuesId = '{{ queuesId }}' --required
AND tasksId = '{{ tasksId }}' --required;
Lifecycle Methods
- run
- buffer
Forces a task to run now. When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED. This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now. If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig. RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed.
EXEC google.cloudtasks.tasks.run
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@queuesId='{{ queuesId }}' --required,
@tasksId='{{ tasksId }}' --required
@@json=
'{
"responseView": "{{ responseView }}"
}';
Creates and buffers a new task without the need to explicitly define a Task message. The queue must have HTTP target. To create the task with a custom ID, use the following format and set TASK_ID to your desired ID: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID:buffer To create the task with an automatically generated ID, use the following format: projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks:buffer.
EXEC google.cloudtasks.tasks.buffer
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@queuesId='{{ queuesId }}' --required,
@taskId='{{ taskId }}' --required
@@json=
'{
"body": "{{ body }}"
}';