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/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/cloud/scheduler/v1/job.proto"; 24import "google/protobuf/empty.proto"; 25import "google/protobuf/field_mask.proto"; 26 27option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb"; 28option java_multiple_files = true; 29option java_outer_classname = "SchedulerProto"; 30option java_package = "com.google.cloud.scheduler.v1"; 31option objc_class_prefix = "SCHEDULER"; 32 33// The Cloud Scheduler API allows external entities to reliably 34// schedule asynchronous jobs. 35service CloudScheduler { 36 option (google.api.default_host) = "cloudscheduler.googleapis.com"; 37 option (google.api.oauth_scopes) = 38 "https://www.googleapis.com/auth/cloud-platform"; 39 40 // Lists jobs. 41 rpc ListJobs(ListJobsRequest) returns (ListJobsResponse) { 42 option (google.api.http) = { 43 get: "/v1/{parent=projects/*/locations/*}/jobs" 44 }; 45 option (google.api.method_signature) = "parent"; 46 } 47 48 // Gets a job. 49 rpc GetJob(GetJobRequest) returns (Job) { 50 option (google.api.http) = { 51 get: "/v1/{name=projects/*/locations/*/jobs/*}" 52 }; 53 option (google.api.method_signature) = "name"; 54 } 55 56 // Creates a job. 57 rpc CreateJob(CreateJobRequest) returns (Job) { 58 option (google.api.http) = { 59 post: "/v1/{parent=projects/*/locations/*}/jobs" 60 body: "job" 61 }; 62 option (google.api.method_signature) = "parent,job"; 63 } 64 65 // Updates a job. 66 // 67 // If successful, the updated [Job][google.cloud.scheduler.v1.Job] is 68 // returned. If the job does not exist, `NOT_FOUND` is returned. 69 // 70 // If UpdateJob does not successfully return, it is possible for the 71 // job to be in an 72 // [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] 73 // state. A job in this state may not be executed. If this happens, retry the 74 // UpdateJob request until a successful response is received. 75 rpc UpdateJob(UpdateJobRequest) returns (Job) { 76 option (google.api.http) = { 77 patch: "/v1/{job.name=projects/*/locations/*/jobs/*}" 78 body: "job" 79 }; 80 option (google.api.method_signature) = "job,update_mask"; 81 } 82 83 // Deletes a job. 84 rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty) { 85 option (google.api.http) = { 86 delete: "/v1/{name=projects/*/locations/*/jobs/*}" 87 }; 88 option (google.api.method_signature) = "name"; 89 } 90 91 // Pauses a job. 92 // 93 // If a job is paused then the system will stop executing the job 94 // until it is re-enabled via 95 // [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state 96 // of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if 97 // paused it will be set to 98 // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must 99 // be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to 100 // be paused. 101 rpc PauseJob(PauseJobRequest) returns (Job) { 102 option (google.api.http) = { 103 post: "/v1/{name=projects/*/locations/*/jobs/*}:pause" 104 body: "*" 105 }; 106 option (google.api.method_signature) = "name"; 107 } 108 109 // Resume a job. 110 // 111 // This method reenables a job after it has been 112 // [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state 113 // of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; 114 // after calling this method it will be set to 115 // [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job 116 // must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] 117 // to be resumed. 118 rpc ResumeJob(ResumeJobRequest) returns (Job) { 119 option (google.api.http) = { 120 post: "/v1/{name=projects/*/locations/*/jobs/*}:resume" 121 body: "*" 122 }; 123 option (google.api.method_signature) = "name"; 124 } 125 126 // Forces a job to run now. 127 // 128 // When this method is called, Cloud Scheduler will dispatch the job, even 129 // if the job is already running. 130 rpc RunJob(RunJobRequest) returns (Job) { 131 option (google.api.http) = { 132 post: "/v1/{name=projects/*/locations/*/jobs/*}:run" 133 body: "*" 134 }; 135 option (google.api.method_signature) = "name"; 136 } 137} 138 139// Request message for listing jobs using 140// [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. 141message ListJobsRequest { 142 // Required. The location name. For example: 143 // `projects/PROJECT_ID/locations/LOCATION_ID`. 144 string parent = 1 [ 145 (google.api.field_behavior) = REQUIRED, 146 (google.api.resource_reference) = { 147 child_type: "cloudscheduler.googleapis.com/Job" 148 } 149 ]; 150 151 // Requested page size. 152 // 153 // The maximum page size is 500. If unspecified, the page size will 154 // be the maximum. Fewer jobs than requested might be returned, 155 // even if more jobs exist; use next_page_token to determine if more 156 // jobs exist. 157 int32 page_size = 5; 158 159 // A token identifying a page of results the server will return. To 160 // request the first page results, page_token must be empty. To 161 // request the next page of results, page_token must be the value of 162 // [next_page_token][google.cloud.scheduler.v1.ListJobsResponse.next_page_token] 163 // returned from the previous call to 164 // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. It is an 165 // error to switch the value of 166 // [filter][google.cloud.scheduler.v1.ListJobsRequest.filter] or 167 // [order_by][google.cloud.scheduler.v1.ListJobsRequest.order_by] while 168 // iterating through pages. 169 string page_token = 6; 170} 171 172// Response message for listing jobs using 173// [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs]. 174message ListJobsResponse { 175 // The list of jobs. 176 repeated Job jobs = 1; 177 178 // A token to retrieve next page of results. Pass this value in the 179 // [page_token][google.cloud.scheduler.v1.ListJobsRequest.page_token] field in 180 // the subsequent call to 181 // [ListJobs][google.cloud.scheduler.v1.CloudScheduler.ListJobs] to retrieve 182 // the next page of results. If this is empty it indicates that there are no 183 // more results through which to paginate. 184 // 185 // The page token is valid for only 2 hours. 186 string next_page_token = 2; 187} 188 189// Request message for 190// [GetJob][google.cloud.scheduler.v1.CloudScheduler.GetJob]. 191message GetJobRequest { 192 // Required. The job name. For example: 193 // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 194 string name = 1 [ 195 (google.api.field_behavior) = REQUIRED, 196 (google.api.resource_reference) = { 197 type: "cloudscheduler.googleapis.com/Job" 198 } 199 ]; 200} 201 202// Request message for 203// [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob]. 204message CreateJobRequest { 205 // Required. The location name. For example: 206 // `projects/PROJECT_ID/locations/LOCATION_ID`. 207 string parent = 1 [ 208 (google.api.field_behavior) = REQUIRED, 209 (google.api.resource_reference) = { 210 child_type: "cloudscheduler.googleapis.com/Job" 211 } 212 ]; 213 214 // Required. The job to add. The user can optionally specify a name for the 215 // job in [name][google.cloud.scheduler.v1.Job.name]. 216 // [name][google.cloud.scheduler.v1.Job.name] cannot be the same as an 217 // existing job. If a name is not specified then the system will 218 // generate a random unique name that will be returned 219 // ([name][google.cloud.scheduler.v1.Job.name]) in the response. 220 Job job = 2 [(google.api.field_behavior) = REQUIRED]; 221} 222 223// Request message for 224// [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]. 225message UpdateJobRequest { 226 // Required. The new job properties. 227 // [name][google.cloud.scheduler.v1.Job.name] must be specified. 228 // 229 // Output only fields cannot be modified using UpdateJob. 230 // Any value specified for an output only field will be ignored. 231 Job job = 1 [(google.api.field_behavior) = REQUIRED]; 232 233 // A mask used to specify which fields of the job are being updated. 234 google.protobuf.FieldMask update_mask = 2; 235} 236 237// Request message for deleting a job using 238// [DeleteJob][google.cloud.scheduler.v1.CloudScheduler.DeleteJob]. 239message DeleteJobRequest { 240 // Required. The job name. For example: 241 // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 242 string name = 1 [ 243 (google.api.field_behavior) = REQUIRED, 244 (google.api.resource_reference) = { 245 type: "cloudscheduler.googleapis.com/Job" 246 } 247 ]; 248} 249 250// Request message for 251// [PauseJob][google.cloud.scheduler.v1.CloudScheduler.PauseJob]. 252message PauseJobRequest { 253 // Required. The job name. For example: 254 // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 255 string name = 1 [ 256 (google.api.field_behavior) = REQUIRED, 257 (google.api.resource_reference) = { 258 type: "cloudscheduler.googleapis.com/Job" 259 } 260 ]; 261} 262 263// Request message for 264// [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. 265message ResumeJobRequest { 266 // Required. The job name. For example: 267 // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 268 string name = 1 [ 269 (google.api.field_behavior) = REQUIRED, 270 (google.api.resource_reference) = { 271 type: "cloudscheduler.googleapis.com/Job" 272 } 273 ]; 274} 275 276// Request message for forcing a job to run now using 277// [RunJob][google.cloud.scheduler.v1.CloudScheduler.RunJob]. 278message RunJobRequest { 279 // Required. The job name. For example: 280 // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 281 string name = 1 [ 282 (google.api.field_behavior) = REQUIRED, 283 (google.api.resource_reference) = { 284 type: "cloudscheduler.googleapis.com/Job" 285 } 286 ]; 287} 288