tasks
Creates, updates, deletes, gets or lists a tasks
resource.
Overview
Name | tasks |
Type | Resource |
Id | google.cloudtasks.tasks |
Fields
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 | App Engine HTTP request. The message defines the HTTP request that is sent to an App Engine app when the task is dispatched. Using AppEngineHttpRequest requires appengine.applications.get Google IAM permission for the project and the following scope: https://www.googleapis.com/auth/cloud-platform The task will be delivered to the App Engine app which belongs to the same project as the queue. For more information, see How Requests are Routed and how routing is affected by dispatch files. Traffic is encrypted during transport and never leaves Google datacenters. Because this traffic is carried over a communication mechanism internal to Google, you cannot explicitly set the protocol (for example, HTTP or HTTPS). The request to the handler, however, will appear to have used the HTTP protocol. The AppEngineRouting used to construct the URL that the task is delivered to can be set at the queue-level or task-level: If app_engine_routing_override is set on the queue, this value is used for all tasks in the queue, no matter what the setting is for the task-level app_engine_routing. The url that the task will be sent to is: url = host + relative_uri Tasks can be dispatched to secure app handlers, unsecure app handlers, and URIs restricted with login: admin . Because tasks are not run as any user, they cannot be dispatched to URIs restricted with login: required Task dispatches also do not follow redirects. The task attempt has succeeded if the app's request handler returns an HTTP response code in the range [200 - 299 ]. The task attempt has failed if the app's handler returns a non-2xx response code or Cloud Tasks does not receive response before the deadline. Failed tasks will be retried according to the retry configuration. 503 (Service Unavailable) is considered an App Engine system error instead of an application error and will cause Cloud Tasks' traffic congestion control to temporarily throttle the queue's dispatches. Unlike other types of task targets, a 429 (Too Many Requests) response from an app handler does not cause traffic congestion control to throttle the queue. |
createTime | string | Output only. The time that the task was created. create_time will be truncated to the nearest second. |
dispatchCount | integer | Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response. |
dispatchDeadline | string | 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 | The status of a task attempt. |
httpRequest | object | HTTP request. The task will be pushed to the worker as an HTTP request. If the worker or the redirected worker acknowledges the task by returning a successful HTTP response code ([200 - 299 ]), the task will be removed from the queue. If any other HTTP response code is returned or no response is received, the task will be retried according to the following: User-specified throttling: retry configuration, rate limits, and the queue's state. System throttling: To prevent the worker from overloading, Cloud Tasks may temporarily reduce the queue's effective rate. User-specified settings will not be changed. System throttling happens because: Cloud Tasks backs off on all errors. Normally the backoff specified in rate limits will be used. But if the worker returns 429 (Too Many Requests), 503 (Service Unavailable), or the rate of errors is high, Cloud Tasks will use a higher backoff rate. The retry specified in the Retry-After HTTP response header is considered. To prevent traffic spikes and to smooth sudden increases in traffic, dispatches ramp up slowly when the queue is newly created or idle and if large numbers of tasks suddenly become available to dispatch (due to spikes in create task rates, the queue being unpaused, or many tasks that are scheduled at the same time). |
lastAttempt | object | The status of a task attempt. |
responseCount | integer | Output only. The number of attempts which have received a response. |
scheduleTime | string | 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
Name | Accessible by | Required Params | Description |
---|---|---|---|
get | SELECT | locationsId, projectsId, queuesId, tasksId | Gets a task. |
list | SELECT | locationsId, projectsId, queuesId | 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 | locationsId, projectsId, 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 | locationsId, projectsId, 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. |
buffer | EXEC | locationsId, projectsId, 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. |
run | EXEC | locationsId, projectsId, 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. The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target. 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. |
SELECT
examples
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 locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}'
AND queuesId = '{{ queuesId }}';
INSERT
example
Use the following StackQL query and manifest file to create a new tasks
resource.
- All Properties
- Manifest
/*+ create */
INSERT INTO google.cloudtasks.tasks (
locationsId,
projectsId,
queuesId,
task,
responseView
)
SELECT
'{{ locationsId }}',
'{{ projectsId }}',
'{{ queuesId }}',
'{{ task }}',
'{{ responseView }}'
;
- name: your_resource_model_name
props:
- name: task
value:
- name: name
value: string
- name: appEngineHttpRequest
value:
- name: httpMethod
value: string
- name: appEngineRouting
value:
- name: service
value: string
- name: version
value: string
- name: instance
value: string
- name: host
value: string
- name: relativeUri
value: string
- name: headers
value: object
- name: body
value: string
- name: httpRequest
value:
- name: url
value: string
- name: httpMethod
value: string
- name: headers
value: object
- name: body
value: string
- name: oauthToken
value:
- name: serviceAccountEmail
value: string
- name: scope
value: string
- name: oidcToken
value:
- name: serviceAccountEmail
value: string
- name: audience
value: string
- name: scheduleTime
value: string
- name: createTime
value: string
- name: dispatchDeadline
value: string
- name: dispatchCount
value: integer
- name: responseCount
value: integer
- name: firstAttempt
value:
- name: scheduleTime
value: string
- name: dispatchTime
value: string
- name: responseTime
value: string
- name: responseStatus
value:
- name: code
value: integer
- name: message
value: string
- name: details
value:
- object
- name: view
value: string
- name: responseView
value: string
DELETE
example
Deletes the specified tasks
resource.
/*+ delete */
DELETE FROM google.cloudtasks.tasks
WHERE locationsId = '{{ locationsId }}'
AND projectsId = '{{ projectsId }}'
AND queuesId = '{{ queuesId }}'
AND tasksId = '{{ tasksId }}';