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