From 2f0fe714a8541dc72f88b45bddd8748e5f21cf29 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 5 Jan 2019 00:47:23 -0800 Subject: [PATCH] Regenerate scheduler client --- .../scheduler/v1beta1/SchedulerProto.java | 8 +- .../scheduler/v1beta1/cloudscheduler.proto | 1 + .../v1beta1/CloudSchedulerClient.java | 363 ++++++++++++------ .../cloud/scheduler/v1beta1/package-info.java | 4 +- .../v1beta1/CloudSchedulerClientTest.java | 94 ++--- .../google-cloud-scheduler/synth.metadata | 35 +- 6 files changed, 320 insertions(+), 185 deletions(-) diff --git a/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/java/com/google/cloud/scheduler/v1beta1/SchedulerProto.java b/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/java/com/google/cloud/scheduler/v1beta1/SchedulerProto.java index ef13fc69074d..992a365c68da 100644 --- a/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/java/com/google/cloud/scheduler/v1beta1/SchedulerProto.java +++ b/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/java/com/google/cloud/scheduler/v1beta1/SchedulerProto.java @@ -108,10 +108,10 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "cheduler.v1beta1.RunJobRequest\032#.google." + "cloud.scheduler.v1beta1.Job\"<\202\323\344\223\0026\"1/v1" + "beta1/{name=projects/*/locations/*/jobs/" - + "*}:run:\001*B\177\n\"com.google.cloud.scheduler." - + "v1beta1B\016SchedulerProtoP\001ZGgoogle.golang" - + ".org/genproto/googleapis/cloud/scheduler" - + "/v1beta1;schedulerb\006proto3" + + "*}:run:\001*B\213\001\n\"com.google.cloud.scheduler" + + ".v1beta1B\016SchedulerProtoP\001ZGgoogle.golan" + + "g.org/genproto/googleapis/cloud/schedule" + + "r/v1beta1;scheduler\242\002\tSCHEDULERb\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { diff --git a/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/proto/google/cloud/scheduler/v1beta1/cloudscheduler.proto b/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/proto/google/cloud/scheduler/v1beta1/cloudscheduler.proto index 56390c9df173..f3fa89dcf36a 100644 --- a/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/proto/google/cloud/scheduler/v1beta1/cloudscheduler.proto +++ b/google-api-grpc/proto-google-cloud-scheduler-v1beta1/src/main/proto/google/cloud/scheduler/v1beta1/cloudscheduler.proto @@ -26,6 +26,7 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/scheduler/v1bet option java_multiple_files = true; option java_outer_classname = "SchedulerProto"; option java_package = "com.google.cloud.scheduler.v1beta1"; +option objc_class_prefix = "SCHEDULER"; // The Cloud Scheduler API allows external entities to reliably diff --git a/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java b/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java index 5531160dc63b..1e3a8fffd56c 100644 --- a/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java +++ b/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java @@ -25,7 +25,6 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.scheduler.v1beta1.stub.CloudSchedulerStub; import com.google.cloud.scheduler.v1beta1.stub.CloudSchedulerStubSettings; import com.google.protobuf.Empty; @@ -46,8 +45,8 @@ *
  * 
  * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
- *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
- *   Job response = cloudSchedulerClient.getJob(formattedName);
+ *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+ *   Job response = cloudSchedulerClient.getJob(name);
  * }
  * 
  * 
