xref: /aosp_15_r20/external/googleapis/google/cloud/run/v2/job.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 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.run.v2;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/launch_stage.proto";
23import "google/api/resource.proto";
24import "google/api/routing.proto";
25import "google/cloud/run/v2/condition.proto";
26import "google/cloud/run/v2/execution.proto";
27import "google/cloud/run/v2/execution_template.proto";
28import "google/cloud/run/v2/k8s.min.proto";
29import "google/cloud/run/v2/vendor_settings.proto";
30import "google/iam/v1/iam_policy.proto";
31import "google/iam/v1/policy.proto";
32import "google/longrunning/operations.proto";
33import "google/protobuf/duration.proto";
34import "google/protobuf/timestamp.proto";
35
36option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb";
37option java_multiple_files = true;
38option java_outer_classname = "JobProto";
39option java_package = "com.google.cloud.run.v2";
40
41// Cloud Run Job Control Plane API.
42service Jobs {
43  option (google.api.default_host) = "run.googleapis.com";
44  option (google.api.oauth_scopes) =
45      "https://www.googleapis.com/auth/cloud-platform";
46
47  // Creates a Job.
48  rpc CreateJob(CreateJobRequest) returns (google.longrunning.Operation) {
49    option (google.api.http) = {
50      post: "/v2/{parent=projects/*/locations/*}/jobs"
51      body: "job"
52    };
53    option (google.api.routing) = {
54      routing_parameters {
55        field: "parent"
56        path_template: "projects/*/locations/{location=*}"
57      }
58    };
59    option (google.api.method_signature) = "parent,job,job_id";
60    option (google.longrunning.operation_info) = {
61      response_type: "Job"
62      metadata_type: "Job"
63    };
64  }
65
66  // Gets information about a Job.
67  rpc GetJob(GetJobRequest) returns (Job) {
68    option (google.api.http) = {
69      get: "/v2/{name=projects/*/locations/*/jobs/*}"
70    };
71    option (google.api.routing) = {
72      routing_parameters {
73        field: "name"
74        path_template: "projects/*/locations/{location=*}/**"
75      }
76    };
77    option (google.api.method_signature) = "name";
78  }
79
80  // Lists Jobs.
81  rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) {
82    option (google.api.http) = {
83      get: "/v2/{parent=projects/*/locations/*}/jobs"
84    };
85    option (google.api.routing) = {
86      routing_parameters {
87        field: "parent"
88        path_template: "projects/*/locations/{location=*}"
89      }
90    };
91    option (google.api.method_signature) = "parent";
92  }
93
94  // Updates a Job.
95  rpc UpdateJob(UpdateJobRequest) returns (google.longrunning.Operation) {
96    option (google.api.http) = {
97      patch: "/v2/{job.name=projects/*/locations/*/jobs/*}"
98      body: "job"
99    };
100    option (google.api.routing) = {
101      routing_parameters {
102        field: "job.name"
103        path_template: "projects/*/locations/{location=*}/**"
104      }
105    };
106    option (google.api.method_signature) = "job";
107    option (google.longrunning.operation_info) = {
108      response_type: "Job"
109      metadata_type: "Job"
110    };
111  }
112
113  // Deletes a Job.
114  rpc DeleteJob(DeleteJobRequest) returns (google.longrunning.Operation) {
115    option (google.api.http) = {
116      delete: "/v2/{name=projects/*/locations/*/jobs/*}"
117    };
118    option (google.api.routing) = {
119      routing_parameters {
120        field: "name"
121        path_template: "projects/*/locations/{location=*}/**"
122      }
123    };
124    option (google.api.method_signature) = "name";
125    option (google.longrunning.operation_info) = {
126      response_type: "Job"
127      metadata_type: "Job"
128    };
129  }
130
131  // Triggers creation of a new Execution of this Job.
132  rpc RunJob(RunJobRequest) returns (google.longrunning.Operation) {
133    option (google.api.http) = {
134      post: "/v2/{name=projects/*/locations/*/jobs/*}:run"
135      body: "*"
136    };
137    option (google.api.routing) = {
138      routing_parameters {
139        field: "name"
140        path_template: "projects/*/locations/{location=*}/**"
141      }
142    };
143    option (google.api.method_signature) = "name";
144    option (google.longrunning.operation_info) = {
145      response_type: "Execution"
146      metadata_type: "Execution"
147    };
148  }
149
150  // Gets the IAM Access Control policy currently in effect for the given Job.
151  // This result does not include any inherited policies.
152  rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest)
153      returns (google.iam.v1.Policy) {
154    option (google.api.http) = {
155      get: "/v2/{resource=projects/*/locations/*/jobs/*}:getIamPolicy"
156    };
157  }
158
159  // Sets the IAM Access control policy for the specified Job. Overwrites
160  // any existing policy.
161  rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest)
162      returns (google.iam.v1.Policy) {
163    option (google.api.http) = {
164      post: "/v2/{resource=projects/*/locations/*/jobs/*}:setIamPolicy"
165      body: "*"
166    };
167  }
168
169  // Returns permissions that a caller has on the specified Project.
170  //
171  // There are no permissions required for making this API call.
172  rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest)
173      returns (google.iam.v1.TestIamPermissionsResponse) {
174    option (google.api.http) = {
175      post: "/v2/{resource=projects/*/locations/*/jobs/*}:testIamPermissions"
176      body: "*"
177    };
178  }
179}
180
181// Request message for creating a Job.
182message CreateJobRequest {
183  // Required. The location and project in which this Job should be created.
184  // Format: projects/{project}/locations/{location}, where {project} can be
185  // project id or number.
186  string parent = 1 [
187    (google.api.field_behavior) = REQUIRED,
188    (google.api.resource_reference) = { child_type: "run.googleapis.com/Job" }
189  ];
190
191  // Required. The Job instance to create.
192  Job job = 2 [(google.api.field_behavior) = REQUIRED];
193
194  // Required. The unique identifier for the Job. The name of the job becomes
195  // {parent}/jobs/{job_id}.
196  string job_id = 3 [(google.api.field_behavior) = REQUIRED];
197
198  // Indicates that the request should be validated and default values
199  // populated, without persisting the request or creating any resources.
200  bool validate_only = 4;
201}
202
203// Request message for obtaining a Job by its full name.
204message GetJobRequest {
205  // Required. The full name of the Job.
206  // Format: projects/{project}/locations/{location}/jobs/{job}, where {project}
207  // can be project id or number.
208  string name = 1 [
209    (google.api.field_behavior) = REQUIRED,
210    (google.api.resource_reference) = { type: "run.googleapis.com/Job" }
211  ];
212}
213
214// Request message for updating a Job.
215message UpdateJobRequest {
216  // Required. The Job to be updated.
217  Job job = 1 [(google.api.field_behavior) = REQUIRED];
218
219  // Indicates that the request should be validated and default values
220  // populated, without persisting the request or updating any resources.
221  bool validate_only = 3;
222
223  // If set to true, and if the Job does not exist, it will create a new
224  // one. Caller must have both create and update permissions for this call if
225  // this is set to true.
226  bool allow_missing = 4;
227}
228
229// Request message for retrieving a list of Jobs.
230message ListJobsRequest {
231  // Required. The location and project to list resources on.
232  // Format: projects/{project}/locations/{location}, where {project} can be
233  // project id or number.
234  string parent = 1 [
235    (google.api.field_behavior) = REQUIRED,
236    (google.api.resource_reference) = { child_type: "run.googleapis.com/Job" }
237  ];
238
239  // Maximum number of Jobs to return in this call.
240  int32 page_size = 2;
241
242  // A page token received from a previous call to ListJobs.
243  // All other parameters must match.
244  string page_token = 3;
245
246  // If true, returns deleted (but unexpired) resources along with active ones.
247  bool show_deleted = 4;
248}
249
250// Response message containing a list of Jobs.
251message ListJobsResponse {
252  // The resulting list of Jobs.
253  repeated Job jobs = 1;
254
255  // A token indicating there are more items than page_size. Use it in the next
256  // ListJobs request to continue.
257  string next_page_token = 2;
258}
259
260// Request message to delete a Job by its full name.
261message DeleteJobRequest {
262  // Required. The full name of the Job.
263  // Format: projects/{project}/locations/{location}/jobs/{job}, where {project}
264  // can be project id or number.
265  string name = 1 [
266    (google.api.field_behavior) = REQUIRED,
267    (google.api.resource_reference) = { type: "run.googleapis.com/Job" }
268  ];
269
270  // Indicates that the request should be validated without actually
271  // deleting any resources.
272  bool validate_only = 3;
273
274  // A system-generated fingerprint for this version of the
275  // resource. May be used to detect modification conflict during updates.
276  string etag = 4;
277}
278
279// Request message to create a new Execution of a Job.
280message RunJobRequest {
281  // RunJob Overrides that contains Execution fields to be overridden.
282  message Overrides {
283    // Per-container override specification.
284    message ContainerOverride {
285      // The name of the container specified as a DNS_LABEL.
286      string name = 1;
287
288      // Optional. Arguments to the entrypoint. Will replace existing args for
289      // override.
290      repeated string args = 2 [(google.api.field_behavior) = OPTIONAL];
291
292      // List of environment variables to set in the container. Will be merged
293      // with existing env for override.
294      repeated EnvVar env = 3;
295
296      // Optional. True if the intention is to clear out existing args list.
297      bool clear_args = 4 [(google.api.field_behavior) = OPTIONAL];
298    }
299
300    // Per container override specification.
301    repeated ContainerOverride container_overrides = 1;
302
303    // Optional. The desired number of tasks the execution should run. Will
304    // replace existing task_count value.
305    int32 task_count = 2 [(google.api.field_behavior) = OPTIONAL];
306
307    // Duration in seconds the task may be active before the system will
308    // actively try to mark it failed and kill associated containers. Will
309    // replace existing timeout_seconds value.
310    google.protobuf.Duration timeout = 4;
311  }
312
313  // Required. The full name of the Job.
314  // Format: projects/{project}/locations/{location}/jobs/{job}, where {project}
315  // can be project id or number.
316  string name = 1 [
317    (google.api.field_behavior) = REQUIRED,
318    (google.api.resource_reference) = { type: "run.googleapis.com/Job" }
319  ];
320
321  // Indicates that the request should be validated without actually
322  // deleting any resources.
323  bool validate_only = 2;
324
325  // A system-generated fingerprint for this version of the
326  // resource. May be used to detect modification conflict during updates.
327  string etag = 3;
328
329  // Overrides specification for a given execution of a job. If provided,
330  // overrides will be applied to update the execution or task spec.
331  Overrides overrides = 4;
332}
333
334// Job represents the configuration of a single job, which references a
335// container image that is run to completion.
336message Job {
337  option (google.api.resource) = {
338    type: "run.googleapis.com/Job"
339    pattern: "projects/{project}/locations/{location}/jobs/{job}"
340    style: DECLARATIVE_FRIENDLY
341  };
342
343  // The fully qualified name of this Job.
344  //
345  // Format:
346  // projects/{project}/locations/{location}/jobs/{job}
347  string name = 1;
348
349  // Output only. Server assigned unique identifier for the Execution. The value
350  // is a UUID4 string and guaranteed to remain unchanged until the resource is
351  // deleted.
352  string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
353
354  // Output only. A number that monotonically increases every time the user
355  // modifies the desired state.
356  int64 generation = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
357
358  // Unstructured key value map that can be used to organize and categorize
359  // objects.
360  // User-provided labels are shared with Google's billing system, so they can
361  // be used to filter, or break down billing charges by team, component,
362  // environment, state, etc. For more information, visit
363  // https://cloud.google.com/resource-manager/docs/creating-managing-labels or
364  // https://cloud.google.com/run/docs/configuring/labels.
365  //
366  // <p>Cloud Run API v2 does not support labels with `run.googleapis.com`,
367  // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev`
368  // namespaces, and they will be rejected. All system labels in v1 now have a
369  // corresponding field in v2 Job.
370  map<string, string> labels = 4;
371
372  // Unstructured key value map that may
373  // be set by external tools to store and arbitrary metadata.
374  // They are not queryable and should be preserved
375  // when modifying objects.
376  //
377  // <p>Cloud Run API v2 does not support annotations with `run.googleapis.com`,
378  // `cloud.googleapis.com`, `serving.knative.dev`, or `autoscaling.knative.dev`
379  // namespaces, and they will be rejected on new resources. All system
380  // annotations in v1 now have a corresponding field in v2 Job.
381  //
382  // <p>This field follows Kubernetes annotations' namespacing, limits, and
383  // rules.
384  map<string, string> annotations = 5;
385
386  // Output only. The creation time.
387  google.protobuf.Timestamp create_time = 6
388      [(google.api.field_behavior) = OUTPUT_ONLY];
389
390  // Output only. The last-modified time.
391  google.protobuf.Timestamp update_time = 7
392      [(google.api.field_behavior) = OUTPUT_ONLY];
393
394  // Output only. The deletion time.
395  google.protobuf.Timestamp delete_time = 8
396      [(google.api.field_behavior) = OUTPUT_ONLY];
397
398  // Output only. For a deleted resource, the time after which it will be
399  // permamently deleted.
400  google.protobuf.Timestamp expire_time = 9
401      [(google.api.field_behavior) = OUTPUT_ONLY];
402
403  // Output only. Email address of the authenticated creator.
404  string creator = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
405
406  // Output only. Email address of the last authenticated modifier.
407  string last_modifier = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
408
409  // Arbitrary identifier for the API client.
410  string client = 12;
411
412  // Arbitrary version identifier for the API client.
413  string client_version = 13;
414
415  // The launch stage as defined by [Google Cloud Platform
416  // Launch Stages](https://cloud.google.com/terms/launch-stages).
417  // Cloud Run supports `ALPHA`, `BETA`, and `GA`. If no value is specified, GA
418  // is assumed.
419  // Set the launch stage to a preview stage on input to allow use of preview
420  // features in that stage. On read (or output), describes whether the resource
421  // uses preview features.
422  // <p>
423  // For example, if ALPHA is provided as input, but only BETA and GA-level
424  // features are used, this field will be BETA on output.
425  google.api.LaunchStage launch_stage = 14;
426
427  // Settings for the Binary Authorization feature.
428  BinaryAuthorization binary_authorization = 15;
429
430  // Required. The template used to create executions for this Job.
431  ExecutionTemplate template = 16 [(google.api.field_behavior) = REQUIRED];
432
433  // Output only. The generation of this Job. See comments in `reconciling` for
434  // additional information on reconciliation process in Cloud Run.
435  int64 observed_generation = 17 [(google.api.field_behavior) = OUTPUT_ONLY];
436
437  // Output only. The Condition of this Job, containing its readiness status,
438  // and detailed error information in case it did not reach the desired state.
439  Condition terminal_condition = 18 [(google.api.field_behavior) = OUTPUT_ONLY];
440
441  // Output only. The Conditions of all other associated sub-resources. They
442  // contain additional diagnostics information in case the Job does not reach
443  // its desired state. See comments in `reconciling` for additional information
444  // on reconciliation process in Cloud Run.
445  repeated Condition conditions = 19
446      [(google.api.field_behavior) = OUTPUT_ONLY];
447
448  // Output only. Number of executions created for this job.
449  int32 execution_count = 20 [(google.api.field_behavior) = OUTPUT_ONLY];
450
451  // Output only. Name of the last created execution.
452  ExecutionReference latest_created_execution = 22
453      [(google.api.field_behavior) = OUTPUT_ONLY];
454
455  // Output only. Returns true if the Job is currently being acted upon by the
456  // system to bring it into the desired state.
457  //
458  // When a new Job is created, or an existing one is updated, Cloud Run
459  // will asynchronously perform all necessary steps to bring the Job to the
460  // desired state. This process is called reconciliation.
461  // While reconciliation is in process, `observed_generation` and
462  // `latest_succeeded_execution`, will have transient values that might
463  // mismatch the intended state: Once reconciliation is over (and this field is
464  // false), there are two possible outcomes: reconciliation succeeded and the
465  // state matches the Job, or there was an error,  and reconciliation failed.
466  // This state can be found in `terminal_condition.state`.
467  //
468  // If reconciliation succeeded, the following fields will match:
469  // `observed_generation` and `generation`, `latest_succeeded_execution` and
470  // `latest_created_execution`.
471  //
472  // If reconciliation failed, `observed_generation` and
473  // `latest_succeeded_execution` will have the state of the last succeeded
474  // execution or empty for newly created Job. Additional information on the
475  // failure can be found in `terminal_condition` and `conditions`.
476  bool reconciling = 23 [(google.api.field_behavior) = OUTPUT_ONLY];
477
478  // Output only. Reserved for future use.
479  bool satisfies_pzs = 25 [(google.api.field_behavior) = OUTPUT_ONLY];
480
481  // Output only. A system-generated fingerprint for this version of the
482  // resource. May be used to detect modification conflict during updates.
483  string etag = 99 [(google.api.field_behavior) = OUTPUT_ONLY];
484}
485
486// Reference to an Execution. Use /Executions.GetExecution with the given name
487// to get full execution including the latest status.
488message ExecutionReference {
489  // Name of the execution.
490  string name = 1 [
491    (google.api.resource_reference) = { type: "run.googleapis.com/Execution" }
492  ];
493
494  // Creation timestamp of the execution.
495  google.protobuf.Timestamp create_time = 2;
496
497  // Creation timestamp of the execution.
498  google.protobuf.Timestamp completion_time = 3;
499}
500