target.proto 18 KB

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