xref: /aosp_15_r20/external/googleapis/google/cloud/scheduler/v1beta1/job.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/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/cloud/scheduler/v1beta1/target.proto";
22import "google/protobuf/duration.proto";
23import "google/protobuf/timestamp.proto";
24import "google/rpc/status.proto";
25
26option go_package = "cloud.google.com/go/scheduler/apiv1beta1/schedulerpb;schedulerpb";
27option java_multiple_files = true;
28option java_outer_classname = "JobProto";
29option java_package = "com.google.cloud.scheduler.v1beta1";
30
31// Configuration for a job.
32// The maximum allowed size for a job is 1MB.
33message Job {
34  option (google.api.resource) = {
35    type: "cloudscheduler.googleapis.com/Job"
36    pattern: "projects/{project}/locations/{location}/jobs/{job}"
37  };
38
39  // State of the job.
40  enum State {
41    // Unspecified state.
42    STATE_UNSPECIFIED = 0;
43
44    // The job is executing normally.
45    ENABLED = 1;
46
47    // The job is paused by the user. It will not execute. A user can
48    // intentionally pause the job using
49    // [PauseJobRequest][google.cloud.scheduler.v1beta1.PauseJobRequest].
50    PAUSED = 2;
51
52    // The job is disabled by the system due to error. The user
53    // cannot directly set a job to be disabled.
54    DISABLED = 3;
55
56    // The job state resulting from a failed
57    // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]
58    // operation. To recover a job from this state, retry
59    // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob]
60    // until a successful response is received.
61    UPDATE_FAILED = 4;
62  }
63
64  // Optionally caller-specified in
65  // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob], after
66  // which it becomes output only.
67  //
68  // The job name. For example:
69  // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
70  //
71  // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
72  //    hyphens (-), colons (:), or periods (.).
73  //    For more information, see
74  //    [Identifying
75  //    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
76  // * `LOCATION_ID` is the canonical ID for the job's location.
77  //    The list of available locations can be obtained by calling
78  //    [ListLocations][google.cloud.location.Locations.ListLocations].
79  //    For more information, see https://cloud.google.com/about/locations/.
80  // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
81  //    hyphens (-), or underscores (_). The maximum length is 500 characters.
82  string name = 1;
83
84  // Optionally caller-specified in
85  // [CreateJob][google.cloud.scheduler.v1beta1.CloudScheduler.CreateJob] or
86  // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob].
87  //
88  // A human-readable description for the job. This string must not contain
89  // more than 500 characters.
90  string description = 2;
91
92  // Required.
93  //
94  // Delivery settings containing destination and parameters.
95  oneof target {
96    // Pub/Sub target.
97    PubsubTarget pubsub_target = 4;
98
99    // App Engine HTTP target.
100    AppEngineHttpTarget app_engine_http_target = 5;
101
102    // HTTP target.
103    HttpTarget http_target = 6;
104  }
105
106  // Required, except when used with
107  // [UpdateJob][google.cloud.scheduler.v1beta1.CloudScheduler.UpdateJob].
108  //
109  // Describes the schedule on which the job will be executed.
110  //
111  // The schedule can be either of the following types:
112  //
113  // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview)
114  // * English-like
115  // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules)
116  //
117  // As a general rule, execution `n + 1` of a job will not begin
118  // until execution `n` has finished. Cloud Scheduler will never
119  // allow two simultaneously outstanding executions. For example,
120  // this implies that if the `n+1`th execution is scheduled to run at
121  // 16:00 but the `n`th execution takes until 16:15, the `n+1`th
122  // execution will not start until `16:15`.
123  // A scheduled start time will be delayed if the previous
124  // execution has not ended when its scheduled time occurs.
125  //
126  // If [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count] >
127  // 0 and a job attempt fails, the job will be tried a total of
128  // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count]
129  // times, with exponential backoff, until the next scheduled start
130  // time.
131  string schedule = 20;
132
133  // Specifies the time zone to be used in interpreting
134  // [schedule][google.cloud.scheduler.v1beta1.Job.schedule]. The value of this
135  // field must be a time zone name from the [tz
136  // database](http://en.wikipedia.org/wiki/Tz_database).
137  //
138  // Note that some time zones include a provision for
139  // daylight savings time. The rules for daylight saving time are
140  // determined by the chosen tz. For UTC use the string "utc". If a
141  // time zone is not specified, the default will be in UTC (also known
142  // as GMT).
143  string time_zone = 21;
144
145  // Output only. The creation time of the job.
146  google.protobuf.Timestamp user_update_time = 9;
147
148  // Output only. State of the job.
149  State state = 10;
150
151  // Output only. The response from the target for the last attempted execution.
152  google.rpc.Status status = 11;
153
154  // Output only. The next time the job is scheduled. Note that this may be a
155  // retry of a previously failed attempt or the next execution time
156  // according to the schedule.
157  google.protobuf.Timestamp schedule_time = 17;
158
159  // Output only. The time the last job attempt started.
160  google.protobuf.Timestamp last_attempt_time = 18;
161
162  // Settings that determine the retry behavior.
163  RetryConfig retry_config = 19;
164
165  // The deadline for job attempts. If the request handler does not respond by
166  // this deadline then the request is cancelled and the attempt is marked as a
167  // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in
168  // execution logs. Cloud Scheduler will retry the job according
169  // to the [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig].
170  //
171  // The default and the allowed values depend on the type of target:
172  //
173  // * For [HTTP targets][google.cloud.scheduler.v1beta1.Job.http_target], the
174  // default is 3 minutes. The deadline must be in the interval [15 seconds, 30
175  // minutes].
176  //
177  // * For [App Engine HTTP
178  // targets][google.cloud.scheduler.v1beta1.Job.app_engine_http_target], 0
179  // indicates that the request has the default deadline. The default deadline
180  // depends on the scaling type of the service: 10 minutes for standard apps
181  // with automatic scaling, 24 hours for standard apps with manual and basic
182  // scaling, and 60 minutes for flex apps. If the request deadline is set, it
183  // must be in the interval [15 seconds, 24 hours 15 seconds].
184  //
185  // * For [Pub/Sub targets][google.cloud.scheduler.v1beta1.Job.pubsub_target],
186  // this field is ignored.
187  google.protobuf.Duration attempt_deadline = 22;
188
189  // Immutable. This field is used to manage the legacy App Engine Cron jobs
190  // using the Cloud Scheduler API. If the field is set to true, the job will be
191  // considered a legacy job. Note that App Engine Cron jobs have fewer
192  // features than Cloud Scheduler jobs, e.g., are only limited to App Engine
193  // targets.
194  bool legacy_app_engine_cron = 23 [(google.api.field_behavior) = IMMUTABLE];
195}
196
197// Settings that determine the retry behavior.
198//
199// By default, if a job does not complete successfully (meaning that
200// an acknowledgement is not received from the handler, then it will be retried
201// with exponential backoff according to the settings in
202// [RetryConfig][google.cloud.scheduler.v1beta1.RetryConfig].
203message RetryConfig {
204  // The number of attempts that the system will make to run a job using the
205  // exponential backoff procedure described by
206  // [max_doublings][google.cloud.scheduler.v1beta1.RetryConfig.max_doublings].
207  //
208  // The default value of retry_count is zero.
209  //
210  // If retry_count is zero, a job attempt will *not* be retried if
211  // it fails. Instead the Cloud Scheduler system will wait for the
212  // next scheduled execution time.
213  //
214  // If retry_count is set to a non-zero number then Cloud Scheduler
215  // will retry failed attempts, using exponential backoff,
216  // retry_count times, or until the next scheduled execution time,
217  // whichever comes first.
218  //
219  // Values greater than 5 and negative values are not allowed.
220  int32 retry_count = 1;
221
222  // The time limit for retrying a failed job, measured from time when an
223  // execution was first attempted. If specified with
224  // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count], the
225  // job will be retried until both limits are reached.
226  //
227  // The default value for max_retry_duration is zero, which means retry
228  // duration is unlimited.
229  google.protobuf.Duration max_retry_duration = 2;
230
231  // The minimum amount of time to wait before retrying a job after
232  // it fails.
233  //
234  // The default value of this field is 5 seconds.
235  google.protobuf.Duration min_backoff_duration = 3;
236
237  // The maximum amount of time to wait before retrying a job after
238  // it fails.
239  //
240  // The default value of this field is 1 hour.
241  google.protobuf.Duration max_backoff_duration = 4;
242
243  // The time between retries will double `max_doublings` times.
244  //
245  // A job's retry interval starts at
246  // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration],
247  // then doubles `max_doublings` times, then increases linearly, and finally
248  // retries at intervals of
249  // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration]
250  // up to [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count]
251  // times.
252  //
253  // For example, if
254  // [min_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.min_backoff_duration]
255  // is 10s,
256  // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration]
257  // is 300s, and `max_doublings` is 3, then the a job will first be retried in
258  // 10s. The retry interval will double three times, and then increase linearly
259  // by 2^3 * 10s.  Finally, the job will retry at intervals of
260  // [max_backoff_duration][google.cloud.scheduler.v1beta1.RetryConfig.max_backoff_duration]
261  // until the job has been attempted
262  // [retry_count][google.cloud.scheduler.v1beta1.RetryConfig.retry_count]
263  // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s,
264  // 300s, 300s, ....
265  //
266  // The default value of this field is 5.
267  int32 max_doublings = 5;
268}
269