target.proto 18 KB

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