1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.tasks.v2; 18 19import "google/api/field_behavior.proto"; 20 21option go_package = "cloud.google.com/go/cloudtasks/apiv2/cloudtaskspb;cloudtaskspb"; 22option java_multiple_files = true; 23option java_outer_classname = "TargetProto"; 24option java_package = "com.google.cloud.tasks.v2"; 25 26// HTTP request. 27// 28// The task will be pushed to the worker as an HTTP request. If the worker 29// or the redirected worker acknowledges the task by returning a successful HTTP 30// response code ([`200` - `299`]), the task will be removed from the queue. If 31// any other HTTP response code is returned or no response is received, the 32// task will be retried according to the following: 33// 34// * User-specified throttling: [retry 35// configuration][google.cloud.tasks.v2.Queue.retry_config], 36// [rate limits][google.cloud.tasks.v2.Queue.rate_limits], and the [queue's 37// state][google.cloud.tasks.v2.Queue.state]. 38// 39// * System throttling: To prevent the worker from overloading, Cloud Tasks may 40// temporarily reduce the queue's effective rate. User-specified settings 41// will not be changed. 42// 43// System throttling happens because: 44// 45// * Cloud Tasks backs off on all errors. Normally the backoff specified in 46// [rate limits][google.cloud.tasks.v2.Queue.rate_limits] will be used. But 47// if the worker returns `429` (Too Many Requests), `503` (Service 48// Unavailable), or the rate of errors is high, Cloud Tasks will use a 49// higher backoff rate. The retry specified in the `Retry-After` HTTP 50// response header is considered. 51// 52// * To prevent traffic spikes and to smooth sudden increases in traffic, 53// dispatches ramp up slowly when the queue is newly created or idle and 54// if large numbers of tasks suddenly become available to dispatch (due to 55// spikes in create task rates, the queue being unpaused, or many tasks 56// that are scheduled at the same time). 57message HttpRequest { 58 // Required. The full url path that the request will be sent to. 59 // 60 // This string must begin with either "http://" or "https://". Some examples 61 // are: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Tasks will 62 // encode some characters for safety and compatibility. The maximum allowed 63 // URL length is 2083 characters after encoding. 64 // 65 // The `Location` header response from a redirect response [`300` - `399`] 66 // may be followed. The redirect is not counted as a separate attempt. 67 string url = 1 [(google.api.field_behavior) = REQUIRED]; 68 69 // The HTTP method to use for the request. The default is POST. 70 HttpMethod http_method = 2; 71 72 // HTTP request headers. 73 // 74 // This map contains the header field names and values. 75 // Headers can be set when the 76 // [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask]. 77 // 78 // These headers represent a subset of the headers that will accompany the 79 // task's HTTP request. Some HTTP request headers will be ignored or replaced. 80 // 81 // A partial list of headers that will be ignored or replaced is: 82 // 83 // * Host: This will be computed by Cloud Tasks and derived from 84 // [HttpRequest.url][google.cloud.tasks.v2.HttpRequest.url]. 85 // * Content-Length: This will be computed by Cloud Tasks. 86 // * User-Agent: This will be set to `"Google-Cloud-Tasks"`. 87 // * `X-Google-*`: Google use only. 88 // * `X-AppEngine-*`: Google use only. 89 // 90 // `Content-Type` won't be set by Cloud Tasks. You can explicitly set 91 // `Content-Type` to a media type when the 92 // [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask]. 93 // For example, `Content-Type` can be set to `"application/octet-stream"` or 94 // `"application/json"`. 95 // 96 // Headers which can have multiple values (according to RFC2616) can be 97 // specified using comma-separated values. 98 // 99 // The size of the headers must be less than 80KB. 100 map<string, string> headers = 3; 101 102 // HTTP request body. 103 // 104 // A request body is allowed only if the 105 // [HTTP method][google.cloud.tasks.v2.HttpRequest.http_method] is POST, PUT, 106 // or PATCH. It is an error to set body on a task with an incompatible 107 // [HttpMethod][google.cloud.tasks.v2.HttpMethod]. 108 bytes body = 4; 109 110 // The mode for generating an `Authorization` header for HTTP requests. 111 // 112 // If specified, all `Authorization` headers in the 113 // [HttpRequest.headers][google.cloud.tasks.v2.HttpRequest.headers] field will 114 // be overridden. 115 oneof authorization_header { 116 // If specified, an 117 // [OAuth token](https://developers.google.com/identity/protocols/OAuth2) 118 // will be generated and attached as an `Authorization` header in the HTTP 119 // request. 120 // 121 // This type of authorization should generally only be used when calling 122 // Google APIs hosted on *.googleapis.com. 123 OAuthToken oauth_token = 5; 124 125 // If specified, an 126 // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect) 127 // token will be generated and attached as an `Authorization` header in the 128 // HTTP request. 129 // 130 // This type of authorization can be used for many scenarios, including 131 // calling Cloud Run, or endpoints where you intend to validate the token 132 // yourself. 133 OidcToken oidc_token = 6; 134 } 135} 136 137// App Engine HTTP request. 138// 139// The message defines the HTTP request that is sent to an App Engine app when 140// the task is dispatched. 141// 142// Using [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] 143// requires 144// [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control) 145// Google IAM permission for the project 146// and the following scope: 147// 148// `https://www.googleapis.com/auth/cloud-platform` 149// 150// The task will be delivered to the App Engine app which belongs to the same 151// project as the queue. For more information, see 152// [How Requests are 153// Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) 154// and how routing is affected by 155// [dispatch 156// files](https://cloud.google.com/appengine/docs/python/config/dispatchref). 157// Traffic is encrypted during transport and never leaves Google datacenters. 158// Because this traffic is carried over a communication mechanism internal to 159// Google, you cannot explicitly set the protocol (for example, HTTP or HTTPS). 160// The request to the handler, however, will appear to have used the HTTP 161// protocol. 162// 163// The [AppEngineRouting][google.cloud.tasks.v2.AppEngineRouting] used to 164// construct the URL that the task is delivered to can be set at the queue-level 165// or task-level: 166// 167// * If [app_engine_routing_override is set on the 168// queue][google.cloud.tasks.v2.Queue.app_engine_routing_override], this value 169// is used for all tasks in the queue, no matter what the setting is for the 170// [task-level 171// app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]. 172// 173// 174// The `url` that the task will be sent to is: 175// 176// * `url =` [host][google.cloud.tasks.v2.AppEngineRouting.host] `+` 177// [relative_uri][google.cloud.tasks.v2.AppEngineHttpRequest.relative_uri] 178// 179// Tasks can be dispatched to secure app handlers, unsecure app handlers, and 180// URIs restricted with 181// [`login: 182// admin`](https://cloud.google.com/appengine/docs/standard/python/config/appref). 183// Because tasks are not run as any user, they cannot be dispatched to URIs 184// restricted with 185// [`login: 186// required`](https://cloud.google.com/appengine/docs/standard/python/config/appref) 187// Task dispatches also do not follow redirects. 188// 189// The task attempt has succeeded if the app's request handler returns an HTTP 190// response code in the range [`200` - `299`]. The task attempt has failed if 191// the app's handler returns a non-2xx response code or Cloud Tasks does 192// not receive response before the 193// [deadline][google.cloud.tasks.v2.Task.dispatch_deadline]. Failed tasks will 194// be retried according to the [retry 195// configuration][google.cloud.tasks.v2.Queue.retry_config]. `503` (Service 196// Unavailable) is considered an App Engine system error instead of an 197// application error and will cause Cloud Tasks' traffic congestion control to 198// temporarily throttle the queue's dispatches. Unlike other types of task 199// targets, a `429` (Too Many Requests) response from an app handler does not 200// cause traffic congestion control to throttle the queue. 201message AppEngineHttpRequest { 202 // The HTTP method to use for the request. The default is POST. 203 // 204 // The app's request handler for the task's target URL must be able to handle 205 // HTTP requests with this http_method, otherwise the task attempt fails with 206 // error code 405 (Method Not Allowed). See [Writing a push task request 207 // handler](https://cloud.google.com/appengine/docs/java/taskqueue/push/creating-handlers#writing_a_push_task_request_handler) 208 // and the App Engine documentation for your runtime on [How Requests are 209 // Handled](https://cloud.google.com/appengine/docs/standard/python3/how-requests-are-handled). 210 HttpMethod http_method = 1; 211 212 // Task-level setting for App Engine routing. 213 // 214 // * If [app_engine_routing_override is set on the 215 // queue][google.cloud.tasks.v2.Queue.app_engine_routing_override], this 216 // value is used for all tasks in the queue, no matter what the setting is 217 // for the [task-level 218 // app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]. 219 AppEngineRouting app_engine_routing = 2; 220 221 // The relative URI. 222 // 223 // The relative URI must begin with "/" and must be a valid HTTP relative URI. 224 // It can contain a path and query string arguments. 225 // If the relative URI is empty, then the root path "/" will be used. 226 // No spaces are allowed, and the maximum length allowed is 2083 characters. 227 string relative_uri = 3; 228 229 // HTTP request headers. 230 // 231 // This map contains the header field names and values. 232 // Headers can be set when the 233 // [task is created][google.cloud.tasks.v2.CloudTasks.CreateTask]. 234 // Repeated headers are not supported but a header value can contain commas. 235 // 236 // Cloud Tasks sets some headers to default values: 237 // 238 // * `User-Agent`: By default, this header is 239 // `"AppEngine-Google; (+http://code.google.com/appengine)"`. 240 // This header can be modified, but Cloud Tasks will append 241 // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the 242 // modified `User-Agent`. 243 // 244 // If the task has a [body][google.cloud.tasks.v2.AppEngineHttpRequest.body], 245 // Cloud Tasks sets the following headers: 246 // 247 // * `Content-Type`: By default, the `Content-Type` header is set to 248 // `"application/octet-stream"`. The default can be overridden by explicitly 249 // setting `Content-Type` to a particular media type when the 250 // [task is created][google.cloud.tasks.v2.CloudTasks.CreateTask]. 251 // For example, `Content-Type` can be set to `"application/json"`. 252 // * `Content-Length`: This is computed by Cloud Tasks. This value is 253 // output only. It cannot be changed. 254 // 255 // The headers below cannot be set or overridden: 256 // 257 // * `Host` 258 // * `X-Google-*` 259 // * `X-AppEngine-*` 260 // 261 // In addition, Cloud Tasks sets some headers when the task is dispatched, 262 // such as headers containing information about the task; see 263 // [request 264 // headers](https://cloud.google.com/tasks/docs/creating-appengine-handlers#reading_request_headers). 265 // These headers are set only when the task is dispatched, so they are not 266 // visible when the task is returned in a Cloud Tasks response. 267 // 268 // Although there is no specific limit for the maximum number of headers or 269 // the size, there is a limit on the maximum size of the 270 // [Task][google.cloud.tasks.v2.Task]. For more information, see the 271 // [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] documentation. 272 map<string, string> headers = 4; 273 274 // HTTP request body. 275 // 276 // A request body is allowed only if the HTTP method is POST or PUT. It is 277 // an error to set a body on a task with an incompatible 278 // [HttpMethod][google.cloud.tasks.v2.HttpMethod]. 279 bytes body = 5; 280} 281 282// App Engine Routing. 283// 284// Defines routing characteristics specific to App Engine - service, version, 285// and instance. 286// 287// For more information about services, versions, and instances see 288// [An Overview of App 289// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), 290// [Microservices Architecture on Google App 291// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), 292// [App Engine Standard request 293// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), 294// and [App Engine Flex request 295// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). 296// 297// Using [AppEngineRouting][google.cloud.tasks.v2.AppEngineRouting] requires 298// [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control) 299// Google IAM permission for the project 300// and the following scope: 301// 302// `https://www.googleapis.com/auth/cloud-platform` 303message AppEngineRouting { 304 // App service. 305 // 306 // By default, the task is sent to the service which is the default 307 // service when the task is attempted. 308 // 309 // For some queues or tasks which were created using the App Engine 310 // Task Queue API, [host][google.cloud.tasks.v2.AppEngineRouting.host] is not 311 // parsable into [service][google.cloud.tasks.v2.AppEngineRouting.service], 312 // [version][google.cloud.tasks.v2.AppEngineRouting.version], and 313 // [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. For example, 314 // some tasks which were created using the App Engine SDK use a custom domain 315 // name; custom domains are not parsed by Cloud Tasks. If 316 // [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable, then 317 // [service][google.cloud.tasks.v2.AppEngineRouting.service], 318 // [version][google.cloud.tasks.v2.AppEngineRouting.version], and 319 // [instance][google.cloud.tasks.v2.AppEngineRouting.instance] are the empty 320 // string. 321 string service = 1; 322 323 // App version. 324 // 325 // By default, the task is sent to the version which is the default 326 // version when the task is attempted. 327 // 328 // For some queues or tasks which were created using the App Engine 329 // Task Queue API, [host][google.cloud.tasks.v2.AppEngineRouting.host] is not 330 // parsable into [service][google.cloud.tasks.v2.AppEngineRouting.service], 331 // [version][google.cloud.tasks.v2.AppEngineRouting.version], and 332 // [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. For example, 333 // some tasks which were created using the App Engine SDK use a custom domain 334 // name; custom domains are not parsed by Cloud Tasks. If 335 // [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable, then 336 // [service][google.cloud.tasks.v2.AppEngineRouting.service], 337 // [version][google.cloud.tasks.v2.AppEngineRouting.version], and 338 // [instance][google.cloud.tasks.v2.AppEngineRouting.instance] are the empty 339 // string. 340 string version = 2; 341 342 // App instance. 343 // 344 // By default, the task is sent to an instance which is available when 345 // the task is attempted. 346 // 347 // Requests can only be sent to a specific instance if 348 // [manual scaling is used in App Engine 349 // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes). 350 // App Engine Flex does not support instances. For more information, see 351 // [App Engine Standard request 352 // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) 353 // and [App Engine Flex request 354 // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). 355 string instance = 3; 356 357 // Output only. The host that the task is sent to. 358 // 359 // The host is constructed from the domain name of the app associated with 360 // the queue's project ID (for example <app-id>.appspot.com), and the 361 // [service][google.cloud.tasks.v2.AppEngineRouting.service], 362 // [version][google.cloud.tasks.v2.AppEngineRouting.version], and 363 // [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. Tasks which 364 // were created using the App Engine SDK might have a custom domain name. 365 // 366 // For more information, see 367 // [How Requests are 368 // Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). 369 string host = 4; 370} 371 372// The HTTP method used to deliver the task. 373enum HttpMethod { 374 // HTTP method unspecified 375 HTTP_METHOD_UNSPECIFIED = 0; 376 377 // HTTP POST 378 POST = 1; 379 380 // HTTP GET 381 GET = 2; 382 383 // HTTP HEAD 384 HEAD = 3; 385 386 // HTTP PUT 387 PUT = 4; 388 389 // HTTP DELETE 390 DELETE = 5; 391 392 // HTTP PATCH 393 PATCH = 6; 394 395 // HTTP OPTIONS 396 OPTIONS = 7; 397} 398 399// Contains information needed for generating an 400// [OAuth token](https://developers.google.com/identity/protocols/OAuth2). 401// This type of authorization should generally only be used when calling Google 402// APIs hosted on *.googleapis.com. 403message OAuthToken { 404 // [Service account email](https://cloud.google.com/iam/docs/service-accounts) 405 // to be used for generating OAuth token. 406 // The service account must be within the same project as the queue. The 407 // caller must have iam.serviceAccounts.actAs permission for the service 408 // account. 409 string service_account_email = 1; 410 411 // OAuth scope to be used for generating OAuth access token. 412 // If not specified, "https://www.googleapis.com/auth/cloud-platform" 413 // will be used. 414 string scope = 2; 415} 416 417// Contains information needed for generating an 418// [OpenID Connect 419// token](https://developers.google.com/identity/protocols/OpenIDConnect). 420// This type of authorization can be used for many scenarios, including 421// calling Cloud Run, or endpoints where you intend to validate the token 422// yourself. 423message OidcToken { 424 // [Service account email](https://cloud.google.com/iam/docs/service-accounts) 425 // to be used for generating OIDC token. 426 // The service account must be within the same project as the queue. The 427 // caller must have iam.serviceAccounts.actAs permission for the service 428 // account. 429 string service_account_email = 1; 430 431 // Audience to be used when generating OIDC token. If not specified, the URI 432 // specified in target will be used. 433 string audience = 2; 434} 435