xref: /aosp_15_r20/external/googleapis/google/cloud/scheduler/v1/target.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2022 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.scheduler.v1;
18
19import "google/api/resource.proto";
20
21option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb";
22option java_multiple_files = true;
23option java_outer_classname = "TargetProto";
24option java_package = "com.google.cloud.scheduler.v1";
25option (google.api.resource_definition) = {
26  type: "pubsub.googleapis.com/Topic"
27  pattern: "projects/{project}/topics/{topic}"
28};
29
30// Http target. The job will be pushed to the job handler by means of
31// an HTTP request via an
32// [http_method][google.cloud.scheduler.v1.HttpTarget.http_method] such as HTTP
33// POST, HTTP GET, etc. The job is acknowledged by means of an HTTP
34// response code in the range [200 - 299]. A failure to receive a response
35// constitutes a failed execution. For a redirected request, the response
36// returned by the redirected request is considered.
37message HttpTarget {
38  // Required. The full URI path that the request will be sent to. This string
39  // must begin with either "http://" or "https://". Some examples of
40  // valid values for [uri][google.cloud.scheduler.v1.HttpTarget.uri] are:
41  // `http://acme.com` and `https://acme.com/sales:8080`. Cloud Scheduler will
42  // encode some characters for safety and compatibility. The maximum allowed
43  // URL length is 2083 characters after encoding.
44  string uri = 1;
45
46  // Which HTTP method to use for the request.
47  HttpMethod http_method = 2;
48
49  // The user can specify HTTP request headers to send with the job's
50  // HTTP request. This map contains the header field names and
51  // values. Repeated headers are not supported, but a header value can
52  // contain commas. These headers represent a subset of the headers
53  // that will accompany the job's HTTP request. Some HTTP request
54  // headers will be ignored or replaced. A partial list of headers that
55  // will be ignored or replaced is below:
56  // - Host: This will be computed by Cloud Scheduler and derived from
57  // [uri][google.cloud.scheduler.v1.HttpTarget.uri].
58  // * `Content-Length`: This will be computed by Cloud Scheduler.
59  // * `User-Agent`: This will be set to `"Google-Cloud-Scheduler"`.
60  // * `X-Google-*`: Google internal use only.
61  // * `X-AppEngine-*`: Google internal use only.
62  // * `X-CloudScheduler`: This header will be set to true.
63  // * `X-CloudScheduler-JobName`: This header will contain the job name.
64  // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in
65  // the unix-cron format, this header will contain the job schedule as an
66  // offset of UTC parsed according to RFC3339.
67  //
68  // The total size of headers must be less than 80KB.
69  map<string, string> headers = 3;
70
71  // HTTP request body. A request body is allowed only if the HTTP
72  // method is POST, PUT, or PATCH. It is an error to set body on a job with an
73  // incompatible [HttpMethod][google.cloud.scheduler.v1.HttpMethod].
74  bytes body = 4;
75
76  // The mode for generating an `Authorization` header for HTTP requests.
77  //
78  // If specified, all `Authorization` headers in the
79  // [HttpTarget.headers][google.cloud.scheduler.v1.HttpTarget.headers] field
80  // will be overridden.
81  oneof authorization_header {
82    // If specified, an
83    // [OAuth token](https://developers.google.com/identity/protocols/OAuth2)
84    // will be generated and attached as an `Authorization` header in the HTTP
85    // request.
86    //
87    // This type of authorization should generally only be used when calling
88    // Google APIs hosted on *.googleapis.com.
89    OAuthToken oauth_token = 5;
90
91    // If specified, an
92    // [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)
93    // token will be generated and attached as an `Authorization` header in the
94    // HTTP request.
95    //
96    // This type of authorization can be used for many scenarios, including
97    // calling Cloud Run, or endpoints where you intend to validate the token
98    // yourself.
99    OidcToken oidc_token = 6;
100  }
101}
102
103// App Engine target. The job will be pushed to a job handler by means
104// of an HTTP request via an
105// [http_method][google.cloud.scheduler.v1.AppEngineHttpTarget.http_method] such
106// as HTTP POST, HTTP GET, etc. The job is acknowledged by means of an
107// HTTP response code in the range [200 - 299]. Error 503 is
108// considered an App Engine system error instead of an application
109// error. Requests returning error 503 will be retried regardless of
110// retry configuration and not counted against retry counts. Any other
111// response code, or a failure to receive a response before the
112// deadline, constitutes a failed attempt.
113message AppEngineHttpTarget {
114  // The HTTP method to use for the request. PATCH and OPTIONS are not
115  // permitted.
116  HttpMethod http_method = 1;
117
118  // App Engine Routing setting for the job.
119  AppEngineRouting app_engine_routing = 2;
120
121  // The relative URI.
122  //
123  // The relative URL must begin with "/" and must be a valid HTTP relative URL.
124  // It can contain a path, query string arguments, and `#` fragments.
125  // If the relative URL is empty, then the root path "/" will be used.
126  // No spaces are allowed, and the maximum length allowed is 2083 characters.
127  string relative_uri = 3;
128
129  // HTTP request headers.
130  //
131  // This map contains the header field names and values. Headers can be set
132  // when the job is created.
133  //
134  // Cloud Scheduler sets some headers to default values:
135  //
136  // * `User-Agent`: By default, this header is
137  //   `"AppEngine-Google; (+http://code.google.com/appengine)"`.
138  //   This header can be modified, but Cloud Scheduler will append
139  //   `"AppEngine-Google; (+http://code.google.com/appengine)"` to the
140  //   modified `User-Agent`.
141  // * `X-CloudScheduler`: This header will be set to true.
142  // * `X-CloudScheduler-JobName`: This header will contain the job name.
143  // * `X-CloudScheduler-ScheduleTime`: For Cloud Scheduler jobs specified in
144  // the unix-cron format, this header will contain the job schedule as an
145  // offset of UTC parsed according to RFC3339.
146  //
147  // If the job has an
148  // [body][google.cloud.scheduler.v1.AppEngineHttpTarget.body], Cloud Scheduler
149  // sets the following headers:
150  //
151  // * `Content-Type`: By default, the `Content-Type` header is set to
152  //   `"application/octet-stream"`. The default can be overridden by explictly
153  //   setting `Content-Type` to a particular media type when the job is
154  //   created.
155  //   For example, `Content-Type` can be set to `"application/json"`.
156  // * `Content-Length`: This is computed by Cloud Scheduler. This value is
157  //   output only. It cannot be changed.
158  //
159  // The headers below are output only. They cannot be set or overridden:
160  //
161  // * `X-Google-*`: For Google internal use only.
162  // * `X-AppEngine-*`: For Google internal use only.
163  //
164  // In addition, some App Engine headers, which contain
165  // job-specific information, are also be sent to the job handler.
166  map<string, string> headers = 4;
167
168  // Body.
169  //
170  // HTTP request body. A request body is allowed only if the HTTP method is
171  // POST or PUT. It will result in invalid argument error to set a body on a
172  // job with an incompatible
173  // [HttpMethod][google.cloud.scheduler.v1.HttpMethod].
174  bytes body = 5;
175}
176
177// Pub/Sub target. The job will be delivered by publishing a message to
178// the given Pub/Sub topic.
179message PubsubTarget {
180  // Required. The name of the Cloud Pub/Sub topic to which messages will
181  // be published when a job is delivered. The topic name must be in the
182  // same format as required by Pub/Sub's
183  // [PublishRequest.name](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#publishrequest),
184  // for example `projects/PROJECT_ID/topics/TOPIC_ID`.
185  //
186  // The topic must be in the same project as the Cloud Scheduler job.
187  string topic_name = 1 [
188    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
189  ];
190
191  // The message payload for PubsubMessage.
192  //
193  // Pubsub message must contain either non-empty data, or at least one
194  // attribute.
195  bytes data = 3;
196
197  // Attributes for PubsubMessage.
198  //
199  // Pubsub message must contain either non-empty data, or at least one
200  // attribute.
201  map<string, string> attributes = 4;
202}
203
204// App Engine Routing.
205//
206// For more information about services, versions, and instances see
207// [An Overview of App
208// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine),
209// [Microservices Architecture on Google App
210// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine),
211// [App Engine Standard request
212// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed),
213// and [App Engine Flex request
214// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
215message AppEngineRouting {
216  // App service.
217  //
218  // By default, the job is sent to the service which is the default
219  // service when the job is attempted.
220  string service = 1;
221
222  // App version.
223  //
224  // By default, the job is sent to the version which is the default
225  // version when the job is attempted.
226  string version = 2;
227
228  // App instance.
229  //
230  // By default, the job is sent to an instance which is available when
231  // the job is attempted.
232  //
233  // Requests can only be sent to a specific instance if
234  // [manual scaling is used in App Engine
235  // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?#scaling_types_and_instance_classes).
236  // App Engine Flex does not support instances. For more information, see
237  // [App Engine Standard request
238  // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed)
239  // and [App Engine Flex request
240  // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
241  string instance = 3;
242
243  // Output only. The host that the job is sent to.
244  //
245  // For more information about how App Engine requests are routed, see
246  // [here](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed).
247  //
248  // The host is constructed as:
249  //
250  //
251  // * `host = [application_domain_name]`</br>
252  //   `| [service] + '.' + [application_domain_name]`</br>
253  //   `| [version] + '.' + [application_domain_name]`</br>
254  //   `| [version_dot_service]+ '.' + [application_domain_name]`</br>
255  //   `| [instance] + '.' + [application_domain_name]`</br>
256  //   `| [instance_dot_service] + '.' + [application_domain_name]`</br>
257  //   `| [instance_dot_version] + '.' + [application_domain_name]`</br>
258  //   `| [instance_dot_version_dot_service] + '.' + [application_domain_name]`
259  //
260  // * `application_domain_name` = The domain name of the app, for
261  //   example <app-id>.appspot.com, which is associated with the
262  //   job's project ID.
263  //
264  // * `service =` [service][google.cloud.scheduler.v1.AppEngineRouting.service]
265  //
266  // * `version =` [version][google.cloud.scheduler.v1.AppEngineRouting.version]
267  //
268  // * `version_dot_service =`
269  //   [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +`
270  //   [service][google.cloud.scheduler.v1.AppEngineRouting.service]
271  //
272  // * `instance =`
273  // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance]
274  //
275  // * `instance_dot_service =`
276  //   [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +`
277  //   [service][google.cloud.scheduler.v1.AppEngineRouting.service]
278  //
279  // * `instance_dot_version =`
280  //   [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +`
281  //   [version][google.cloud.scheduler.v1.AppEngineRouting.version]
282  //
283  // * `instance_dot_version_dot_service =`
284  //   [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] `+ '.' +`
285  //   [version][google.cloud.scheduler.v1.AppEngineRouting.version] `+ '.' +`
286  //   [service][google.cloud.scheduler.v1.AppEngineRouting.service]
287  //
288  //
289  // If [service][google.cloud.scheduler.v1.AppEngineRouting.service] is empty,
290  // then the job will be sent to the service which is the default service when
291  // the job is attempted.
292  //
293  // If [version][google.cloud.scheduler.v1.AppEngineRouting.version] is empty,
294  // then the job will be sent to the version which is the default version when
295  // the job is attempted.
296  //
297  // If [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is
298  // empty, then the job will be sent to an instance which is available when the
299  // job is attempted.
300  //
301  // If [service][google.cloud.scheduler.v1.AppEngineRouting.service],
302  // [version][google.cloud.scheduler.v1.AppEngineRouting.version], or
303  // [instance][google.cloud.scheduler.v1.AppEngineRouting.instance] is invalid,
304  // then the job will be sent to the default version of the default service
305  // when the job is attempted.
306  string host = 4;
307}
308
309// The HTTP method used to execute the job.
310enum HttpMethod {
311  // HTTP method unspecified. Defaults to POST.
312  HTTP_METHOD_UNSPECIFIED = 0;
313
314  // HTTP POST
315  POST = 1;
316
317  // HTTP GET
318  GET = 2;
319
320  // HTTP HEAD
321  HEAD = 3;
322
323  // HTTP PUT
324  PUT = 4;
325
326  // HTTP DELETE
327  DELETE = 5;
328
329  // HTTP PATCH
330  PATCH = 6;
331
332  // HTTP OPTIONS
333  OPTIONS = 7;
334}
335
336// Contains information needed for generating an
337// [OAuth token](https://developers.google.com/identity/protocols/OAuth2).
338// This type of authorization should generally only be used when calling Google
339// APIs hosted on *.googleapis.com.
340message OAuthToken {
341  // [Service account email](https://cloud.google.com/iam/docs/service-accounts)
342  // to be used for generating OAuth token.
343  // The service account must be within the same project as the job. The caller
344  // must have iam.serviceAccounts.actAs permission for the service account.
345  string service_account_email = 1;
346
347  // OAuth scope to be used for generating OAuth access token.
348  // If not specified, "https://www.googleapis.com/auth/cloud-platform"
349  // will be used.
350  string scope = 2;
351}
352
353// Contains information needed for generating an
354// [OpenID Connect
355// token](https://developers.google.com/identity/protocols/OpenIDConnect).
356// This type of authorization can be used for many scenarios, including
357// calling Cloud Run, or endpoints where you intend to validate the token
358// yourself.
359message OidcToken {
360  // [Service account email](https://cloud.google.com/iam/docs/service-accounts)
361  // to be used for generating OIDC token.
362  // The service account must be within the same project as the job. The caller
363  // must have iam.serviceAccounts.actAs permission for the service account.
364  string service_account_email = 1;
365
366  // Audience to be used when generating OIDC token. If not specified, the URI
367  // specified in target will be used.
368  string audience = 2;
369}
370