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.
Scopes
You will need authorization for the https://www.googleapis.com/auth/cloud-platform scope to make a valid call.
If unset, the scope for this method defaults to https://www.googleapis.com/auth/cloud-platform.
You can set the scope for this method like this: cloudtasks2-beta3 --scope <scope> projects locations-queues-tasks-create ...
Required Scalar Argument
- <parent> (string)
- Required. The queue name. For example:
projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID
The queue must already exist.
- Required. The queue name. For example:
Required Request Value
The request value is a data-structure with various fields. Each field may be a simple scalar or another data-structure. In the latter case it is advised to set the field-cursor to the data-structure's field to specify values more concisely.
For example, a structure like this:
CreateTaskRequest:
response-view: string
task:
app-engine-http-request:
app-engine-routing:
host: string
instance: string
service: string
version: string
body: string
headers: { string: string }
http-method: string
relative-uri: string
create-time: string
dispatch-count: integer
dispatch-deadline: string
first-attempt:
dispatch-time: string
response-status:
code: integer
message: string
response-time: string
schedule-time: string
http-request:
body: string
headers: { string: string }
http-method: string
oauth-token:
scope: string
service-account-email: string
oidc-token:
audience: string
service-account-email: string
url: string
last-attempt:
dispatch-time: string
response-status:
code: integer
message: string
response-time: string
schedule-time: string
name: string
pull-message:
payload: string
tag: string
response-count: integer
schedule-time: string
view: string
can be set completely with the following arguments which are assumed to be executed in the given order. Note how the cursor position is adjusted to the respective structures, allowing simple field names to be used most of the time.
-r . response-view=voluptua.
- 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 permission on the Task resource.
- 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
task.app-engine-http-request.app-engine-routing host=et
- Output only. The host that the task is sent to. The host is constructed from the domain name of the app associated with the queue's project ID (for example .appspot.com), and the service, version, and instance. Tasks which were created using the App Engine SDK might have a custom domain name. For more information, see How Requests are Routed.
instance=erat
- App instance. By default, the task is sent to an instance which is available when the task is attempted. Requests can only be sent to a specific instance if manual scaling is used in App Engine Standard. App Engine Flex does not support instances. For more information, see App Engine Standard request routing and App Engine Flex request routing.
service=consetetur
- App service. By default, the task is sent to the service which is the default service when the task is attempted. For some queues or tasks which were created using the App Engine Task Queue API, host is not parsable into service, version, and instance. For example, some tasks which were created using the App Engine SDK use a custom domain name; custom domains are not parsed by Cloud Tasks. If host is not parsable, then service, version, and instance are the empty string.
-
version=amet.
- App version. By default, the task is sent to the version which is the default version when the task is attempted. For some queues or tasks which were created using the App Engine Task Queue API, host is not parsable into service, version, and instance. For example, some tasks which were created using the App Engine SDK use a custom domain name; custom domains are not parsed by Cloud Tasks. If host is not parsable, then service, version, and instance are the empty string.
-
.. body=sed
- HTTP request body. A request body is allowed only if the HTTP method is POST or PUT. It is an error to set a body on a task with an incompatible HttpMethod.
headers=key=takimata
- HTTP request headers. This map contains the header field names and values. Headers can be set when the task is created. Repeated headers are not supported but a header value can contain commas. Cloud Tasks sets some headers to default values: *
User-Agent
: By default, this header is"AppEngine-Google; (+http://code.google.com/appengine)"
. This header can be modified, but Cloud Tasks will append"AppEngine-Google; (+http://code.google.com/appengine)"
to the modifiedUser-Agent
. If the task has a body, Cloud Tasks sets the following headers: *Content-Type
: By default, theContent-Type
header is set to"application/octet-stream"
. The default can be overridden by explicitly settingContent-Type
to a particular media type when the task is created. For example,Content-Type
can be set to"application/json"
. *Content-Length
: This is computed by Cloud Tasks. This value is output only. It cannot be changed. The headers below cannot be set or overridden: *Host
*X-Google-*
*X-AppEngine-*
In addition, Cloud Tasks sets some headers when the task is dispatched, such as headers containing information about the task; see request headers. These headers are set only when the task is dispatched, so they are not visible when the task is returned in a Cloud Tasks response. Although there is no specific limit for the maximum number of headers or the size, there is a limit on the maximum size of the Task. For more information, see the CreateTask documentation. - the value will be associated with the given
key
- HTTP request headers. This map contains the header field names and values. Headers can be set when the task is created. Repeated headers are not supported but a header value can contain commas. Cloud Tasks sets some headers to default values: *
http-method=dolores
- The HTTP method to use for the request. The default is POST. The app's request handler for the task's target URL must be able to handle HTTP requests with this http_method, otherwise the task attempt fails with error code 405 (Method Not Allowed). See Writing a push task request handler and the App Engine documentation for your runtime on How Requests are Handled.
-
relative-uri=gubergren
- The relative URI. The relative URI must begin with "/" and must be a valid HTTP relative URI. It can contain a path and query string arguments. If the relative URI is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters.
-
.. create-time=et
- Output only. The time that the task was created.
create_time
will be truncated to the nearest second.
- Output only. The time that the task was created.
dispatch-count=78
- Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response.
dispatch-deadline=voluptua.
- 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'sdispatch_deadline
, the app handler will not run for longer than than the service's timeout. We recommend setting thedispatch_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 bys
(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.
- 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
first-attempt dispatch-time=dolore
- Output only. The time that this attempt was dispatched.
dispatch_time
will be truncated to the nearest microsecond.
- Output only. The time that this attempt was dispatched.
response-status code=67
- The status code, which should be an enum value of google.rpc.Code.
-
message=dolore
- A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
-
.. response-time=voluptua.
- Output only. The time that this attempt response was received.
response_time
will be truncated to the nearest microsecond.
- Output only. The time that this attempt response was received.
-
schedule-time=amet.
- Output only. The time that this attempt was scheduled.
schedule_time
will be truncated to the nearest microsecond.
- Output only. The time that this attempt was scheduled.
-
..http-request body=ea
- HTTP request body. A request body is allowed only if the HTTP method is POST, PUT, or PATCH. It is an error to set body on a task with an incompatible HttpMethod.
headers=key=sadipscing
- HTTP request headers. This map contains the header field names and values. Headers can be set when the task is created. These headers represent a subset of the headers that will accompany the task's HTTP request. Some HTTP request headers will be ignored or replaced. A partial list of headers that will be ignored or replaced is: * Any header that is prefixed with "X-CloudTasks-" will be treated as service header. Service headers define properties of the task and are predefined in CloudTask. * Host: This will be computed by Cloud Tasks and derived from HttpRequest.url. * Content-Length: This will be computed by Cloud Tasks. * User-Agent: This will be set to
"Google-Cloud-Tasks"
. *X-Google-*
: Google use only. *X-AppEngine-*
: Google use only.Content-Type
won't be set by Cloud Tasks. You can explicitly setContent-Type
to a media type when the task is created. For example,Content-Type
can be set to"application/octet-stream"
or"application/json"
. Headers which can have multiple values (according to RFC2616) can be specified using comma-separated values. The size of the headers must be less than 80KB. - the value will be associated with the given
key
- HTTP request headers. This map contains the header field names and values. Headers can be set when the task is created. These headers represent a subset of the headers that will accompany the task's HTTP request. Some HTTP request headers will be ignored or replaced. A partial list of headers that will be ignored or replaced is: * Any header that is prefixed with "X-CloudTasks-" will be treated as service header. Service headers define properties of the task and are predefined in CloudTask. * Host: This will be computed by Cloud Tasks and derived from HttpRequest.url. * Content-Length: This will be computed by Cloud Tasks. * User-Agent: This will be set to
http-method=lorem
- The HTTP method to use for the request. The default is POST.
oauth-token scope=invidunt
- OAuth scope to be used for generating OAuth access token. If not specified, "https://www.googleapis.com/auth/cloud-platform" will be used.
-
service-account-email=no
- Service account email to be used for generating OAuth token. The service account must be within the same project as the queue. The caller must have iam.serviceAccounts.actAs permission for the service account.
-
..oidc-token audience=est
- Audience to be used when generating OIDC token. If not specified, the URI specified in target will be used.
-
service-account-email=at
- Service account email to be used for generating OIDC token. The service account must be within the same project as the queue. The caller must have iam.serviceAccounts.actAs permission for the service account.
-
.. url=sed
- Required. The full url path that the request will be sent to. This string must begin with either "http://" or "https://". Some examples are:
http://acme.com
andhttps://acme.com/sales:8080
. Cloud Tasks will encode some characters for safety and compatibility. The maximum allowed URL length is 2083 characters after encoding. TheLocation
header response from a redirect response [300
-399
] may be followed. The redirect is not counted as a separate attempt.
- Required. The full url path that the request will be sent to. This string must begin with either "http://" or "https://". Some examples are:
-
..last-attempt dispatch-time=sit
- Output only. The time that this attempt was dispatched.
dispatch_time
will be truncated to the nearest microsecond.
- Output only. The time that this attempt was dispatched.
response-status code=66
- The status code, which should be an enum value of google.rpc.Code.
-
message=tempor
- A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
-
.. response-time=aliquyam
- Output only. The time that this attempt response was received.
response_time
will be truncated to the nearest microsecond.
- Output only. The time that this attempt response was received.
-
schedule-time=ipsum
- Output only. The time that this attempt was scheduled.
schedule_time
will be truncated to the nearest microsecond.
- Output only. The time that this attempt was scheduled.
-
.. name=et
- 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.
- Optionally caller-specified in CreateTask. The task name. The task name must have the following format:
pull-message payload=sanctus
- A data payload consumed by the worker to execute the task.
-
tag=lorem
- The tasks's tag. The tag is less than 500 characters. SDK compatibility: Although the SDK allows tags to be either string or bytes, only UTF-8 encoded tags can be used in Cloud Tasks. If a tag isn't UTF-8 encoded, the tag will be empty when the task is returned by Cloud Tasks.
-
.. response-count=94
- Output only. The number of attempts which have received a response.
schedule-time=sed
- The time when the task is scheduled to be attempted. For App Engine queues, this is when the task will be attempted or retried.
schedule_time
will be truncated to the nearest microsecond.
- The time when the task is scheduled to be attempted. For App Engine queues, this is when the task will be attempted or retried.
view=diam
- Output only. The view specifies which subset of the Task has been returned.
About Cursors
The cursor position is key to comfortably set complex nested structures. The following rules apply:
- The cursor position is always set relative to the current one, unless the field name starts with the
.
character. Fields can be nested such as in-r f.s.o
. - The cursor position is set relative to the top-level structure if it starts with
.
, e.g.-r .s.s
- You can also set nested fields without setting the cursor explicitly. For example, to set a value relative to the current cursor position, you would specify
-r struct.sub_struct=bar
. - You can move the cursor one level up by using
..
. Each additional.
moves it up one additional level. E.g....
would go three levels up.
Optional Output Flags
The method's return value a JSON encoded structure, which will be written to standard output by default.
- -o out
- out specifies the destination to which to write the server's result to.
It will be a JSON-encoded structure.
The destination may be
-
to indicate standard output, or a filepath that is to contain the received bytes. If unset, it defaults to standard output.
- out specifies the destination to which to write the server's result to.
It will be a JSON-encoded structure.
The destination may be
Optional General Properties
The following properties can configure any call, and are not specific to this method.
-
-p $-xgafv=string
- V1 error format.
-
-p access-token=string
- OAuth access token.
-
-p alt=string
- Data format for response.
-
-p callback=string
- JSONP
-
-p fields=string
- Selector specifying which fields to include in a partial response.
-
-p key=string
- API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
-
-p oauth-token=string
- OAuth 2.0 token for the current user.
-
-p pretty-print=boolean
- Returns response with indentations and line breaks.
-
-p quota-user=string
- Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
-
-p upload-type=string
- Legacy upload protocol for media (e.g. "media", "multipart").
-
-p upload-protocol=string
- Upload protocol for media (e.g. "raw", "multipart").