1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.scheduler.v1; 18 19 import com.google.api.core.ApiFuture; 20 import com.google.api.core.ApiFutures; 21 import com.google.api.gax.core.BackgroundResource; 22 import com.google.api.gax.paging.AbstractFixedSizeCollection; 23 import com.google.api.gax.paging.AbstractPage; 24 import com.google.api.gax.paging.AbstractPagedListResponse; 25 import com.google.api.gax.rpc.PageContext; 26 import com.google.api.gax.rpc.UnaryCallable; 27 import com.google.cloud.location.GetLocationRequest; 28 import com.google.cloud.location.ListLocationsRequest; 29 import com.google.cloud.location.ListLocationsResponse; 30 import com.google.cloud.location.Location; 31 import com.google.cloud.scheduler.v1.stub.CloudSchedulerStub; 32 import com.google.cloud.scheduler.v1.stub.CloudSchedulerStubSettings; 33 import com.google.common.util.concurrent.MoreExecutors; 34 import com.google.protobuf.Empty; 35 import com.google.protobuf.FieldMask; 36 import java.io.IOException; 37 import java.util.List; 38 import java.util.concurrent.TimeUnit; 39 import javax.annotation.Generated; 40 41 // AUTO-GENERATED DOCUMENTATION AND CLASS. 42 /** 43 * Service Description: The Cloud Scheduler API allows external entities to reliably schedule 44 * asynchronous jobs. 45 * 46 * <p>This class provides the ability to make remote calls to the backing service through method 47 * calls that map to API methods. Sample code to get started: 48 * 49 * <pre>{@code 50 * // This snippet has been automatically generated and should be regarded as a code template only. 51 * // It will require modifications to work: 52 * // - It may require correct/in-range values for request initialization. 53 * // - It may require specifying regional endpoints when creating the service client as shown in 54 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 55 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 56 * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); 57 * Job response = cloudSchedulerClient.getJob(name); 58 * } 59 * }</pre> 60 * 61 * <p>Note: close() needs to be called on the CloudSchedulerClient object to clean up resources such 62 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 63 * 64 * <p>The surface of this class includes several types of Java methods for each of the API's 65 * methods: 66 * 67 * <ol> 68 * <li>A "flattened" method. With this type of method, the fields of the request type have been 69 * converted into function parameters. It may be the case that not all fields are available as 70 * parameters, and not every API method will have a flattened method entry point. 71 * <li>A "request object" method. This type of method only takes one parameter, a request object, 72 * which must be constructed before the call. Not every API method will have a request object 73 * method. 74 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 75 * callable object, which can be used to initiate calls to the service. 76 * </ol> 77 * 78 * <p>See the individual methods for example code. 79 * 80 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 81 * these names, this class includes a format method for each type of name, and additionally a parse 82 * method to extract the individual identifiers contained within names that are returned. 83 * 84 * <p>This class can be customized by passing in a custom instance of CloudSchedulerSettings to 85 * create(). For example: 86 * 87 * <p>To customize credentials: 88 * 89 * <pre>{@code 90 * // This snippet has been automatically generated and should be regarded as a code template only. 91 * // It will require modifications to work: 92 * // - It may require correct/in-range values for request initialization. 93 * // - It may require specifying regional endpoints when creating the service client as shown in 94 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 95 * CloudSchedulerSettings cloudSchedulerSettings = 96 * CloudSchedulerSettings.newBuilder() 97 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 98 * .build(); 99 * CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); 100 * }</pre> 101 * 102 * <p>To customize the endpoint: 103 * 104 * <pre>{@code 105 * // This snippet has been automatically generated and should be regarded as a code template only. 106 * // It will require modifications to work: 107 * // - It may require correct/in-range values for request initialization. 108 * // - It may require specifying regional endpoints when creating the service client as shown in 109 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 110 * CloudSchedulerSettings cloudSchedulerSettings = 111 * CloudSchedulerSettings.newBuilder().setEndpoint(myEndpoint).build(); 112 * CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); 113 * }</pre> 114 * 115 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 116 * the wire: 117 * 118 * <pre>{@code 119 * // This snippet has been automatically generated and should be regarded as a code template only. 120 * // It will require modifications to work: 121 * // - It may require correct/in-range values for request initialization. 122 * // - It may require specifying regional endpoints when creating the service client as shown in 123 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 124 * CloudSchedulerSettings cloudSchedulerSettings = 125 * CloudSchedulerSettings.newHttpJsonBuilder().build(); 126 * CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); 127 * }</pre> 128 * 129 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 130 */ 131 @Generated("by gapic-generator-java") 132 public class CloudSchedulerClient implements BackgroundResource { 133 private final CloudSchedulerSettings settings; 134 private final CloudSchedulerStub stub; 135 136 /** Constructs an instance of CloudSchedulerClient with default settings. */ create()137 public static final CloudSchedulerClient create() throws IOException { 138 return create(CloudSchedulerSettings.newBuilder().build()); 139 } 140 141 /** 142 * Constructs an instance of CloudSchedulerClient, using the given settings. The channels are 143 * created based on the settings passed in, or defaults for any settings that are not set. 144 */ create(CloudSchedulerSettings settings)145 public static final CloudSchedulerClient create(CloudSchedulerSettings settings) 146 throws IOException { 147 return new CloudSchedulerClient(settings); 148 } 149 150 /** 151 * Constructs an instance of CloudSchedulerClient, using the given stub for making calls. This is 152 * for advanced usage - prefer using create(CloudSchedulerSettings). 153 */ create(CloudSchedulerStub stub)154 public static final CloudSchedulerClient create(CloudSchedulerStub stub) { 155 return new CloudSchedulerClient(stub); 156 } 157 158 /** 159 * Constructs an instance of CloudSchedulerClient, using the given settings. This is protected so 160 * that it is easy to make a subclass, but otherwise, the static factory methods should be 161 * preferred. 162 */ CloudSchedulerClient(CloudSchedulerSettings settings)163 protected CloudSchedulerClient(CloudSchedulerSettings settings) throws IOException { 164 this.settings = settings; 165 this.stub = ((CloudSchedulerStubSettings) settings.getStubSettings()).createStub(); 166 } 167 CloudSchedulerClient(CloudSchedulerStub stub)168 protected CloudSchedulerClient(CloudSchedulerStub stub) { 169 this.settings = null; 170 this.stub = stub; 171 } 172 getSettings()173 public final CloudSchedulerSettings getSettings() { 174 return settings; 175 } 176 getStub()177 public CloudSchedulerStub getStub() { 178 return stub; 179 } 180 181 // AUTO-GENERATED DOCUMENTATION AND METHOD. 182 /** 183 * Lists jobs. 184 * 185 * <p>Sample code: 186 * 187 * <pre>{@code 188 * // This snippet has been automatically generated and should be regarded as a code template only. 189 * // It will require modifications to work: 190 * // - It may require correct/in-range values for request initialization. 191 * // - It may require specifying regional endpoints when creating the service client as shown in 192 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 193 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 194 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 195 * for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { 196 * // doThingsWith(element); 197 * } 198 * } 199 * }</pre> 200 * 201 * @param parent Required. The location name. For example: 202 * `projects/PROJECT_ID/locations/LOCATION_ID`. 203 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 204 */ listJobs(LocationName parent)205 public final ListJobsPagedResponse listJobs(LocationName parent) { 206 ListJobsRequest request = 207 ListJobsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); 208 return listJobs(request); 209 } 210 211 // AUTO-GENERATED DOCUMENTATION AND METHOD. 212 /** 213 * Lists jobs. 214 * 215 * <p>Sample code: 216 * 217 * <pre>{@code 218 * // This snippet has been automatically generated and should be regarded as a code template only. 219 * // It will require modifications to work: 220 * // - It may require correct/in-range values for request initialization. 221 * // - It may require specifying regional endpoints when creating the service client as shown in 222 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 223 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 224 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 225 * for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { 226 * // doThingsWith(element); 227 * } 228 * } 229 * }</pre> 230 * 231 * @param parent Required. The location name. For example: 232 * `projects/PROJECT_ID/locations/LOCATION_ID`. 233 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 234 */ listJobs(String parent)235 public final ListJobsPagedResponse listJobs(String parent) { 236 ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent).build(); 237 return listJobs(request); 238 } 239 240 // AUTO-GENERATED DOCUMENTATION AND METHOD. 241 /** 242 * Lists jobs. 243 * 244 * <p>Sample code: 245 * 246 * <pre>{@code 247 * // This snippet has been automatically generated and should be regarded as a code template only. 248 * // It will require modifications to work: 249 * // - It may require correct/in-range values for request initialization. 250 * // - It may require specifying regional endpoints when creating the service client as shown in 251 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 252 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 253 * ListJobsRequest request = 254 * ListJobsRequest.newBuilder() 255 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 256 * .setPageSize(883849137) 257 * .setPageToken("pageToken873572522") 258 * .build(); 259 * for (Job element : cloudSchedulerClient.listJobs(request).iterateAll()) { 260 * // doThingsWith(element); 261 * } 262 * } 263 * }</pre> 264 * 265 * @param request The request object containing all of the parameters for the API call. 266 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 267 */ listJobs(ListJobsRequest request)268 public final ListJobsPagedResponse listJobs(ListJobsRequest request) { 269 return listJobsPagedCallable().call(request); 270 } 271 272 // AUTO-GENERATED DOCUMENTATION AND METHOD. 273 /** 274 * Lists jobs. 275 * 276 * <p>Sample code: 277 * 278 * <pre>{@code 279 * // This snippet has been automatically generated and should be regarded as a code template only. 280 * // It will require modifications to work: 281 * // - It may require correct/in-range values for request initialization. 282 * // - It may require specifying regional endpoints when creating the service client as shown in 283 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 284 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 285 * ListJobsRequest request = 286 * ListJobsRequest.newBuilder() 287 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 288 * .setPageSize(883849137) 289 * .setPageToken("pageToken873572522") 290 * .build(); 291 * ApiFuture<Job> future = cloudSchedulerClient.listJobsPagedCallable().futureCall(request); 292 * // Do something. 293 * for (Job element : future.get().iterateAll()) { 294 * // doThingsWith(element); 295 * } 296 * } 297 * }</pre> 298 */ listJobsPagedCallable()299 public final UnaryCallable<ListJobsRequest, ListJobsPagedResponse> listJobsPagedCallable() { 300 return stub.listJobsPagedCallable(); 301 } 302 303 // AUTO-GENERATED DOCUMENTATION AND METHOD. 304 /** 305 * Lists jobs. 306 * 307 * <p>Sample code: 308 * 309 * <pre>{@code 310 * // This snippet has been automatically generated and should be regarded as a code template only. 311 * // It will require modifications to work: 312 * // - It may require correct/in-range values for request initialization. 313 * // - It may require specifying regional endpoints when creating the service client as shown in 314 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 315 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 316 * ListJobsRequest request = 317 * ListJobsRequest.newBuilder() 318 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 319 * .setPageSize(883849137) 320 * .setPageToken("pageToken873572522") 321 * .build(); 322 * while (true) { 323 * ListJobsResponse response = cloudSchedulerClient.listJobsCallable().call(request); 324 * for (Job element : response.getJobsList()) { 325 * // doThingsWith(element); 326 * } 327 * String nextPageToken = response.getNextPageToken(); 328 * if (!Strings.isNullOrEmpty(nextPageToken)) { 329 * request = request.toBuilder().setPageToken(nextPageToken).build(); 330 * } else { 331 * break; 332 * } 333 * } 334 * } 335 * }</pre> 336 */ listJobsCallable()337 public final UnaryCallable<ListJobsRequest, ListJobsResponse> listJobsCallable() { 338 return stub.listJobsCallable(); 339 } 340 341 // AUTO-GENERATED DOCUMENTATION AND METHOD. 342 /** 343 * Gets a job. 344 * 345 * <p>Sample code: 346 * 347 * <pre>{@code 348 * // This snippet has been automatically generated and should be regarded as a code template only. 349 * // It will require modifications to work: 350 * // - It may require correct/in-range values for request initialization. 351 * // - It may require specifying regional endpoints when creating the service client as shown in 352 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 353 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 354 * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); 355 * Job response = cloudSchedulerClient.getJob(name); 356 * } 357 * }</pre> 358 * 359 * @param name Required. The job name. For example: 360 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 361 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 362 */ getJob(JobName name)363 public final Job getJob(JobName name) { 364 GetJobRequest request = 365 GetJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 366 return getJob(request); 367 } 368 369 // AUTO-GENERATED DOCUMENTATION AND METHOD. 370 /** 371 * Gets a job. 372 * 373 * <p>Sample code: 374 * 375 * <pre>{@code 376 * // This snippet has been automatically generated and should be regarded as a code template only. 377 * // It will require modifications to work: 378 * // - It may require correct/in-range values for request initialization. 379 * // - It may require specifying regional endpoints when creating the service client as shown in 380 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 381 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 382 * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); 383 * Job response = cloudSchedulerClient.getJob(name); 384 * } 385 * }</pre> 386 * 387 * @param name Required. The job name. For example: 388 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 389 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 390 */ getJob(String name)391 public final Job getJob(String name) { 392 GetJobRequest request = GetJobRequest.newBuilder().setName(name).build(); 393 return getJob(request); 394 } 395 396 // AUTO-GENERATED DOCUMENTATION AND METHOD. 397 /** 398 * Gets a job. 399 * 400 * <p>Sample code: 401 * 402 * <pre>{@code 403 * // This snippet has been automatically generated and should be regarded as a code template only. 404 * // It will require modifications to work: 405 * // - It may require correct/in-range values for request initialization. 406 * // - It may require specifying regional endpoints when creating the service client as shown in 407 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 408 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 409 * GetJobRequest request = 410 * GetJobRequest.newBuilder() 411 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 412 * .build(); 413 * Job response = cloudSchedulerClient.getJob(request); 414 * } 415 * }</pre> 416 * 417 * @param request The request object containing all of the parameters for the API call. 418 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 419 */ getJob(GetJobRequest request)420 public final Job getJob(GetJobRequest request) { 421 return getJobCallable().call(request); 422 } 423 424 // AUTO-GENERATED DOCUMENTATION AND METHOD. 425 /** 426 * Gets a job. 427 * 428 * <p>Sample code: 429 * 430 * <pre>{@code 431 * // This snippet has been automatically generated and should be regarded as a code template only. 432 * // It will require modifications to work: 433 * // - It may require correct/in-range values for request initialization. 434 * // - It may require specifying regional endpoints when creating the service client as shown in 435 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 436 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 437 * GetJobRequest request = 438 * GetJobRequest.newBuilder() 439 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 440 * .build(); 441 * ApiFuture<Job> future = cloudSchedulerClient.getJobCallable().futureCall(request); 442 * // Do something. 443 * Job response = future.get(); 444 * } 445 * }</pre> 446 */ getJobCallable()447 public final UnaryCallable<GetJobRequest, Job> getJobCallable() { 448 return stub.getJobCallable(); 449 } 450 451 // AUTO-GENERATED DOCUMENTATION AND METHOD. 452 /** 453 * Creates a job. 454 * 455 * <p>Sample code: 456 * 457 * <pre>{@code 458 * // This snippet has been automatically generated and should be regarded as a code template only. 459 * // It will require modifications to work: 460 * // - It may require correct/in-range values for request initialization. 461 * // - It may require specifying regional endpoints when creating the service client as shown in 462 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 463 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 464 * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); 465 * Job job = Job.newBuilder().build(); 466 * Job response = cloudSchedulerClient.createJob(parent, job); 467 * } 468 * }</pre> 469 * 470 * @param parent Required. The location name. For example: 471 * `projects/PROJECT_ID/locations/LOCATION_ID`. 472 * @param job Required. The job to add. The user can optionally specify a name for the job in 473 * [name][google.cloud.scheduler.v1.Job.name]. [name][google.cloud.scheduler.v1.Job.name] 474 * cannot be the same as an existing job. If a name is not specified then the system will 475 * generate a random unique name that will be returned 476 * ([name][google.cloud.scheduler.v1.Job.name]) in the response. 477 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 478 */ createJob(LocationName parent, Job job)479 public final Job createJob(LocationName parent, Job job) { 480 CreateJobRequest request = 481 CreateJobRequest.newBuilder() 482 .setParent(parent == null ? null : parent.toString()) 483 .setJob(job) 484 .build(); 485 return createJob(request); 486 } 487 488 // AUTO-GENERATED DOCUMENTATION AND METHOD. 489 /** 490 * Creates a job. 491 * 492 * <p>Sample code: 493 * 494 * <pre>{@code 495 * // This snippet has been automatically generated and should be regarded as a code template only. 496 * // It will require modifications to work: 497 * // - It may require correct/in-range values for request initialization. 498 * // - It may require specifying regional endpoints when creating the service client as shown in 499 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 500 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 501 * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); 502 * Job job = Job.newBuilder().build(); 503 * Job response = cloudSchedulerClient.createJob(parent, job); 504 * } 505 * }</pre> 506 * 507 * @param parent Required. The location name. For example: 508 * `projects/PROJECT_ID/locations/LOCATION_ID`. 509 * @param job Required. The job to add. The user can optionally specify a name for the job in 510 * [name][google.cloud.scheduler.v1.Job.name]. [name][google.cloud.scheduler.v1.Job.name] 511 * cannot be the same as an existing job. If a name is not specified then the system will 512 * generate a random unique name that will be returned 513 * ([name][google.cloud.scheduler.v1.Job.name]) in the response. 514 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 515 */ createJob(String parent, Job job)516 public final Job createJob(String parent, Job job) { 517 CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent).setJob(job).build(); 518 return createJob(request); 519 } 520 521 // AUTO-GENERATED DOCUMENTATION AND METHOD. 522 /** 523 * Creates a job. 524 * 525 * <p>Sample code: 526 * 527 * <pre>{@code 528 * // This snippet has been automatically generated and should be regarded as a code template only. 529 * // It will require modifications to work: 530 * // - It may require correct/in-range values for request initialization. 531 * // - It may require specifying regional endpoints when creating the service client as shown in 532 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 533 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 534 * CreateJobRequest request = 535 * CreateJobRequest.newBuilder() 536 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 537 * .setJob(Job.newBuilder().build()) 538 * .build(); 539 * Job response = cloudSchedulerClient.createJob(request); 540 * } 541 * }</pre> 542 * 543 * @param request The request object containing all of the parameters for the API call. 544 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 545 */ createJob(CreateJobRequest request)546 public final Job createJob(CreateJobRequest request) { 547 return createJobCallable().call(request); 548 } 549 550 // AUTO-GENERATED DOCUMENTATION AND METHOD. 551 /** 552 * Creates a job. 553 * 554 * <p>Sample code: 555 * 556 * <pre>{@code 557 * // This snippet has been automatically generated and should be regarded as a code template only. 558 * // It will require modifications to work: 559 * // - It may require correct/in-range values for request initialization. 560 * // - It may require specifying regional endpoints when creating the service client as shown in 561 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 562 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 563 * CreateJobRequest request = 564 * CreateJobRequest.newBuilder() 565 * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) 566 * .setJob(Job.newBuilder().build()) 567 * .build(); 568 * ApiFuture<Job> future = cloudSchedulerClient.createJobCallable().futureCall(request); 569 * // Do something. 570 * Job response = future.get(); 571 * } 572 * }</pre> 573 */ createJobCallable()574 public final UnaryCallable<CreateJobRequest, Job> createJobCallable() { 575 return stub.createJobCallable(); 576 } 577 578 // AUTO-GENERATED DOCUMENTATION AND METHOD. 579 /** 580 * Updates a job. 581 * 582 * <p>If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does 583 * not exist, `NOT_FOUND` is returned. 584 * 585 * <p>If UpdateJob does not successfully return, it is possible for the job to be in an 586 * [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in 587 * this state may not be executed. If this happens, retry the UpdateJob request until a successful 588 * response is received. 589 * 590 * <p>Sample code: 591 * 592 * <pre>{@code 593 * // This snippet has been automatically generated and should be regarded as a code template only. 594 * // It will require modifications to work: 595 * // - It may require correct/in-range values for request initialization. 596 * // - It may require specifying regional endpoints when creating the service client as shown in 597 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 598 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 599 * Job job = Job.newBuilder().build(); 600 * FieldMask updateMask = FieldMask.newBuilder().build(); 601 * Job response = cloudSchedulerClient.updateJob(job, updateMask); 602 * } 603 * }</pre> 604 * 605 * @param job Required. The new job properties. [name][google.cloud.scheduler.v1.Job.name] must be 606 * specified. 607 * <p>Output only fields cannot be modified using UpdateJob. Any value specified for an output 608 * only field will be ignored. 609 * @param updateMask A mask used to specify which fields of the job are being updated. 610 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 611 */ updateJob(Job job, FieldMask updateMask)612 public final Job updateJob(Job job, FieldMask updateMask) { 613 UpdateJobRequest request = 614 UpdateJobRequest.newBuilder().setJob(job).setUpdateMask(updateMask).build(); 615 return updateJob(request); 616 } 617 618 // AUTO-GENERATED DOCUMENTATION AND METHOD. 619 /** 620 * Updates a job. 621 * 622 * <p>If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does 623 * not exist, `NOT_FOUND` is returned. 624 * 625 * <p>If UpdateJob does not successfully return, it is possible for the job to be in an 626 * [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in 627 * this state may not be executed. If this happens, retry the UpdateJob request until a successful 628 * response is received. 629 * 630 * <p>Sample code: 631 * 632 * <pre>{@code 633 * // This snippet has been automatically generated and should be regarded as a code template only. 634 * // It will require modifications to work: 635 * // - It may require correct/in-range values for request initialization. 636 * // - It may require specifying regional endpoints when creating the service client as shown in 637 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 638 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 639 * UpdateJobRequest request = 640 * UpdateJobRequest.newBuilder() 641 * .setJob(Job.newBuilder().build()) 642 * .setUpdateMask(FieldMask.newBuilder().build()) 643 * .build(); 644 * Job response = cloudSchedulerClient.updateJob(request); 645 * } 646 * }</pre> 647 * 648 * @param request The request object containing all of the parameters for the API call. 649 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 650 */ updateJob(UpdateJobRequest request)651 public final Job updateJob(UpdateJobRequest request) { 652 return updateJobCallable().call(request); 653 } 654 655 // AUTO-GENERATED DOCUMENTATION AND METHOD. 656 /** 657 * Updates a job. 658 * 659 * <p>If successful, the updated [Job][google.cloud.scheduler.v1.Job] is returned. If the job does 660 * not exist, `NOT_FOUND` is returned. 661 * 662 * <p>If UpdateJob does not successfully return, it is possible for the job to be in an 663 * [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] state. A job in 664 * this state may not be executed. If this happens, retry the UpdateJob request until a successful 665 * response is received. 666 * 667 * <p>Sample code: 668 * 669 * <pre>{@code 670 * // This snippet has been automatically generated and should be regarded as a code template only. 671 * // It will require modifications to work: 672 * // - It may require correct/in-range values for request initialization. 673 * // - It may require specifying regional endpoints when creating the service client as shown in 674 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 675 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 676 * UpdateJobRequest request = 677 * UpdateJobRequest.newBuilder() 678 * .setJob(Job.newBuilder().build()) 679 * .setUpdateMask(FieldMask.newBuilder().build()) 680 * .build(); 681 * ApiFuture<Job> future = cloudSchedulerClient.updateJobCallable().futureCall(request); 682 * // Do something. 683 * Job response = future.get(); 684 * } 685 * }</pre> 686 */ updateJobCallable()687 public final UnaryCallable<UpdateJobRequest, Job> updateJobCallable() { 688 return stub.updateJobCallable(); 689 } 690 691 // AUTO-GENERATED DOCUMENTATION AND METHOD. 692 /** 693 * Deletes a job. 694 * 695 * <p>Sample code: 696 * 697 * <pre>{@code 698 * // This snippet has been automatically generated and should be regarded as a code template only. 699 * // It will require modifications to work: 700 * // - It may require correct/in-range values for request initialization. 701 * // - It may require specifying regional endpoints when creating the service client as shown in 702 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 703 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 704 * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); 705 * cloudSchedulerClient.deleteJob(name); 706 * } 707 * }</pre> 708 * 709 * @param name Required. The job name. For example: 710 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 711 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 712 */ deleteJob(JobName name)713 public final void deleteJob(JobName name) { 714 DeleteJobRequest request = 715 DeleteJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 716 deleteJob(request); 717 } 718 719 // AUTO-GENERATED DOCUMENTATION AND METHOD. 720 /** 721 * Deletes a job. 722 * 723 * <p>Sample code: 724 * 725 * <pre>{@code 726 * // This snippet has been automatically generated and should be regarded as a code template only. 727 * // It will require modifications to work: 728 * // - It may require correct/in-range values for request initialization. 729 * // - It may require specifying regional endpoints when creating the service client as shown in 730 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 731 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 732 * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); 733 * cloudSchedulerClient.deleteJob(name); 734 * } 735 * }</pre> 736 * 737 * @param name Required. The job name. For example: 738 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 739 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 740 */ deleteJob(String name)741 public final void deleteJob(String name) { 742 DeleteJobRequest request = DeleteJobRequest.newBuilder().setName(name).build(); 743 deleteJob(request); 744 } 745 746 // AUTO-GENERATED DOCUMENTATION AND METHOD. 747 /** 748 * Deletes a job. 749 * 750 * <p>Sample code: 751 * 752 * <pre>{@code 753 * // This snippet has been automatically generated and should be regarded as a code template only. 754 * // It will require modifications to work: 755 * // - It may require correct/in-range values for request initialization. 756 * // - It may require specifying regional endpoints when creating the service client as shown in 757 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 758 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 759 * DeleteJobRequest request = 760 * DeleteJobRequest.newBuilder() 761 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 762 * .build(); 763 * cloudSchedulerClient.deleteJob(request); 764 * } 765 * }</pre> 766 * 767 * @param request The request object containing all of the parameters for the API call. 768 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 769 */ deleteJob(DeleteJobRequest request)770 public final void deleteJob(DeleteJobRequest request) { 771 deleteJobCallable().call(request); 772 } 773 774 // AUTO-GENERATED DOCUMENTATION AND METHOD. 775 /** 776 * Deletes a job. 777 * 778 * <p>Sample code: 779 * 780 * <pre>{@code 781 * // This snippet has been automatically generated and should be regarded as a code template only. 782 * // It will require modifications to work: 783 * // - It may require correct/in-range values for request initialization. 784 * // - It may require specifying regional endpoints when creating the service client as shown in 785 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 786 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 787 * DeleteJobRequest request = 788 * DeleteJobRequest.newBuilder() 789 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 790 * .build(); 791 * ApiFuture<Empty> future = cloudSchedulerClient.deleteJobCallable().futureCall(request); 792 * // Do something. 793 * future.get(); 794 * } 795 * }</pre> 796 */ deleteJobCallable()797 public final UnaryCallable<DeleteJobRequest, Empty> deleteJobCallable() { 798 return stub.deleteJobCallable(); 799 } 800 801 // AUTO-GENERATED DOCUMENTATION AND METHOD. 802 /** 803 * Pauses a job. 804 * 805 * <p>If a job is paused then the system will stop executing the job until it is re-enabled via 806 * [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored 807 * in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to 808 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in 809 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused. 810 * 811 * <p>Sample code: 812 * 813 * <pre>{@code 814 * // This snippet has been automatically generated and should be regarded as a code template only. 815 * // It will require modifications to work: 816 * // - It may require correct/in-range values for request initialization. 817 * // - It may require specifying regional endpoints when creating the service client as shown in 818 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 819 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 820 * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); 821 * Job response = cloudSchedulerClient.pauseJob(name); 822 * } 823 * }</pre> 824 * 825 * @param name Required. The job name. For example: 826 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 827 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 828 */ pauseJob(JobName name)829 public final Job pauseJob(JobName name) { 830 PauseJobRequest request = 831 PauseJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 832 return pauseJob(request); 833 } 834 835 // AUTO-GENERATED DOCUMENTATION AND METHOD. 836 /** 837 * Pauses a job. 838 * 839 * <p>If a job is paused then the system will stop executing the job until it is re-enabled via 840 * [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored 841 * in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to 842 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in 843 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused. 844 * 845 * <p>Sample code: 846 * 847 * <pre>{@code 848 * // This snippet has been automatically generated and should be regarded as a code template only. 849 * // It will require modifications to work: 850 * // - It may require correct/in-range values for request initialization. 851 * // - It may require specifying regional endpoints when creating the service client as shown in 852 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 853 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 854 * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); 855 * Job response = cloudSchedulerClient.pauseJob(name); 856 * } 857 * }</pre> 858 * 859 * @param name Required. The job name. For example: 860 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 861 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 862 */ pauseJob(String name)863 public final Job pauseJob(String name) { 864 PauseJobRequest request = PauseJobRequest.newBuilder().setName(name).build(); 865 return pauseJob(request); 866 } 867 868 // AUTO-GENERATED DOCUMENTATION AND METHOD. 869 /** 870 * Pauses a job. 871 * 872 * <p>If a job is paused then the system will stop executing the job until it is re-enabled via 873 * [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored 874 * in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to 875 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in 876 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused. 877 * 878 * <p>Sample code: 879 * 880 * <pre>{@code 881 * // This snippet has been automatically generated and should be regarded as a code template only. 882 * // It will require modifications to work: 883 * // - It may require correct/in-range values for request initialization. 884 * // - It may require specifying regional endpoints when creating the service client as shown in 885 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 886 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 887 * PauseJobRequest request = 888 * PauseJobRequest.newBuilder() 889 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 890 * .build(); 891 * Job response = cloudSchedulerClient.pauseJob(request); 892 * } 893 * }</pre> 894 * 895 * @param request The request object containing all of the parameters for the API call. 896 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 897 */ pauseJob(PauseJobRequest request)898 public final Job pauseJob(PauseJobRequest request) { 899 return pauseJobCallable().call(request); 900 } 901 902 // AUTO-GENERATED DOCUMENTATION AND METHOD. 903 /** 904 * Pauses a job. 905 * 906 * <p>If a job is paused then the system will stop executing the job until it is re-enabled via 907 * [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state of the job is stored 908 * in [state][google.cloud.scheduler.v1.Job.state]; if paused it will be set to 909 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must be in 910 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to be paused. 911 * 912 * <p>Sample code: 913 * 914 * <pre>{@code 915 * // This snippet has been automatically generated and should be regarded as a code template only. 916 * // It will require modifications to work: 917 * // - It may require correct/in-range values for request initialization. 918 * // - It may require specifying regional endpoints when creating the service client as shown in 919 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 920 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 921 * PauseJobRequest request = 922 * PauseJobRequest.newBuilder() 923 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 924 * .build(); 925 * ApiFuture<Job> future = cloudSchedulerClient.pauseJobCallable().futureCall(request); 926 * // Do something. 927 * Job response = future.get(); 928 * } 929 * }</pre> 930 */ pauseJobCallable()931 public final UnaryCallable<PauseJobRequest, Job> pauseJobCallable() { 932 return stub.pauseJobCallable(); 933 } 934 935 // AUTO-GENERATED DOCUMENTATION AND METHOD. 936 /** 937 * Resume a job. 938 * 939 * <p>This method reenables a job after it has been 940 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in 941 * [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to 942 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in 943 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed. 944 * 945 * <p>Sample code: 946 * 947 * <pre>{@code 948 * // This snippet has been automatically generated and should be regarded as a code template only. 949 * // It will require modifications to work: 950 * // - It may require correct/in-range values for request initialization. 951 * // - It may require specifying regional endpoints when creating the service client as shown in 952 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 953 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 954 * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); 955 * Job response = cloudSchedulerClient.resumeJob(name); 956 * } 957 * }</pre> 958 * 959 * @param name Required. The job name. For example: 960 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 961 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 962 */ resumeJob(JobName name)963 public final Job resumeJob(JobName name) { 964 ResumeJobRequest request = 965 ResumeJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 966 return resumeJob(request); 967 } 968 969 // AUTO-GENERATED DOCUMENTATION AND METHOD. 970 /** 971 * Resume a job. 972 * 973 * <p>This method reenables a job after it has been 974 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in 975 * [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to 976 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in 977 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed. 978 * 979 * <p>Sample code: 980 * 981 * <pre>{@code 982 * // This snippet has been automatically generated and should be regarded as a code template only. 983 * // It will require modifications to work: 984 * // - It may require correct/in-range values for request initialization. 985 * // - It may require specifying regional endpoints when creating the service client as shown in 986 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 987 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 988 * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); 989 * Job response = cloudSchedulerClient.resumeJob(name); 990 * } 991 * }</pre> 992 * 993 * @param name Required. The job name. For example: 994 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 995 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 996 */ resumeJob(String name)997 public final Job resumeJob(String name) { 998 ResumeJobRequest request = ResumeJobRequest.newBuilder().setName(name).build(); 999 return resumeJob(request); 1000 } 1001 1002 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1003 /** 1004 * Resume a job. 1005 * 1006 * <p>This method reenables a job after it has been 1007 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in 1008 * [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to 1009 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in 1010 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed. 1011 * 1012 * <p>Sample code: 1013 * 1014 * <pre>{@code 1015 * // This snippet has been automatically generated and should be regarded as a code template only. 1016 * // It will require modifications to work: 1017 * // - It may require correct/in-range values for request initialization. 1018 * // - It may require specifying regional endpoints when creating the service client as shown in 1019 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1020 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1021 * ResumeJobRequest request = 1022 * ResumeJobRequest.newBuilder() 1023 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 1024 * .build(); 1025 * Job response = cloudSchedulerClient.resumeJob(request); 1026 * } 1027 * }</pre> 1028 * 1029 * @param request The request object containing all of the parameters for the API call. 1030 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1031 */ resumeJob(ResumeJobRequest request)1032 public final Job resumeJob(ResumeJobRequest request) { 1033 return resumeJobCallable().call(request); 1034 } 1035 1036 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1037 /** 1038 * Resume a job. 1039 * 1040 * <p>This method reenables a job after it has been 1041 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state of a job is stored in 1042 * [Job.state][google.cloud.scheduler.v1.Job.state]; after calling this method it will be set to 1043 * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job must be in 1044 * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] to be resumed. 1045 * 1046 * <p>Sample code: 1047 * 1048 * <pre>{@code 1049 * // This snippet has been automatically generated and should be regarded as a code template only. 1050 * // It will require modifications to work: 1051 * // - It may require correct/in-range values for request initialization. 1052 * // - It may require specifying regional endpoints when creating the service client as shown in 1053 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1054 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1055 * ResumeJobRequest request = 1056 * ResumeJobRequest.newBuilder() 1057 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 1058 * .build(); 1059 * ApiFuture<Job> future = cloudSchedulerClient.resumeJobCallable().futureCall(request); 1060 * // Do something. 1061 * Job response = future.get(); 1062 * } 1063 * }</pre> 1064 */ resumeJobCallable()1065 public final UnaryCallable<ResumeJobRequest, Job> resumeJobCallable() { 1066 return stub.resumeJobCallable(); 1067 } 1068 1069 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1070 /** 1071 * Forces a job to run now. 1072 * 1073 * <p>When this method is called, Cloud Scheduler will dispatch the job, even if the job is 1074 * already running. 1075 * 1076 * <p>Sample code: 1077 * 1078 * <pre>{@code 1079 * // This snippet has been automatically generated and should be regarded as a code template only. 1080 * // It will require modifications to work: 1081 * // - It may require correct/in-range values for request initialization. 1082 * // - It may require specifying regional endpoints when creating the service client as shown in 1083 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1084 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1085 * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); 1086 * Job response = cloudSchedulerClient.runJob(name); 1087 * } 1088 * }</pre> 1089 * 1090 * @param name Required. The job name. For example: 1091 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 1092 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1093 */ runJob(JobName name)1094 public final Job runJob(JobName name) { 1095 RunJobRequest request = 1096 RunJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); 1097 return runJob(request); 1098 } 1099 1100 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1101 /** 1102 * Forces a job to run now. 1103 * 1104 * <p>When this method is called, Cloud Scheduler will dispatch the job, even if the job is 1105 * already running. 1106 * 1107 * <p>Sample code: 1108 * 1109 * <pre>{@code 1110 * // This snippet has been automatically generated and should be regarded as a code template only. 1111 * // It will require modifications to work: 1112 * // - It may require correct/in-range values for request initialization. 1113 * // - It may require specifying regional endpoints when creating the service client as shown in 1114 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1115 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1116 * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); 1117 * Job response = cloudSchedulerClient.runJob(name); 1118 * } 1119 * }</pre> 1120 * 1121 * @param name Required. The job name. For example: 1122 * `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. 1123 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1124 */ runJob(String name)1125 public final Job runJob(String name) { 1126 RunJobRequest request = RunJobRequest.newBuilder().setName(name).build(); 1127 return runJob(request); 1128 } 1129 1130 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1131 /** 1132 * Forces a job to run now. 1133 * 1134 * <p>When this method is called, Cloud Scheduler will dispatch the job, even if the job is 1135 * already running. 1136 * 1137 * <p>Sample code: 1138 * 1139 * <pre>{@code 1140 * // This snippet has been automatically generated and should be regarded as a code template only. 1141 * // It will require modifications to work: 1142 * // - It may require correct/in-range values for request initialization. 1143 * // - It may require specifying regional endpoints when creating the service client as shown in 1144 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1145 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1146 * RunJobRequest request = 1147 * RunJobRequest.newBuilder() 1148 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 1149 * .build(); 1150 * Job response = cloudSchedulerClient.runJob(request); 1151 * } 1152 * }</pre> 1153 * 1154 * @param request The request object containing all of the parameters for the API call. 1155 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1156 */ runJob(RunJobRequest request)1157 public final Job runJob(RunJobRequest request) { 1158 return runJobCallable().call(request); 1159 } 1160 1161 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1162 /** 1163 * Forces a job to run now. 1164 * 1165 * <p>When this method is called, Cloud Scheduler will dispatch the job, even if the job is 1166 * already running. 1167 * 1168 * <p>Sample code: 1169 * 1170 * <pre>{@code 1171 * // This snippet has been automatically generated and should be regarded as a code template only. 1172 * // It will require modifications to work: 1173 * // - It may require correct/in-range values for request initialization. 1174 * // - It may require specifying regional endpoints when creating the service client as shown in 1175 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1176 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1177 * RunJobRequest request = 1178 * RunJobRequest.newBuilder() 1179 * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) 1180 * .build(); 1181 * ApiFuture<Job> future = cloudSchedulerClient.runJobCallable().futureCall(request); 1182 * // Do something. 1183 * Job response = future.get(); 1184 * } 1185 * }</pre> 1186 */ runJobCallable()1187 public final UnaryCallable<RunJobRequest, Job> runJobCallable() { 1188 return stub.runJobCallable(); 1189 } 1190 1191 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1192 /** 1193 * Lists information about the supported locations for this service. 1194 * 1195 * <p>Sample code: 1196 * 1197 * <pre>{@code 1198 * // This snippet has been automatically generated and should be regarded as a code template only. 1199 * // It will require modifications to work: 1200 * // - It may require correct/in-range values for request initialization. 1201 * // - It may require specifying regional endpoints when creating the service client as shown in 1202 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1203 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1204 * ListLocationsRequest request = 1205 * ListLocationsRequest.newBuilder() 1206 * .setName("name3373707") 1207 * .setFilter("filter-1274492040") 1208 * .setPageSize(883849137) 1209 * .setPageToken("pageToken873572522") 1210 * .build(); 1211 * for (Location element : cloudSchedulerClient.listLocations(request).iterateAll()) { 1212 * // doThingsWith(element); 1213 * } 1214 * } 1215 * }</pre> 1216 * 1217 * @param request The request object containing all of the parameters for the API call. 1218 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1219 */ listLocations(ListLocationsRequest request)1220 public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { 1221 return listLocationsPagedCallable().call(request); 1222 } 1223 1224 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1225 /** 1226 * Lists information about the supported locations for this service. 1227 * 1228 * <p>Sample code: 1229 * 1230 * <pre>{@code 1231 * // This snippet has been automatically generated and should be regarded as a code template only. 1232 * // It will require modifications to work: 1233 * // - It may require correct/in-range values for request initialization. 1234 * // - It may require specifying regional endpoints when creating the service client as shown in 1235 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1236 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1237 * ListLocationsRequest request = 1238 * ListLocationsRequest.newBuilder() 1239 * .setName("name3373707") 1240 * .setFilter("filter-1274492040") 1241 * .setPageSize(883849137) 1242 * .setPageToken("pageToken873572522") 1243 * .build(); 1244 * ApiFuture<Location> future = 1245 * cloudSchedulerClient.listLocationsPagedCallable().futureCall(request); 1246 * // Do something. 1247 * for (Location element : future.get().iterateAll()) { 1248 * // doThingsWith(element); 1249 * } 1250 * } 1251 * }</pre> 1252 */ 1253 public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse> listLocationsPagedCallable()1254 listLocationsPagedCallable() { 1255 return stub.listLocationsPagedCallable(); 1256 } 1257 1258 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1259 /** 1260 * Lists information about the supported locations for this service. 1261 * 1262 * <p>Sample code: 1263 * 1264 * <pre>{@code 1265 * // This snippet has been automatically generated and should be regarded as a code template only. 1266 * // It will require modifications to work: 1267 * // - It may require correct/in-range values for request initialization. 1268 * // - It may require specifying regional endpoints when creating the service client as shown in 1269 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1270 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1271 * ListLocationsRequest request = 1272 * ListLocationsRequest.newBuilder() 1273 * .setName("name3373707") 1274 * .setFilter("filter-1274492040") 1275 * .setPageSize(883849137) 1276 * .setPageToken("pageToken873572522") 1277 * .build(); 1278 * while (true) { 1279 * ListLocationsResponse response = cloudSchedulerClient.listLocationsCallable().call(request); 1280 * for (Location element : response.getLocationsList()) { 1281 * // doThingsWith(element); 1282 * } 1283 * String nextPageToken = response.getNextPageToken(); 1284 * if (!Strings.isNullOrEmpty(nextPageToken)) { 1285 * request = request.toBuilder().setPageToken(nextPageToken).build(); 1286 * } else { 1287 * break; 1288 * } 1289 * } 1290 * } 1291 * }</pre> 1292 */ listLocationsCallable()1293 public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() { 1294 return stub.listLocationsCallable(); 1295 } 1296 1297 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1298 /** 1299 * Gets information about a location. 1300 * 1301 * <p>Sample code: 1302 * 1303 * <pre>{@code 1304 * // This snippet has been automatically generated and should be regarded as a code template only. 1305 * // It will require modifications to work: 1306 * // - It may require correct/in-range values for request initialization. 1307 * // - It may require specifying regional endpoints when creating the service client as shown in 1308 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1309 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1310 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 1311 * Location response = cloudSchedulerClient.getLocation(request); 1312 * } 1313 * }</pre> 1314 * 1315 * @param request The request object containing all of the parameters for the API call. 1316 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 1317 */ getLocation(GetLocationRequest request)1318 public final Location getLocation(GetLocationRequest request) { 1319 return getLocationCallable().call(request); 1320 } 1321 1322 // AUTO-GENERATED DOCUMENTATION AND METHOD. 1323 /** 1324 * Gets information about a location. 1325 * 1326 * <p>Sample code: 1327 * 1328 * <pre>{@code 1329 * // This snippet has been automatically generated and should be regarded as a code template only. 1330 * // It will require modifications to work: 1331 * // - It may require correct/in-range values for request initialization. 1332 * // - It may require specifying regional endpoints when creating the service client as shown in 1333 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 1334 * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { 1335 * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); 1336 * ApiFuture<Location> future = cloudSchedulerClient.getLocationCallable().futureCall(request); 1337 * // Do something. 1338 * Location response = future.get(); 1339 * } 1340 * }</pre> 1341 */ getLocationCallable()1342 public final UnaryCallable<GetLocationRequest, Location> getLocationCallable() { 1343 return stub.getLocationCallable(); 1344 } 1345 1346 @Override close()1347 public final void close() { 1348 stub.close(); 1349 } 1350 1351 @Override shutdown()1352 public void shutdown() { 1353 stub.shutdown(); 1354 } 1355 1356 @Override isShutdown()1357 public boolean isShutdown() { 1358 return stub.isShutdown(); 1359 } 1360 1361 @Override isTerminated()1362 public boolean isTerminated() { 1363 return stub.isTerminated(); 1364 } 1365 1366 @Override shutdownNow()1367 public void shutdownNow() { 1368 stub.shutdownNow(); 1369 } 1370 1371 @Override awaitTermination(long duration, TimeUnit unit)1372 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 1373 return stub.awaitTermination(duration, unit); 1374 } 1375 1376 public static class ListJobsPagedResponse 1377 extends AbstractPagedListResponse< 1378 ListJobsRequest, ListJobsResponse, Job, ListJobsPage, ListJobsFixedSizeCollection> { 1379 createAsync( PageContext<ListJobsRequest, ListJobsResponse, Job> context, ApiFuture<ListJobsResponse> futureResponse)1380 public static ApiFuture<ListJobsPagedResponse> createAsync( 1381 PageContext<ListJobsRequest, ListJobsResponse, Job> context, 1382 ApiFuture<ListJobsResponse> futureResponse) { 1383 ApiFuture<ListJobsPage> futurePage = 1384 ListJobsPage.createEmptyPage().createPageAsync(context, futureResponse); 1385 return ApiFutures.transform( 1386 futurePage, input -> new ListJobsPagedResponse(input), MoreExecutors.directExecutor()); 1387 } 1388 ListJobsPagedResponse(ListJobsPage page)1389 private ListJobsPagedResponse(ListJobsPage page) { 1390 super(page, ListJobsFixedSizeCollection.createEmptyCollection()); 1391 } 1392 } 1393 1394 public static class ListJobsPage 1395 extends AbstractPage<ListJobsRequest, ListJobsResponse, Job, ListJobsPage> { 1396 ListJobsPage( PageContext<ListJobsRequest, ListJobsResponse, Job> context, ListJobsResponse response)1397 private ListJobsPage( 1398 PageContext<ListJobsRequest, ListJobsResponse, Job> context, ListJobsResponse response) { 1399 super(context, response); 1400 } 1401 createEmptyPage()1402 private static ListJobsPage createEmptyPage() { 1403 return new ListJobsPage(null, null); 1404 } 1405 1406 @Override createPage( PageContext<ListJobsRequest, ListJobsResponse, Job> context, ListJobsResponse response)1407 protected ListJobsPage createPage( 1408 PageContext<ListJobsRequest, ListJobsResponse, Job> context, ListJobsResponse response) { 1409 return new ListJobsPage(context, response); 1410 } 1411 1412 @Override createPageAsync( PageContext<ListJobsRequest, ListJobsResponse, Job> context, ApiFuture<ListJobsResponse> futureResponse)1413 public ApiFuture<ListJobsPage> createPageAsync( 1414 PageContext<ListJobsRequest, ListJobsResponse, Job> context, 1415 ApiFuture<ListJobsResponse> futureResponse) { 1416 return super.createPageAsync(context, futureResponse); 1417 } 1418 } 1419 1420 public static class ListJobsFixedSizeCollection 1421 extends AbstractFixedSizeCollection< 1422 ListJobsRequest, ListJobsResponse, Job, ListJobsPage, ListJobsFixedSizeCollection> { 1423 ListJobsFixedSizeCollection(List<ListJobsPage> pages, int collectionSize)1424 private ListJobsFixedSizeCollection(List<ListJobsPage> pages, int collectionSize) { 1425 super(pages, collectionSize); 1426 } 1427 createEmptyCollection()1428 private static ListJobsFixedSizeCollection createEmptyCollection() { 1429 return new ListJobsFixedSizeCollection(null, 0); 1430 } 1431 1432 @Override createCollection( List<ListJobsPage> pages, int collectionSize)1433 protected ListJobsFixedSizeCollection createCollection( 1434 List<ListJobsPage> pages, int collectionSize) { 1435 return new ListJobsFixedSizeCollection(pages, collectionSize); 1436 } 1437 } 1438 1439 public static class ListLocationsPagedResponse 1440 extends AbstractPagedListResponse< 1441 ListLocationsRequest, 1442 ListLocationsResponse, 1443 Location, 1444 ListLocationsPage, 1445 ListLocationsFixedSizeCollection> { 1446 createAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1447 public static ApiFuture<ListLocationsPagedResponse> createAsync( 1448 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1449 ApiFuture<ListLocationsResponse> futureResponse) { 1450 ApiFuture<ListLocationsPage> futurePage = 1451 ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); 1452 return ApiFutures.transform( 1453 futurePage, 1454 input -> new ListLocationsPagedResponse(input), 1455 MoreExecutors.directExecutor()); 1456 } 1457 ListLocationsPagedResponse(ListLocationsPage page)1458 private ListLocationsPagedResponse(ListLocationsPage page) { 1459 super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); 1460 } 1461 } 1462 1463 public static class ListLocationsPage 1464 extends AbstractPage< 1465 ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { 1466 ListLocationsPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1467 private ListLocationsPage( 1468 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1469 ListLocationsResponse response) { 1470 super(context, response); 1471 } 1472 createEmptyPage()1473 private static ListLocationsPage createEmptyPage() { 1474 return new ListLocationsPage(null, null); 1475 } 1476 1477 @Override createPage( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ListLocationsResponse response)1478 protected ListLocationsPage createPage( 1479 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1480 ListLocationsResponse response) { 1481 return new ListLocationsPage(context, response); 1482 } 1483 1484 @Override createPageAsync( PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, ApiFuture<ListLocationsResponse> futureResponse)1485 public ApiFuture<ListLocationsPage> createPageAsync( 1486 PageContext<ListLocationsRequest, ListLocationsResponse, Location> context, 1487 ApiFuture<ListLocationsResponse> futureResponse) { 1488 return super.createPageAsync(context, futureResponse); 1489 } 1490 } 1491 1492 public static class ListLocationsFixedSizeCollection 1493 extends AbstractFixedSizeCollection< 1494 ListLocationsRequest, 1495 ListLocationsResponse, 1496 Location, 1497 ListLocationsPage, 1498 ListLocationsFixedSizeCollection> { 1499 ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize)1500 private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) { 1501 super(pages, collectionSize); 1502 } 1503 createEmptyCollection()1504 private static ListLocationsFixedSizeCollection createEmptyCollection() { 1505 return new ListLocationsFixedSizeCollection(null, 0); 1506 } 1507 1508 @Override createCollection( List<ListLocationsPage> pages, int collectionSize)1509 protected ListLocationsFixedSizeCollection createCollection( 1510 List<ListLocationsPage> pages, int collectionSize) { 1511 return new ListLocationsFixedSizeCollection(pages, collectionSize); 1512 } 1513 } 1514 } 1515