@@ -108,69 +107,6 @@ public class CloudSchedulerClient implements BackgroundResource { private final CloudSchedulerSettings settings; private final CloudSchedulerStub stub; - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}"); - - private static final PathTemplate LOCATION_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); - - private static final PathTemplate JOB_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}/jobs/{job}"); - - /** Formats a string containing the fully-qualified path to represent a project resource. */ - public static final String formatProjectName(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** Formats a string containing the fully-qualified path to represent a location resource. */ - public static final String formatLocationName(String project, String location) { - return LOCATION_PATH_TEMPLATE.instantiate( - "project", project, - "location", location); - } - - /** Formats a string containing the fully-qualified path to represent a job resource. */ - public static final String formatJobName(String project, String location, String job) { - return JOB_PATH_TEMPLATE.instantiate( - "project", project, - "location", location, - "job", job); - } - - /** Parses the project from the given fully-qualified path which represents a project resource. */ - public static final String parseProjectFromProjectName(String projectName) { - return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); - } - - /** - * Parses the project from the given fully-qualified path which represents a location resource. - */ - public static final String parseProjectFromLocationName(String locationName) { - return LOCATION_PATH_TEMPLATE.parse(locationName).get("project"); - } - - /** - * Parses the location from the given fully-qualified path which represents a location resource. - */ - public static final String parseLocationFromLocationName(String locationName) { - return LOCATION_PATH_TEMPLATE.parse(locationName).get("location"); - } - - /** Parses the project from the given fully-qualified path which represents a job resource. */ - public static final String parseProjectFromJobName(String jobName) { - return JOB_PATH_TEMPLATE.parse(jobName).get("project"); - } - - /** Parses the location from the given fully-qualified path which represents a job resource. */ - public static final String parseLocationFromJobName(String jobName) { - return JOB_PATH_TEMPLATE.parse(jobName).get("location"); - } - - /** Parses the job from the given fully-qualified path which represents a job resource. */ - public static final String parseJobFromJobName(String jobName) { - return JOB_PATH_TEMPLATE.parse(jobName).get("job"); - } - /** Constructs an instance of CloudSchedulerClient with default settings. */ public static final CloudSchedulerClient create() throws IOException { return create(CloudSchedulerSettings.newBuilder().build()); @@ -227,8 +163,33 @@ public CloudSchedulerStub getStub() { * *

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]");
-   *   for (Job element : cloudSchedulerClient.listJobs(formattedParent).iterateAll()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param parent Required. + *

The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListJobsPagedResponse listJobs(LocationName parent) { + ListJobsRequest request = + ListJobsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return listJobs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists jobs. + * + *

Sample code: + * + *


+   * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (Job element : cloudSchedulerClient.listJobs(parent.toString()).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
@@ -239,7 +200,6 @@ public CloudSchedulerStub getStub() {
    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
    */
   public final ListJobsPagedResponse listJobs(String parent) {
-    LOCATION_PATH_TEMPLATE.validate(parent, "listJobs");
     ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent).build();
     return listJobs(request);
   }
@@ -252,9 +212,9 @@ public final ListJobsPagedResponse listJobs(String parent) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]");
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    *   ListJobsRequest request = ListJobsRequest.newBuilder()
-   *     .setParent(formattedParent)
+   *     .setParent(parent.toString())
    *     .build();
    *   for (Job element : cloudSchedulerClient.listJobs(request).iterateAll()) {
    *     // doThingsWith(element);
@@ -277,9 +237,9 @@ public final ListJobsPagedResponse listJobs(ListJobsRequest request) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]");
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    *   ListJobsRequest request = ListJobsRequest.newBuilder()
-   *     .setParent(formattedParent)
+   *     .setParent(parent.toString())
    *     .build();
    *   ApiFuture<ListJobsPagedResponse> future = cloudSchedulerClient.listJobsPagedCallable().futureCall(request);
    *   // Do something
@@ -301,9 +261,9 @@ public final UnaryCallable listJobsPaged
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]");
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    *   ListJobsRequest request = ListJobsRequest.newBuilder()
-   *     .setParent(formattedParent)
+   *     .setParent(parent.toString())
    *     .build();
    *   while (true) {
    *     ListJobsResponse response = cloudSchedulerClient.listJobsCallable().call(request);
@@ -332,8 +292,32 @@ public final UnaryCallable listJobsCallable()
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   Job response = cloudSchedulerClient.getJob(formattedName);
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.getJob(name);
+   * }
+   * 
+ * + * @param name Required. + *

The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job getJob(JobName name) { + + GetJobRequest request = + GetJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a job. + * + *

Sample code: + * + *


+   * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.getJob(name.toString());
    * }
    * 
* @@ -342,7 +326,7 @@ public final UnaryCallable listJobsCallable() * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Job getJob(String name) { - JOB_PATH_TEMPLATE.validate(name, "getJob"); + GetJobRequest request = GetJobRequest.newBuilder().setName(name).build(); return getJob(request); } @@ -355,9 +339,9 @@ public final Job getJob(String name) { * *

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   GetJobRequest request = GetJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   Job response = cloudSchedulerClient.getJob(request);
    * }
@@ -378,9 +362,9 @@ public final Job getJob(GetJobRequest request) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   GetJobRequest request = GetJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Job> future = cloudSchedulerClient.getJobCallable().futureCall(request);
    *   // Do something
@@ -400,9 +384,43 @@ public final UnaryCallable getJobCallable() {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]");
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    *   Job job = Job.newBuilder().build();
-   *   Job response = cloudSchedulerClient.createJob(formattedParent, job);
+   *   Job response = cloudSchedulerClient.createJob(parent, job);
+   * }
+   * 
+ * + * @param parent Required. + *

The location name. For example: `projects/PROJECT_ID/locations/LOCATION_ID`. + * @param job Required. + *

The job to add. The user can optionally specify a name for the job in + * [name][google.cloud.scheduler.v1beta1.Job.name]. + * [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an existing job. If a + * name is not specified then the system will generate a random unique name that will be + * returned ([name][google.cloud.scheduler.v1beta1.Job.name]) in the response. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job createJob(LocationName parent, Job job) { + + CreateJobRequest request = + CreateJobRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setJob(job) + .build(); + return createJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a job. + * + *

Sample code: + * + *


+   * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Job job = Job.newBuilder().build();
+   *   Job response = cloudSchedulerClient.createJob(parent.toString(), job);
    * }
    * 
* @@ -417,7 +435,7 @@ public final UnaryCallable getJobCallable() { * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Job createJob(String parent, Job job) { - LOCATION_PATH_TEMPLATE.validate(parent, "createJob"); + CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent).setJob(job).build(); return createJob(request); } @@ -430,10 +448,10 @@ public final Job createJob(String parent, Job job) { * *

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]");
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    *   Job job = Job.newBuilder().build();
    *   CreateJobRequest request = CreateJobRequest.newBuilder()
-   *     .setParent(formattedParent)
+   *     .setParent(parent.toString())
    *     .setJob(job)
    *     .build();
    *   Job response = cloudSchedulerClient.createJob(request);
@@ -455,10 +473,10 @@ public final Job createJob(CreateJobRequest request) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]");
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    *   Job job = Job.newBuilder().build();
    *   CreateJobRequest request = CreateJobRequest.newBuilder()
-   *     .setParent(formattedParent)
+   *     .setParent(parent.toString())
    *     .setJob(job)
    *     .build();
    *   ApiFuture<Job> future = cloudSchedulerClient.createJobCallable().futureCall(request);
@@ -577,8 +595,32 @@ public final UnaryCallable updateJobCallable() {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   cloudSchedulerClient.deleteJob(formattedName);
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   cloudSchedulerClient.deleteJob(name);
+   * }
+   * 
+ * + * @param name Required. + *

The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteJob(JobName name) { + + DeleteJobRequest request = + DeleteJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a job. + * + *

Sample code: + * + *


+   * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   cloudSchedulerClient.deleteJob(name.toString());
    * }
    * 
* @@ -587,7 +629,7 @@ public final UnaryCallable updateJobCallable() { * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteJob(String name) { - JOB_PATH_TEMPLATE.validate(name, "deleteJob"); + DeleteJobRequest request = DeleteJobRequest.newBuilder().setName(name).build(); deleteJob(request); } @@ -600,9 +642,9 @@ public final void deleteJob(String name) { * *

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   DeleteJobRequest request = DeleteJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   cloudSchedulerClient.deleteJob(request);
    * }
@@ -623,9 +665,9 @@ public final void deleteJob(DeleteJobRequest request) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   DeleteJobRequest request = DeleteJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Void> future = cloudSchedulerClient.deleteJobCallable().futureCall(request);
    *   // Do something
@@ -651,8 +693,38 @@ public final UnaryCallable deleteJobCallable() {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   Job response = cloudSchedulerClient.pauseJob(formattedName);
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.pauseJob(name);
+   * }
+   * 
+ * + * @param name Required. + *

The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job pauseJob(JobName name) { + + PauseJobRequest request = + PauseJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return pauseJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Pauses a job. + * + *

If a job is paused then the system will stop executing the job until it is re-enabled via + * [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The state of the job is + * stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it will be set to + * [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in + * [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED] to be paused. + * + *

Sample code: + * + *


+   * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.pauseJob(name.toString());
    * }
    * 
* @@ -661,7 +733,7 @@ public final UnaryCallable deleteJobCallable() { * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Job pauseJob(String name) { - JOB_PATH_TEMPLATE.validate(name, "pauseJob"); + PauseJobRequest request = PauseJobRequest.newBuilder().setName(name).build(); return pauseJob(request); } @@ -680,9 +752,9 @@ public final Job pauseJob(String name) { * *

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   PauseJobRequest request = PauseJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   Job response = cloudSchedulerClient.pauseJob(request);
    * }
@@ -709,9 +781,9 @@ public final Job pauseJob(PauseJobRequest request) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   PauseJobRequest request = PauseJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Job> future = cloudSchedulerClient.pauseJobCallable().futureCall(request);
    *   // Do something
@@ -737,8 +809,38 @@ public final UnaryCallable pauseJobCallable() {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   Job response = cloudSchedulerClient.resumeJob(formattedName);
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.resumeJob(name);
+   * }
+   * 
+ * + * @param name Required. + *

The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job resumeJob(JobName name) { + + ResumeJobRequest request = + ResumeJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return resumeJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Resume a job. + * + *

This method reenables a job after it has been + * [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The state of a job is + * stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it + * will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job + * must be in [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed. + * + *

Sample code: + * + *


+   * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.resumeJob(name.toString());
    * }
    * 
* @@ -747,7 +849,7 @@ public final UnaryCallable pauseJobCallable() { * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Job resumeJob(String name) { - JOB_PATH_TEMPLATE.validate(name, "resumeJob"); + ResumeJobRequest request = ResumeJobRequest.newBuilder().setName(name).build(); return resumeJob(request); } @@ -766,9 +868,9 @@ public final Job resumeJob(String name) { * *

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   ResumeJobRequest request = ResumeJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   Job response = cloudSchedulerClient.resumeJob(request);
    * }
@@ -795,9 +897,9 @@ public final Job resumeJob(ResumeJobRequest request) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   ResumeJobRequest request = ResumeJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Job> future = cloudSchedulerClient.resumeJobCallable().futureCall(request);
    *   // Do something
@@ -820,8 +922,35 @@ public final UnaryCallable resumeJobCallable() {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   Job response = cloudSchedulerClient.runJob(formattedName);
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.runJob(name);
+   * }
+   * 
+ * + * @param name Required. + *

The job name. For example: `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job runJob(JobName name) { + + RunJobRequest request = + RunJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return runJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Forces a job to run now. + * + *

When this method is called, Cloud Scheduler will dispatch the job, even if the job is + * already running. + * + *

Sample code: + * + *


+   * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   Job response = cloudSchedulerClient.runJob(name.toString());
    * }
    * 
* @@ -830,7 +959,7 @@ public final UnaryCallable resumeJobCallable() { * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Job runJob(String name) { - JOB_PATH_TEMPLATE.validate(name, "runJob"); + RunJobRequest request = RunJobRequest.newBuilder().setName(name).build(); return runJob(request); } @@ -846,9 +975,9 @@ public final Job runJob(String name) { * *

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   RunJobRequest request = RunJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   Job response = cloudSchedulerClient.runJob(request);
    * }
@@ -872,9 +1001,9 @@ public final Job runJob(RunJobRequest request) {
    *
    * 

    * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
-   *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
+   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
    *   RunJobRequest request = RunJobRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Job> future = cloudSchedulerClient.runJobCallable().futureCall(request);
    *   // Do something
diff --git a/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/package-info.java b/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/package-info.java
index 9240aae4f121..4f5848b10f17 100644
--- a/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/package-info.java
+++ b/google-cloud-clients/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/package-info.java
@@ -29,8 +29,8 @@
  * 
  * 
  * try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) {
- *   String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]");
- *   Job response = cloudSchedulerClient.getJob(formattedName);
+ *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
+ *   Job response = cloudSchedulerClient.getJob(name);
  * }
  * 
  * 
diff --git a/google-cloud-clients/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClientTest.java b/google-cloud-clients/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClientTest.java index 4af9b73e8777..25d32eb4356f 100644 --- a/google-cloud-clients/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClientTest.java +++ b/google-cloud-clients/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClientTest.java @@ -87,9 +87,9 @@ public void listJobsTest() { ListJobsResponse.newBuilder().setNextPageToken(nextPageToken).addAllJobs(jobs).build(); mockCloudScheduler.addResponse(expectedResponse); - String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]"); + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - ListJobsPagedResponse pagedListResponse = client.listJobs(formattedParent); + ListJobsPagedResponse pagedListResponse = client.listJobs(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); Assert.assertEquals(1, resources.size()); @@ -99,7 +99,7 @@ public void listJobsTest() { Assert.assertEquals(1, actualRequests.size()); ListJobsRequest actualRequest = (ListJobsRequest) actualRequests.get(0); - Assert.assertEquals(formattedParent, actualRequest.getParent()); + Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -113,9 +113,9 @@ public void listJobsExceptionTest() throws Exception { mockCloudScheduler.addException(exception); try { - String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]"); + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - client.listJobs(formattedParent); + client.listJobs(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -125,29 +125,29 @@ public void listJobsExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void getJobTest() { - String name2 = "name2-1052831874"; + JobName name2 = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); String description = "description-1724546052"; String schedule = "schedule-697920873"; String timeZone = "timeZone36848094"; Job expectedResponse = Job.newBuilder() - .setName(name2) + .setName(name2.toString()) .setDescription(description) .setSchedule(schedule) .setTimeZone(timeZone) .build(); mockCloudScheduler.addResponse(expectedResponse); - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - Job actualResponse = client.getJob(formattedName); + Job actualResponse = client.getJob(name); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudScheduler.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetJobRequest actualRequest = (GetJobRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, JobName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -161,9 +161,9 @@ public void getJobExceptionTest() throws Exception { mockCloudScheduler.addException(exception); try { - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - client.getJob(formattedName); + client.getJob(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -173,30 +173,30 @@ public void getJobExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void createJobTest() { - String name = "name3373707"; + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); String description = "description-1724546052"; String schedule = "schedule-697920873"; String timeZone = "timeZone36848094"; Job expectedResponse = Job.newBuilder() - .setName(name) + .setName(name.toString()) .setDescription(description) .setSchedule(schedule) .setTimeZone(timeZone) .build(); mockCloudScheduler.addResponse(expectedResponse); - String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]"); + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Job job = Job.newBuilder().build(); - Job actualResponse = client.createJob(formattedParent, job); + Job actualResponse = client.createJob(parent, job); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudScheduler.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateJobRequest actualRequest = (CreateJobRequest) actualRequests.get(0); - Assert.assertEquals(formattedParent, actualRequest.getParent()); + Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); Assert.assertEquals(job, actualRequest.getJob()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -211,10 +211,10 @@ public void createJobExceptionTest() throws Exception { mockCloudScheduler.addException(exception); try { - String formattedParent = CloudSchedulerClient.formatLocationName("[PROJECT]", "[LOCATION]"); + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Job job = Job.newBuilder().build(); - client.createJob(formattedParent, job); + client.createJob(parent, job); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -224,13 +224,13 @@ public void createJobExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void updateJobTest() { - String name = "name3373707"; + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); String description = "description-1724546052"; String schedule = "schedule-697920873"; String timeZone = "timeZone36848094"; Job expectedResponse = Job.newBuilder() - .setName(name) + .setName(name.toString()) .setDescription(description) .setSchedule(schedule) .setTimeZone(timeZone) @@ -278,15 +278,15 @@ public void deleteJobTest() { Empty expectedResponse = Empty.newBuilder().build(); mockCloudScheduler.addResponse(expectedResponse); - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - client.deleteJob(formattedName); + client.deleteJob(name); List actualRequests = mockCloudScheduler.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteJobRequest actualRequest = (DeleteJobRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, JobName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -300,9 +300,9 @@ public void deleteJobExceptionTest() throws Exception { mockCloudScheduler.addException(exception); try { - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - client.deleteJob(formattedName); + client.deleteJob(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -312,29 +312,29 @@ public void deleteJobExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void pauseJobTest() { - String name2 = "name2-1052831874"; + JobName name2 = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); String description = "description-1724546052"; String schedule = "schedule-697920873"; String timeZone = "timeZone36848094"; Job expectedResponse = Job.newBuilder() - .setName(name2) + .setName(name2.toString()) .setDescription(description) .setSchedule(schedule) .setTimeZone(timeZone) .build(); mockCloudScheduler.addResponse(expectedResponse); - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - Job actualResponse = client.pauseJob(formattedName); + Job actualResponse = client.pauseJob(name); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudScheduler.getRequests(); Assert.assertEquals(1, actualRequests.size()); PauseJobRequest actualRequest = (PauseJobRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, JobName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -348,9 +348,9 @@ public void pauseJobExceptionTest() throws Exception { mockCloudScheduler.addException(exception); try { - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - client.pauseJob(formattedName); + client.pauseJob(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -360,29 +360,29 @@ public void pauseJobExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void resumeJobTest() { - String name2 = "name2-1052831874"; + JobName name2 = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); String description = "description-1724546052"; String schedule = "schedule-697920873"; String timeZone = "timeZone36848094"; Job expectedResponse = Job.newBuilder() - .setName(name2) + .setName(name2.toString()) .setDescription(description) .setSchedule(schedule) .setTimeZone(timeZone) .build(); mockCloudScheduler.addResponse(expectedResponse); - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - Job actualResponse = client.resumeJob(formattedName); + Job actualResponse = client.resumeJob(name); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudScheduler.getRequests(); Assert.assertEquals(1, actualRequests.size()); ResumeJobRequest actualRequest = (ResumeJobRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, JobName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -396,9 +396,9 @@ public void resumeJobExceptionTest() throws Exception { mockCloudScheduler.addException(exception); try { - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - client.resumeJob(formattedName); + client.resumeJob(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -408,29 +408,29 @@ public void resumeJobExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void runJobTest() { - String name2 = "name2-1052831874"; + JobName name2 = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); String description = "description-1724546052"; String schedule = "schedule-697920873"; String timeZone = "timeZone36848094"; Job expectedResponse = Job.newBuilder() - .setName(name2) + .setName(name2.toString()) .setDescription(description) .setSchedule(schedule) .setTimeZone(timeZone) .build(); mockCloudScheduler.addResponse(expectedResponse); - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - Job actualResponse = client.runJob(formattedName); + Job actualResponse = client.runJob(name); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudScheduler.getRequests(); Assert.assertEquals(1, actualRequests.size()); RunJobRequest actualRequest = (RunJobRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, JobName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -444,9 +444,9 @@ public void runJobExceptionTest() throws Exception { mockCloudScheduler.addException(exception); try { - String formattedName = CloudSchedulerClient.formatJobName("[PROJECT]", "[LOCATION]", "[JOB]"); + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - client.runJob(formattedName); + client.runJob(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception diff --git a/google-cloud-clients/google-cloud-scheduler/synth.metadata b/google-cloud-clients/google-cloud-scheduler/synth.metadata index 2bd4f07a69a5..3fe1cfae7e55 100644 --- a/google-cloud-clients/google-cloud-scheduler/synth.metadata +++ b/google-cloud-clients/google-cloud-scheduler/synth.metadata @@ -1,27 +1,32 @@ { + "updateTime": "2019-01-05T08:47:23.002288Z", "sources": [ { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "5a57f0c13a358b2b15452bf2d67453774a5f6d4f", - "internalRef": "221837528" + "generator": { + "name": "artman", + "version": "0.16.4", + "dockerImage": "googleapis/artman@sha256:8b45fae963557c3299921037ecbb86f0689f41b1b4aea73408ebc50562cb2857" } }, { "git": { - "name": "googleapis-private", - "remote": "https://github.com/googleapis/googleapis-private.git", - "sha": "6aa8e1a447bb8d0367150356a28cb4d3f2332641", - "internalRef": "221340946" + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "a111a53c0c6722afcd793b64724ceef7862db5b9", + "internalRef": "227896184" } - }, + } + ], + "destinations": [ { - "generator": { - "name": "artman", - "version": "0.16.0", - "dockerImage": "googleapis/artman@sha256:90f9d15e9bad675aeecd586725bce48f5667ffe7d5fc4d1e96d51ff34304815b" + "client": { + "source": "googleapis", + "apiName": "scheduler", + "apiVersion": "v1beta1", + "language": "java", + "generator": "gapic", + "config": "google/cloud/scheduler/artman_cloudscheduler_v1beta1.yaml" } } ] -} +} \ No newline at end of file