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