From 811573dc7413d2bbf02bf66c1e88058ba736354c Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 14 Dec 2020 10:42:04 -0800 Subject: [PATCH] chore: migrate to microgenerator (#78) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/7b434ed7-41bc-42d7-adee-51bd18fb325b/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 346372957 Source-Link: https://github.com/googleapis/googleapis/commit/857f70daef9f4c38f042fb3dfb7b8423ae18fd19 PiperOrigin-RevId: 346126713 Source-Link: https://github.com/googleapis/googleapis/commit/b8b2f8c288cec1f673bf10aa5008819c1576bf2e PiperOrigin-RevId: 345476969 Source-Link: https://github.com/googleapis/googleapis/commit/7be2c821dd88109038c55c89f7dd48f092eeab9d PiperOrigin-RevId: 345067549 Source-Link: https://github.com/googleapis/googleapis/commit/8cfc6c874574b649b4524a4ef6a0651533325a84 PiperOrigin-RevId: 344906237 Source-Link: https://github.com/googleapis/googleapis/commit/14adde91e90011702483e943edf1044549252bd9 PiperOrigin-RevId: 344134135 Source-Link: https://github.com/googleapis/googleapis/commit/b11a87f3b54be3a5e42c15020ee1e0781f86da90 --- .../v1beta1/TranscoderServiceClient.java | 517 ++--------------- .../v1beta1/TranscoderServiceSettings.java | 33 +- .../transcoder/v1beta1/package-info.java | 18 +- .../GrpcTranscoderServiceCallableFactory.java | 40 +- .../stub/GrpcTranscoderServiceStub.java | 50 +- .../v1beta1/stub/TranscoderServiceStub.java | 9 +- .../stub/TranscoderServiceStubSettings.java | 319 ++++++----- .../v1beta1/MockTranscoderService.java | 6 +- .../v1beta1/MockTranscoderServiceImpl.java | 38 +- .../v1beta1/TranscoderServiceClientTest.java | 527 ++++++++++++++---- .../video/transcoder/v1beta1/JobName.java | 112 ++-- .../transcoder/v1beta1/JobTemplateName.java | 112 ++-- .../transcoder/v1beta1/LocationName.java | 98 ++-- synth.metadata | 6 +- 14 files changed, 905 insertions(+), 980 deletions(-) diff --git a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClient.java b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClient.java index a35c4064..16c5b294 100644 --- a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClient.java +++ b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClient.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1; import com.google.api.core.ApiFunction; @@ -34,7 +35,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: Using the Transcoder API, you can queue asynchronous jobs for transcoding * media into various output formats. Output formats may include different streaming standards such @@ -45,17 +46,7 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * - *

- * 
- * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
- *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
- *   Job job = Job.newBuilder().build();
- *   Job response = transcoderServiceClient.createJob(parent, job);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the transcoderServiceClient object to clean up resources + *

Note: close() needs to be called on the TranscoderServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). * @@ -84,30 +75,28 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * TranscoderServiceSettings transcoderServiceSettings =
  *     TranscoderServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * TranscoderServiceClient transcoderServiceClient =
  *     TranscoderServiceClient.create(transcoderServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * TranscoderServiceSettings transcoderServiceSettings =
  *     TranscoderServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * TranscoderServiceClient transcoderServiceClient =
  *     TranscoderServiceClient.create(transcoderServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator") public class TranscoderServiceClient implements BackgroundResource { private final TranscoderServiceSettings settings; private final TranscoderServiceStub stub; @@ -128,7 +117,7 @@ public static final TranscoderServiceClient create(TranscoderServiceSettings set /** * Constructs an instance of TranscoderServiceClient, using the given stub for making calls. This - * is for advanced usage - prefer to use TranscoderServiceSettings}. + * is for advanced usage - prefer using create(TranscoderServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final TranscoderServiceClient create(TranscoderServiceStub stub) { @@ -160,20 +149,10 @@ public TranscoderServiceStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Job job = Job.newBuilder().build();
-   *   Job response = transcoderServiceClient.createJob(parent, job);
-   * }
-   * 
- * * @param parent Required. The parent location to create and process this job. Format: * `projects/{project}/locations/{location}` * @param job Required. Parameters for creating transcoding job. @@ -188,20 +167,10 @@ public final Job createJob(LocationName parent, Job job) { return createJob(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Job job = Job.newBuilder().build();
-   *   Job response = transcoderServiceClient.createJob(parent.toString(), job);
-   * }
-   * 
- * * @param parent Required. The parent location to create and process this job. Format: * `projects/{project}/locations/{location}` * @param job Required. Parameters for creating transcoding job. @@ -212,24 +181,10 @@ public final Job createJob(String parent, Job job) { return createJob(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Job job = Job.newBuilder().build();
-   *   CreateJobRequest request = CreateJobRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setJob(job)
-   *     .build();
-   *   Job response = transcoderServiceClient.createJob(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -237,45 +192,20 @@ public final Job createJob(CreateJobRequest request) { return createJobCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job in the specified region. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Job job = Job.newBuilder().build();
-   *   CreateJobRequest request = CreateJobRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setJob(job)
-   *     .build();
-   *   ApiFuture<Job> future = transcoderServiceClient.createJobCallable().futureCall(request);
-   *   // Do something
-   *   Job response = future.get();
-   * }
-   * 
*/ public final UnaryCallable createJobCallable() { return stub.createJobCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists jobs in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   for (Job element : transcoderServiceClient.listJobs(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. Format: `projects/{project}/locations/{location}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -285,21 +215,10 @@ public final ListJobsPagedResponse listJobs(LocationName parent) { return listJobs(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists jobs in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   for (Job element : transcoderServiceClient.listJobs(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. Format: `projects/{project}/locations/{location}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -308,24 +227,10 @@ public final ListJobsPagedResponse listJobs(String parent) { return listJobs(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists jobs in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListJobsRequest request = ListJobsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   for (Job element : transcoderServiceClient.listJobs(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -333,74 +238,30 @@ public final ListJobsPagedResponse listJobs(ListJobsRequest request) { return listJobsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists jobs in the specified region. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListJobsRequest request = ListJobsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListJobsPagedResponse> future = transcoderServiceClient.listJobsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Job element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listJobsPagedCallable() { return stub.listJobsPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists jobs in the specified region. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListJobsRequest request = ListJobsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   while (true) {
-   *     ListJobsResponse response = transcoderServiceClient.listJobsCallable().call(request);
-   *     for (Job element : response.getJobsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listJobsCallable() { return stub.listJobsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job data. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   Job response = transcoderServiceClient.getJob(name);
-   * }
-   * 
- * * @param name Required. The name of the job to retrieve. Format: * `projects/{project}/locations/{location}/jobs/{job}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -411,19 +272,10 @@ public final Job getJob(JobName name) { return getJob(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job data. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   Job response = transcoderServiceClient.getJob(name.toString());
-   * }
-   * 
- * * @param name Required. The name of the job to retrieve. Format: * `projects/{project}/locations/{location}/jobs/{job}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -433,22 +285,10 @@ public final Job getJob(String name) { return getJob(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job data. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   GetJobRequest request = GetJobRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Job response = transcoderServiceClient.getJob(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -456,41 +296,20 @@ public final Job getJob(GetJobRequest request) { return getJobCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job data. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   GetJobRequest request = GetJobRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Job> future = transcoderServiceClient.getJobCallable().futureCall(request);
-   *   // Do something
-   *   Job response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getJobCallable() { return stub.getJobCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   transcoderServiceClient.deleteJob(name);
-   * }
-   * 
- * * @param name Required. The name of the job to delete. Format: * `projects/{project}/locations/{location}/jobs/{job}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -501,19 +320,10 @@ public final void deleteJob(JobName name) { deleteJob(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   transcoderServiceClient.deleteJob(name.toString());
-   * }
-   * 
- * * @param name Required. The name of the job to delete. Format: * `projects/{project}/locations/{location}/jobs/{job}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -523,22 +333,10 @@ public final void deleteJob(String name) { deleteJob(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   DeleteJobRequest request = DeleteJobRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   transcoderServiceClient.deleteJob(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -546,43 +344,20 @@ public final void deleteJob(DeleteJobRequest request) { deleteJobCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
-   *   DeleteJobRequest request = DeleteJobRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = transcoderServiceClient.deleteJobCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ public final UnaryCallable deleteJobCallable() { return stub.deleteJobCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job template in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   JobTemplate jobTemplate = JobTemplate.newBuilder().build();
-   *   String jobTemplateId = "";
-   *   JobTemplate response = transcoderServiceClient.createJobTemplate(parent, jobTemplate, jobTemplateId);
-   * }
-   * 
- * * @param parent Required. The parent location to create this job template. Format: * `projects/{project}/locations/{location}` * @param jobTemplate Required. Parameters for creating job template. @@ -603,21 +378,10 @@ public final JobTemplate createJobTemplate( return createJobTemplate(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job template in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   JobTemplate jobTemplate = JobTemplate.newBuilder().build();
-   *   String jobTemplateId = "";
-   *   JobTemplate response = transcoderServiceClient.createJobTemplate(parent.toString(), jobTemplate, jobTemplateId);
-   * }
-   * 
- * * @param parent Required. The parent location to create this job template. Format: * `projects/{project}/locations/{location}` * @param jobTemplate Required. Parameters for creating job template. @@ -638,26 +402,10 @@ public final JobTemplate createJobTemplate( return createJobTemplate(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job template in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   JobTemplate jobTemplate = JobTemplate.newBuilder().build();
-   *   String jobTemplateId = "";
-   *   CreateJobTemplateRequest request = CreateJobTemplateRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setJobTemplate(jobTemplate)
-   *     .setJobTemplateId(jobTemplateId)
-   *     .build();
-   *   JobTemplate response = transcoderServiceClient.createJobTemplate(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -665,47 +413,20 @@ public final JobTemplate createJobTemplate(CreateJobTemplateRequest request) { return createJobTemplateCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a job template in the specified region. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   JobTemplate jobTemplate = JobTemplate.newBuilder().build();
-   *   String jobTemplateId = "";
-   *   CreateJobTemplateRequest request = CreateJobTemplateRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setJobTemplate(jobTemplate)
-   *     .setJobTemplateId(jobTemplateId)
-   *     .build();
-   *   ApiFuture<JobTemplate> future = transcoderServiceClient.createJobTemplateCallable().futureCall(request);
-   *   // Do something
-   *   JobTemplate response = future.get();
-   * }
-   * 
*/ public final UnaryCallable createJobTemplateCallable() { return stub.createJobTemplateCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists job templates in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   for (JobTemplate element : transcoderServiceClient.listJobTemplates(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. The parent location from which to retrieve the collection of job * templates. Format: `projects/{project}/locations/{location}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -718,21 +439,10 @@ public final ListJobTemplatesPagedResponse listJobTemplates(LocationName parent) return listJobTemplates(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists job templates in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   for (JobTemplate element : transcoderServiceClient.listJobTemplates(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. The parent location from which to retrieve the collection of job * templates. Format: `projects/{project}/locations/{location}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -743,24 +453,10 @@ public final ListJobTemplatesPagedResponse listJobTemplates(String parent) { return listJobTemplates(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists job templates in the specified region. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListJobTemplatesRequest request = ListJobTemplatesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   for (JobTemplate element : transcoderServiceClient.listJobTemplates(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -768,76 +464,32 @@ public final ListJobTemplatesPagedResponse listJobTemplates(ListJobTemplatesRequ return listJobTemplatesPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists job templates in the specified region. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListJobTemplatesRequest request = ListJobTemplatesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListJobTemplatesPagedResponse> future = transcoderServiceClient.listJobTemplatesPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (JobTemplate element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listJobTemplatesPagedCallable() { return stub.listJobTemplatesPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists job templates in the specified region. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   ListJobTemplatesRequest request = ListJobTemplatesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   while (true) {
-   *     ListJobTemplatesResponse response = transcoderServiceClient.listJobTemplatesCallable().call(request);
-   *     for (JobTemplate element : response.getJobTemplatesList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listJobTemplatesCallable() { return stub.listJobTemplatesCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job template data. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   JobTemplate response = transcoderServiceClient.getJobTemplate(name);
-   * }
-   * 
- * * @param name Required. The name of the job template to retrieve. Format: * `projects/{project}/locations/{location}/jobTemplates/{job_template}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -848,19 +500,10 @@ public final JobTemplate getJobTemplate(JobTemplateName name) { return getJobTemplate(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job template data. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   JobTemplate response = transcoderServiceClient.getJobTemplate(name.toString());
-   * }
-   * 
- * * @param name Required. The name of the job template to retrieve. Format: * `projects/{project}/locations/{location}/jobTemplates/{job_template}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -870,22 +513,10 @@ public final JobTemplate getJobTemplate(String name) { return getJobTemplate(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job template data. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   GetJobTemplateRequest request = GetJobTemplateRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   JobTemplate response = transcoderServiceClient.getJobTemplate(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -893,41 +524,20 @@ public final JobTemplate getJobTemplate(GetJobTemplateRequest request) { return getJobTemplateCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the job template data. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   GetJobTemplateRequest request = GetJobTemplateRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<JobTemplate> future = transcoderServiceClient.getJobTemplateCallable().futureCall(request);
-   *   // Do something
-   *   JobTemplate response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getJobTemplateCallable() { return stub.getJobTemplateCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job template. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   transcoderServiceClient.deleteJobTemplate(name);
-   * }
-   * 
- * * @param name Required. The name of the job template to delete. * `projects/{project}/locations/{location}/jobTemplates/{job_template}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -940,19 +550,10 @@ public final void deleteJobTemplate(JobTemplateName name) { deleteJobTemplate(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job template. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   transcoderServiceClient.deleteJobTemplate(name.toString());
-   * }
-   * 
- * * @param name Required. The name of the job template to delete. * `projects/{project}/locations/{location}/jobTemplates/{job_template}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -962,22 +563,10 @@ public final void deleteJobTemplate(String name) { deleteJobTemplate(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job template. * - *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   DeleteJobTemplateRequest request = DeleteJobTemplateRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   transcoderServiceClient.deleteJobTemplate(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -985,23 +574,11 @@ public final void deleteJobTemplate(DeleteJobTemplateRequest request) { deleteJobTemplateCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a job template. * *

Sample code: - * - *


-   * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
-   *   JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]");
-   *   DeleteJobTemplateRequest request = DeleteJobTemplateRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = transcoderServiceClient.deleteJobTemplateCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ public final UnaryCallable deleteJobTemplateCallable() { return stub.deleteJobTemplateCallable(); diff --git a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceSettings.java b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceSettings.java index c350a924..ee12c358 100644 --- a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceSettings.java +++ b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceSettings.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1; import static com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient.ListJobTemplatesPagedResponse; @@ -35,7 +36,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link TranscoderServiceClient}. * @@ -52,23 +53,24 @@ * *

For example, to set the total timeout of createJob to 30 seconds: * - *

- * 
+ * 
{@code
  * TranscoderServiceSettings.Builder transcoderServiceSettingsBuilder =
  *     TranscoderServiceSettings.newBuilder();
  * transcoderServiceSettingsBuilder
  *     .createJobSettings()
  *     .setRetrySettings(
- *         transcoderServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder()
+ *         transcoderServiceSettingsBuilder
+ *             .createJobSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * TranscoderServiceSettings transcoderServiceSettings = transcoderServiceSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class TranscoderServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to createJob. */ public UnaryCallSettings createJobSettings() { return ((TranscoderServiceStubSettings) getStubSettings()).createJobSettings(); @@ -172,18 +174,15 @@ protected TranscoderServiceSettings(Builder settingsBuilder) throws IOException /** Builder for TranscoderServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(TranscoderServiceStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(TranscoderServiceStubSettings.newBuilder()); - } - protected Builder(TranscoderServiceSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -192,11 +191,15 @@ protected Builder(TranscoderServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(TranscoderServiceStubSettings.newBuilder()); + } + public TranscoderServiceStubSettings.Builder getStubSettingsBuilder() { return ((TranscoderServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/package-info.java b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/package-info.java index eeb9c4bc..83080c28 100644 --- a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/package-info.java +++ b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/package-info.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,9 +15,7 @@ */ /** - * A client to Transcoder API. - * - *

The interfaces provided are listed below, along with usage samples. + * The interfaces provided are listed below, along with usage samples. * *

======================= TranscoderServiceClient ======================= * @@ -28,18 +26,8 @@ * equalization, content concatenation, and digital ad-stitch ready content generation. * *

Sample for TranscoderServiceClient: - * - *

- * 
- * try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
- *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
- *   Job job = Job.newBuilder().build();
- *   Job response = transcoderServiceClient.createJob(parent, job);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.video.transcoder.v1beta1; import javax.annotation.Generated; diff --git a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceCallableFactory.java b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceCallableFactory.java index 83d1c4cc..990959f4 100644 --- a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceCallableFactory.java +++ b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceCallableFactory.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,18 +31,19 @@ import com.google.api.gax.rpc.StreamingCallSettings; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Transcoder API. + * gRPC callable factory implementation for the TranscoderService service API. * *

This class is for advanced usage. */ @Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public class GrpcTranscoderServiceCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceStub.java b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceStub.java index d14baf28..e73175cd 100644 --- a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceStub.java +++ b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/GrpcTranscoderServiceStub.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1.stub; import static com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient.ListJobTemplatesPagedResponse; import static com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient.ListJobsPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -39,6 +39,7 @@ import com.google.cloud.video.transcoder.v1beta1.ListJobsRequest; import com.google.cloud.video.transcoder.v1beta1.ListJobsResponse; import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.protobuf.Empty; import io.grpc.MethodDescriptor; import io.grpc.protobuf.ProtoUtils; @@ -47,16 +48,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Transcoder API. + * gRPC stub implementation for the TranscoderService service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public class GrpcTranscoderServiceStub extends TranscoderServiceStub { - private static final MethodDescriptor createJobMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -64,6 +63,7 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(CreateJobRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Job.getDefaultInstance())) .build(); + private static final MethodDescriptor listJobsMethodDescriptor = MethodDescriptor.newBuilder() @@ -72,6 +72,7 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(ListJobsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(ListJobsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getJobMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -79,6 +80,7 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(GetJobRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Job.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteJobMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -86,6 +88,7 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(DeleteJobRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor createJobTemplateMethodDescriptor = MethodDescriptor.newBuilder() @@ -96,6 +99,7 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { ProtoUtils.marshaller(CreateJobTemplateRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(JobTemplate.getDefaultInstance())) .build(); + private static final MethodDescriptor listJobTemplatesMethodDescriptor = MethodDescriptor.newBuilder() @@ -107,6 +111,7 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(ListJobTemplatesResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getJobTemplateMethodDescriptor = MethodDescriptor.newBuilder() @@ -117,6 +122,7 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { ProtoUtils.marshaller(GetJobTemplateRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(JobTemplate.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteJobTemplateMethodDescriptor = MethodDescriptor.newBuilder() @@ -128,8 +134,6 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable createJobCallable; private final UnaryCallable listJobsCallable; private final UnaryCallable listJobsPagedCallable; @@ -143,6 +147,8 @@ public class GrpcTranscoderServiceStub extends TranscoderServiceStub { private final UnaryCallable getJobTemplateCallable; private final UnaryCallable deleteJobTemplateCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcTranscoderServiceStub create(TranscoderServiceStubSettings settings) @@ -183,6 +189,7 @@ protected GrpcTranscoderServiceStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings createJobTransportSettings = GrpcCallSettings.newBuilder() @@ -325,21 +332,26 @@ public Map extract(DeleteJobTemplateRequest request) { settings.deleteJobTemplateSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - public UnaryCallable createJobCallable() { - return createJobCallable; + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } - public UnaryCallable listJobsPagedCallable() { - return listJobsPagedCallable; + public UnaryCallable createJobCallable() { + return createJobCallable; } public UnaryCallable listJobsCallable() { return listJobsCallable; } + public UnaryCallable listJobsPagedCallable() { + return listJobsPagedCallable; + } + public UnaryCallable getJobCallable() { return getJobCallable; } @@ -352,16 +364,16 @@ public UnaryCallable createJobTemplateCal return createJobTemplateCallable; } - public UnaryCallable - listJobTemplatesPagedCallable() { - return listJobTemplatesPagedCallable; - } - public UnaryCallable listJobTemplatesCallable() { return listJobTemplatesCallable; } + public UnaryCallable + listJobTemplatesPagedCallable() { + return listJobTemplatesPagedCallable; + } + public UnaryCallable getJobTemplateCallable() { return getJobTemplateCallable; } diff --git a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStub.java b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStub.java index 3b789a8d..f9e985a3 100644 --- a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStub.java +++ b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStub.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1.stub; import static com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient.ListJobTemplatesPagedResponse; import static com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient.ListJobsPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.video.transcoder.v1beta1.CreateJobRequest; @@ -36,14 +36,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Transcoder API. + * Base stub class for the TranscoderService service API. * *

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public abstract class TranscoderServiceStub implements BackgroundResource { public UnaryCallable createJobCallable() { diff --git a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStubSettings.java b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStubSettings.java index 49996f79..59e5b5ad 100644 --- a/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStubSettings.java +++ b/google-cloud-video-transcoder/src/main/java/com/google/cloud/video/transcoder/v1beta1/stub/TranscoderServiceStubSettings.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1.stub; import static com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient.ListJobTemplatesPagedResponse; @@ -62,7 +63,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link TranscoderServiceStub}. * @@ -79,22 +80,24 @@ * *

For example, to set the total timeout of createJob to 30 seconds: * - *

- * 
+ * 
{@code
  * TranscoderServiceStubSettings.Builder transcoderServiceSettingsBuilder =
  *     TranscoderServiceStubSettings.newBuilder();
  * transcoderServiceSettingsBuilder
  *     .createJobSettings()
  *     .setRetrySettings(
- *         transcoderServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder()
+ *         transcoderServiceSettingsBuilder
+ *             .createJobSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * TranscoderServiceStubSettings transcoderServiceSettings = transcoderServiceSettingsBuilder.build();
- * 
- * 
+ * TranscoderServiceStubSettings transcoderServiceSettings = + * transcoderServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator-java") public class TranscoderServiceStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -112,6 +115,117 @@ public class TranscoderServiceStubSettings extends StubSettings getJobTemplateSettings; private final UnaryCallSettings deleteJobTemplateSettings; + private static final PagedListDescriptor + LIST_JOBS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListJobsRequest injectToken(ListJobsRequest payload, String token) { + return ListJobsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListJobsRequest injectPageSize(ListJobsRequest payload, int pageSize) { + return ListJobsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListJobsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListJobsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListJobsResponse payload) { + return payload.getJobsList() == null + ? ImmutableList.of() + : payload.getJobsList(); + } + }; + + private static final PagedListDescriptor< + ListJobTemplatesRequest, ListJobTemplatesResponse, JobTemplate> + LIST_JOB_TEMPLATES_PAGE_STR_DESC = + new PagedListDescriptor< + ListJobTemplatesRequest, ListJobTemplatesResponse, JobTemplate>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListJobTemplatesRequest injectToken( + ListJobTemplatesRequest payload, String token) { + return ListJobTemplatesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListJobTemplatesRequest injectPageSize( + ListJobTemplatesRequest payload, int pageSize) { + return ListJobTemplatesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListJobTemplatesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListJobTemplatesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListJobTemplatesResponse payload) { + return payload.getJobTemplatesList() == null + ? ImmutableList.of() + : payload.getJobTemplatesList(); + } + }; + + private static final PagedListResponseFactory< + ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> + LIST_JOBS_PAGE_STR_FACT = + new PagedListResponseFactory() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListJobsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_JOBS_PAGE_STR_DESC, request, context); + return ListJobsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListJobTemplatesRequest, ListJobTemplatesResponse, ListJobTemplatesPagedResponse> + LIST_JOB_TEMPLATES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListJobTemplatesRequest, ListJobTemplatesResponse, ListJobTemplatesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListJobTemplatesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext + pageContext = + PageContext.create( + callable, LIST_JOB_TEMPLATES_PAGE_STR_DESC, request, context); + return ListJobTemplatesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + /** Returns the object with the settings used for calls to createJob. */ public UnaryCallSettings createJobSettings() { return createJobSettings; @@ -161,10 +275,10 @@ public TranscoderServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcTranscoderServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -234,121 +348,9 @@ protected TranscoderServiceStubSettings(Builder settingsBuilder) throws IOExcept deleteJobTemplateSettings = settingsBuilder.deleteJobTemplateSettings().build(); } - private static final PagedListDescriptor - LIST_JOBS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListJobsRequest injectToken(ListJobsRequest payload, String token) { - return ListJobsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListJobsRequest injectPageSize(ListJobsRequest payload, int pageSize) { - return ListJobsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListJobsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListJobsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListJobsResponse payload) { - return payload.getJobsList() != null - ? payload.getJobsList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListJobTemplatesRequest, ListJobTemplatesResponse, JobTemplate> - LIST_JOB_TEMPLATES_PAGE_STR_DESC = - new PagedListDescriptor< - ListJobTemplatesRequest, ListJobTemplatesResponse, JobTemplate>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListJobTemplatesRequest injectToken( - ListJobTemplatesRequest payload, String token) { - return ListJobTemplatesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListJobTemplatesRequest injectPageSize( - ListJobTemplatesRequest payload, int pageSize) { - return ListJobTemplatesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListJobTemplatesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListJobTemplatesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListJobTemplatesResponse payload) { - return payload.getJobTemplatesList() != null - ? payload.getJobTemplatesList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> - LIST_JOBS_PAGE_STR_FACT = - new PagedListResponseFactory() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListJobsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_JOBS_PAGE_STR_DESC, request, context); - return ListJobsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListJobTemplatesRequest, ListJobTemplatesResponse, ListJobTemplatesPagedResponse> - LIST_JOB_TEMPLATES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListJobTemplatesRequest, ListJobTemplatesResponse, ListJobTemplatesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListJobTemplatesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext - pageContext = - PageContext.create( - callable, LIST_JOB_TEMPLATES_PAGE_STR_DESC, request, context); - return ListJobTemplatesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - /** Builder for TranscoderServiceStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final UnaryCallSettings.Builder createJobSettings; private final PagedCallSettings.Builder< ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> @@ -364,14 +366,12 @@ public static class Builder extends StubSettings.Builder deleteJobTemplateSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put( "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); @@ -382,8 +382,6 @@ public static class Builder extends StubSettings.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); settings = RetrySettings.newBuilder() .setInitialRpcTimeout(Duration.ofMillis(60000L)) @@ -396,26 +394,19 @@ public static class Builder extends StubSettings.Builder>of( + createJobSettings, + listJobsSettings, + getJobSettings, + deleteJobSettings, + createJobTemplateSettings, + listJobTemplatesSettings, + getJobTemplateSettings, + deleteJobTemplateSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); } private static Builder initDefaults(Builder builder) { - builder .createJobSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) @@ -486,31 +501,7 @@ private static Builder initDefaults(Builder builder) { return builder; } - protected Builder(TranscoderServiceStubSettings settings) { - super(settings); - - createJobSettings = settings.createJobSettings.toBuilder(); - listJobsSettings = settings.listJobsSettings.toBuilder(); - getJobSettings = settings.getJobSettings.toBuilder(); - deleteJobSettings = settings.deleteJobSettings.toBuilder(); - createJobTemplateSettings = settings.createJobTemplateSettings.toBuilder(); - listJobTemplatesSettings = settings.listJobTemplatesSettings.toBuilder(); - getJobTemplateSettings = settings.getJobTemplateSettings.toBuilder(); - deleteJobTemplateSettings = settings.deleteJobTemplateSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - createJobSettings, - listJobsSettings, - getJobSettings, - deleteJobSettings, - createJobTemplateSettings, - listJobTemplatesSettings, - getJobTemplateSettings, - deleteJobTemplateSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderService.java b/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderService.java index 9e6b04fc..498f52eb 100644 --- a/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderService.java +++ b/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderService.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1; import com.google.api.core.BetaApi; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockTranscoderService implements MockGrpcService { private final MockTranscoderServiceImpl serviceImpl; diff --git a/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderServiceImpl.java b/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderServiceImpl.java index ccc37e68..b8883801 100644 --- a/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderServiceImpl.java +++ b/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/MockTranscoderServiceImpl.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1; import com.google.api.core.BetaApi; @@ -24,9 +25,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockTranscoderServiceImpl extends TranscoderServiceImplBase { private List requests; private Queue responses; @@ -62,10 +64,10 @@ public void createJob(CreateJobRequest request, StreamObserver responseObse Object response = responses.remove(); if (response instanceof Job) { requests.add(request); - responseObserver.onNext((Job) response); + responseObserver.onNext(((Job) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -76,10 +78,10 @@ public void listJobs(ListJobsRequest request, StreamObserver r Object response = responses.remove(); if (response instanceof ListJobsResponse) { requests.add(request); - responseObserver.onNext((ListJobsResponse) response); + responseObserver.onNext(((ListJobsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -90,10 +92,10 @@ public void getJob(GetJobRequest request, StreamObserver responseObserver) Object response = responses.remove(); if (response instanceof Job) { requests.add(request); - responseObserver.onNext((Job) response); + responseObserver.onNext(((Job) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -104,10 +106,10 @@ public void deleteJob(DeleteJobRequest request, StreamObserver responseOb Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -119,10 +121,10 @@ public void createJobTemplate( Object response = responses.remove(); if (response instanceof JobTemplate) { requests.add(request); - responseObserver.onNext((JobTemplate) response); + responseObserver.onNext(((JobTemplate) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -134,10 +136,10 @@ public void listJobTemplates( Object response = responses.remove(); if (response instanceof ListJobTemplatesResponse) { requests.add(request); - responseObserver.onNext((ListJobTemplatesResponse) response); + responseObserver.onNext(((ListJobTemplatesResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -149,10 +151,10 @@ public void getJobTemplate( Object response = responses.remove(); if (response instanceof JobTemplate) { requests.add(request); - responseObserver.onNext((JobTemplate) response); + responseObserver.onNext(((JobTemplate) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -164,10 +166,10 @@ public void deleteJobTemplate( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClientTest.java b/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClientTest.java index b7970fbd..d14e9c4b 100644 --- a/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClientTest.java +++ b/google-cloud-video-transcoder/src/test/java/com/google/cloud/video/transcoder/v1beta1/TranscoderServiceClientTest.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.video.transcoder.v1beta1; import static com.google.cloud.video.transcoder.v1beta1.TranscoderServiceClient.ListJobTemplatesPagedResponse; @@ -28,12 +29,14 @@ import com.google.common.collect.Lists; import com.google.protobuf.AbstractMessage; import com.google.protobuf.Empty; -import io.grpc.Status; +import com.google.protobuf.Timestamp; import io.grpc.StatusRuntimeException; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -41,31 +44,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class TranscoderServiceClientTest { + private static MockServiceHelper mockServiceHelper; private static MockTranscoderService mockTranscoderService; - private static MockServiceHelper serviceHelper; private TranscoderServiceClient client; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockTranscoderService = new MockTranscoderService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockTranscoderService)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); TranscoderServiceSettings settings = TranscoderServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -80,22 +83,19 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void createJobTest() { - JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - String inputUri = "inputUri1707300727"; - String outputUri = "outputUri-1273518802"; - String templateId = "templateId1769642752"; - int priority = 1165461084; - String failureReason = "failureReason1743941273"; + public void createJobTest() throws Exception { Job expectedResponse = Job.newBuilder() - .setName(name.toString()) - .setInputUri(inputUri) - .setOutputUri(outputUri) - .setTemplateId(templateId) - .setPriority(priority) - .setFailureReason(failureReason) + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setInputUri("inputUri470706498") + .setOutputUri("outputUri-2119300949") + .setPriority(-1165461084) + .setProgress(Progress.newBuilder().build()) + .setFailureReason("failureReason-1990598546") + .addAllFailureDetails(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) .build(); mockTranscoderService.addResponse(expectedResponse); @@ -107,9 +107,9 @@ public void createJobTest() { List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateJobRequest actualRequest = (CreateJobRequest) actualRequests.get(0); + CreateJobRequest actualRequest = ((CreateJobRequest) actualRequests.get(0)); - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertEquals(job, actualRequest.getJob()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -118,30 +118,78 @@ public void createJobTest() { } @Test - @SuppressWarnings("all") public void createJobExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Job job = Job.newBuilder().build(); + client.createJob(parent, job); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setInputUri("inputUri470706498") + .setOutputUri("outputUri-2119300949") + .setPriority(-1165461084) + .setProgress(Progress.newBuilder().build()) + .setFailureReason("failureReason-1990598546") + .addAllFailureDetails(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockTranscoderService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + Job job = Job.newBuilder().build(); + Job actualResponse = client.createJob(parent, job); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateJobRequest actualRequest = ((CreateJobRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(job, actualRequest.getJob()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createJobExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + + try { + String parent = "parent-995424086"; + Job job = Job.newBuilder().build(); client.createJob(parent, job); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listJobsTest() { - String nextPageToken = ""; - Job jobsElement = Job.newBuilder().build(); - List jobs = Arrays.asList(jobsElement); + public void listJobsTest() throws Exception { + Job responsesElement = Job.newBuilder().build(); ListJobsResponse expectedResponse = - ListJobsResponse.newBuilder().setNextPageToken(nextPageToken).addAllJobs(jobs).build(); + ListJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); mockTranscoderService.addResponse(expectedResponse); LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); @@ -149,14 +197,15 @@ public void listJobsTest() { ListJobsPagedResponse pagedListResponse = client.listJobs(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0)); List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListJobsRequest actualRequest = (ListJobsRequest) actualRequests.get(0); + ListJobsRequest actualRequest = ((ListJobsRequest) actualRequests.get(0)); - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -164,38 +213,77 @@ public void listJobsTest() { } @Test - @SuppressWarnings("all") public void listJobsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listJobsTest2() throws Exception { + Job responsesElement = Job.newBuilder().build(); + ListJobsResponse expectedResponse = + ListJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockTranscoderService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListJobsPagedResponse pagedListResponse = client.listJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0)); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListJobsRequest actualRequest = ((ListJobsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listJobsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + try { + String parent = "parent-995424086"; client.listJobs(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getJobTest() { - JobName name2 = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); - String inputUri = "inputUri1707300727"; - String outputUri = "outputUri-1273518802"; - String templateId = "templateId1769642752"; - int priority = 1165461084; - String failureReason = "failureReason1743941273"; + public void getJobTest() throws Exception { Job expectedResponse = Job.newBuilder() - .setName(name2.toString()) - .setInputUri(inputUri) - .setOutputUri(outputUri) - .setTemplateId(templateId) - .setPriority(priority) - .setFailureReason(failureReason) + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setInputUri("inputUri470706498") + .setOutputUri("outputUri-2119300949") + .setPriority(-1165461084) + .setProgress(Progress.newBuilder().build()) + .setFailureReason("failureReason-1990598546") + .addAllFailureDetails(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) .build(); mockTranscoderService.addResponse(expectedResponse); @@ -206,9 +294,9 @@ public void getJobTest() { List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetJobRequest actualRequest = (GetJobRequest) actualRequests.get(0); + GetJobRequest actualRequest = ((GetJobRequest) actualRequests.get(0)); - Assert.assertEquals(name, JobName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -216,24 +304,68 @@ public void getJobTest() { } @Test - @SuppressWarnings("all") public void getJobExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.getJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setInputUri("inputUri470706498") + .setOutputUri("outputUri-2119300949") + .setPriority(-1165461084) + .setProgress(Progress.newBuilder().build()) + .setFailureReason("failureReason-1990598546") + .addAllFailureDetails(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockTranscoderService.addResponse(expectedResponse); + + String name = "name3373707"; + Job actualResponse = client.getJob(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetJobRequest actualRequest = ((GetJobRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getJobExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + + try { + String name = "name3373707"; client.getJob(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteJobTest() { + public void deleteJobTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockTranscoderService.addResponse(expectedResponse); @@ -243,9 +375,9 @@ public void deleteJobTest() { List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteJobRequest actualRequest = (DeleteJobRequest) actualRequests.get(0); + DeleteJobRequest actualRequest = ((DeleteJobRequest) actualRequests.get(0)); - Assert.assertEquals(name, JobName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -253,40 +385,74 @@ public void deleteJobTest() { } @Test - @SuppressWarnings("all") public void deleteJobExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.deleteJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockTranscoderService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteJob(name); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteJobRequest actualRequest = ((DeleteJobRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteJobExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + try { + String name = "name3373707"; client.deleteJob(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createJobTemplateTest() { - JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]"); - JobTemplate expectedResponse = JobTemplate.newBuilder().setName(name.toString()).build(); + public void createJobTemplateTest() throws Exception { + JobTemplate expectedResponse = + JobTemplate.newBuilder() + .setName(JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]").toString()) + .setConfig(JobConfig.newBuilder().build()) + .build(); mockTranscoderService.addResponse(expectedResponse); LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); JobTemplate jobTemplate = JobTemplate.newBuilder().build(); - String jobTemplateId = "jobTemplateId-1231822466"; + String jobTemplateId = "jobTemplateId-597733678"; JobTemplate actualResponse = client.createJobTemplate(parent, jobTemplate, jobTemplateId); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateJobTemplateRequest actualRequest = (CreateJobTemplateRequest) actualRequests.get(0); + CreateJobTemplateRequest actualRequest = ((CreateJobTemplateRequest) actualRequests.get(0)); - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertEquals(jobTemplate, actualRequest.getJobTemplate()); Assert.assertEquals(jobTemplateId, actualRequest.getJobTemplateId()); Assert.assertTrue( @@ -296,33 +462,73 @@ public void createJobTemplateTest() { } @Test - @SuppressWarnings("all") public void createJobTemplateExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); JobTemplate jobTemplate = JobTemplate.newBuilder().build(); - String jobTemplateId = "jobTemplateId-1231822466"; + String jobTemplateId = "jobTemplateId-597733678"; + client.createJobTemplate(parent, jobTemplate, jobTemplateId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTemplateTest2() throws Exception { + JobTemplate expectedResponse = + JobTemplate.newBuilder() + .setName(JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]").toString()) + .setConfig(JobConfig.newBuilder().build()) + .build(); + mockTranscoderService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + JobTemplate jobTemplate = JobTemplate.newBuilder().build(); + String jobTemplateId = "jobTemplateId-597733678"; + + JobTemplate actualResponse = client.createJobTemplate(parent, jobTemplate, jobTemplateId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateJobTemplateRequest actualRequest = ((CreateJobTemplateRequest) actualRequests.get(0)); + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(jobTemplate, actualRequest.getJobTemplate()); + Assert.assertEquals(jobTemplateId, actualRequest.getJobTemplateId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createJobTemplateExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + + try { + String parent = "parent-995424086"; + JobTemplate jobTemplate = JobTemplate.newBuilder().build(); + String jobTemplateId = "jobTemplateId-597733678"; client.createJobTemplate(parent, jobTemplate, jobTemplateId); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listJobTemplatesTest() { - String nextPageToken = ""; - JobTemplate jobTemplatesElement = JobTemplate.newBuilder().build(); - List jobTemplates = Arrays.asList(jobTemplatesElement); + public void listJobTemplatesTest() throws Exception { + JobTemplate responsesElement = JobTemplate.newBuilder().build(); ListJobTemplatesResponse expectedResponse = ListJobTemplatesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllJobTemplates(jobTemplates) + .setNextPageToken("") + .addAllJobTemplates(Arrays.asList(responsesElement)) .build(); mockTranscoderService.addResponse(expectedResponse); @@ -331,14 +537,15 @@ public void listJobTemplatesTest() { ListJobTemplatesPagedResponse pagedListResponse = client.listJobTemplates(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getJobTemplatesList().get(0), resources.get(0)); List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListJobTemplatesRequest actualRequest = (ListJobTemplatesRequest) actualRequests.get(0); + ListJobTemplatesRequest actualRequest = ((ListJobTemplatesRequest) actualRequests.get(0)); - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -346,26 +553,70 @@ public void listJobTemplatesTest() { } @Test - @SuppressWarnings("all") public void listJobTemplatesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listJobTemplates(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listJobTemplatesTest2() throws Exception { + JobTemplate responsesElement = JobTemplate.newBuilder().build(); + ListJobTemplatesResponse expectedResponse = + ListJobTemplatesResponse.newBuilder() + .setNextPageToken("") + .addAllJobTemplates(Arrays.asList(responsesElement)) + .build(); + mockTranscoderService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListJobTemplatesPagedResponse pagedListResponse = client.listJobTemplates(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobTemplatesList().get(0), resources.get(0)); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListJobTemplatesRequest actualRequest = ((ListJobTemplatesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listJobTemplatesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + try { + String parent = "parent-995424086"; client.listJobTemplates(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getJobTemplateTest() { - JobTemplateName name2 = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]"); - JobTemplate expectedResponse = JobTemplate.newBuilder().setName(name2.toString()).build(); + public void getJobTemplateTest() throws Exception { + JobTemplate expectedResponse = + JobTemplate.newBuilder() + .setName(JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]").toString()) + .setConfig(JobConfig.newBuilder().build()) + .build(); mockTranscoderService.addResponse(expectedResponse); JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]"); @@ -375,9 +626,9 @@ public void getJobTemplateTest() { List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetJobTemplateRequest actualRequest = (GetJobTemplateRequest) actualRequests.get(0); + GetJobTemplateRequest actualRequest = ((GetJobTemplateRequest) actualRequests.get(0)); - Assert.assertEquals(name, JobTemplateName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -385,24 +636,60 @@ public void getJobTemplateTest() { } @Test - @SuppressWarnings("all") public void getJobTemplateExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]"); + client.getJobTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTemplateTest2() throws Exception { + JobTemplate expectedResponse = + JobTemplate.newBuilder() + .setName(JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]").toString()) + .setConfig(JobConfig.newBuilder().build()) + .build(); + mockTranscoderService.addResponse(expectedResponse); + + String name = "name3373707"; + + JobTemplate actualResponse = client.getJobTemplate(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetJobTemplateRequest actualRequest = ((GetJobTemplateRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void getJobTemplateExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + + try { + String name = "name3373707"; client.getJobTemplate(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteJobTemplateTest() { + public void deleteJobTemplateTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockTranscoderService.addResponse(expectedResponse); @@ -412,9 +699,9 @@ public void deleteJobTemplateTest() { List actualRequests = mockTranscoderService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteJobTemplateRequest actualRequest = (DeleteJobTemplateRequest) actualRequests.get(0); + DeleteJobTemplateRequest actualRequest = ((DeleteJobTemplateRequest) actualRequests.get(0)); - Assert.assertEquals(name, JobTemplateName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -422,18 +709,50 @@ public void deleteJobTemplateTest() { } @Test - @SuppressWarnings("all") public void deleteJobTemplateExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockTranscoderService.addException(exception); try { JobTemplateName name = JobTemplateName.of("[PROJECT]", "[LOCATION]", "[JOB_TEMPLATE]"); + client.deleteJobTemplate(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void deleteJobTemplateTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockTranscoderService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteJobTemplate(name); + + List actualRequests = mockTranscoderService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteJobTemplateRequest actualRequest = ((DeleteJobTemplateRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteJobTemplateExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockTranscoderService.addException(exception); + + try { + String name = "name3373707"; client.deleteJobTemplate(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobName.java b/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobName.java index 2d6a3fe0..046445f6 100644 --- a/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobName.java +++ b/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobName.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -23,20 +23,32 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class JobName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION_JOB = PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}/jobs/{job}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; private final String job; + @Deprecated + protected JobName() { + project = null; + location = null; + job = null; + } + + private JobName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + job = Preconditions.checkNotNull(builder.getJob()); + } + public String getProject() { return project; } @@ -57,12 +69,6 @@ public Builder toBuilder() { return new Builder(this); } - private JobName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - job = Preconditions.checkNotNull(builder.getJob()); - } - public static JobName of(String project, String location, String job) { return newBuilder().setProject(project).setLocation(location).setJob(job).build(); } @@ -76,7 +82,7 @@ public static JobName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION_JOB.validatedMatch( formattedString, "JobName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("job")); } @@ -90,7 +96,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (JobName value : values) { if (value == null) { list.add(""); @@ -102,17 +108,24 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION_JOB.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); - fieldMapBuilder.put("job", job); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (job != null) { + fieldMapBuilder.put("job", job); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -126,16 +139,43 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project, "location", location, "job", job); + return PROJECT_LOCATION_JOB.instantiate("project", project, "location", location, "job", job); } - /** Builder for JobName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + JobName that = ((JobName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.job, that.job); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(job); + return h; + } + + /** Builder for projects/{project}/locations/{location}/jobs/{job}. */ + public static class Builder { private String project; private String location; private String job; + protected Builder() {} + public String getProject() { return project; } @@ -163,8 +203,6 @@ public Builder setJob(String job) { return this; } - private Builder() {} - private Builder(JobName jobName) { project = jobName.project; location = jobName.location; @@ -175,30 +213,4 @@ public JobName build() { return new JobName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof JobName) { - JobName that = (JobName) o; - return (this.project.equals(that.project)) - && (this.location.equals(that.location)) - && (this.job.equals(that.job)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - h *= 1000003; - h ^= job.hashCode(); - return h; - } } diff --git a/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobTemplateName.java b/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobTemplateName.java index 0e5486e1..b6487735 100644 --- a/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobTemplateName.java +++ b/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/JobTemplateName.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -23,21 +23,33 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class JobTemplateName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION_JOB_TEMPLATE = PathTemplate.createWithoutUrlEncoding( "projects/{project}/locations/{location}/jobTemplates/{job_template}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; private final String jobTemplate; + @Deprecated + protected JobTemplateName() { + project = null; + location = null; + jobTemplate = null; + } + + private JobTemplateName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + jobTemplate = Preconditions.checkNotNull(builder.getJobTemplate()); + } + public String getProject() { return project; } @@ -58,12 +70,6 @@ public Builder toBuilder() { return new Builder(this); } - private JobTemplateName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - jobTemplate = Preconditions.checkNotNull(builder.getJobTemplate()); - } - public static JobTemplateName of(String project, String location, String jobTemplate) { return newBuilder() .setProject(project) @@ -86,7 +92,7 @@ public static JobTemplateName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION_JOB_TEMPLATE.validatedMatch( formattedString, "JobTemplateName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("job_template")); } @@ -100,7 +106,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (JobTemplateName value : values) { if (value == null) { list.add(""); @@ -112,17 +118,24 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION_JOB_TEMPLATE.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); - fieldMapBuilder.put("jobTemplate", jobTemplate); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (jobTemplate != null) { + fieldMapBuilder.put("job_template", jobTemplate); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -136,17 +149,44 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_LOCATION_JOB_TEMPLATE.instantiate( "project", project, "location", location, "job_template", jobTemplate); } - /** Builder for JobTemplateName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + JobTemplateName that = ((JobTemplateName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.jobTemplate, that.jobTemplate); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(jobTemplate); + return h; + } + + /** Builder for projects/{project}/locations/{location}/jobTemplates/{job_template}. */ + public static class Builder { private String project; private String location; private String jobTemplate; + protected Builder() {} + public String getProject() { return project; } @@ -174,8 +214,6 @@ public Builder setJobTemplate(String jobTemplate) { return this; } - private Builder() {} - private Builder(JobTemplateName jobTemplateName) { project = jobTemplateName.project; location = jobTemplateName.location; @@ -186,30 +224,4 @@ public JobTemplateName build() { return new JobTemplateName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof JobTemplateName) { - JobTemplateName that = (JobTemplateName) o; - return (this.project.equals(that.project)) - && (this.location.equals(that.location)) - && (this.jobTemplate.equals(that.jobTemplate)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - h *= 1000003; - h ^= jobTemplate.hashCode(); - return h; - } } diff --git a/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/LocationName.java b/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/LocationName.java index 9f60214e..c7706e59 100644 --- a/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/LocationName.java +++ b/proto-google-cloud-video-transcoder-v1beta1/src/main/java/com/google/cloud/video/transcoder/v1beta1/LocationName.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -23,19 +23,29 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class LocationName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION = PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; + @Deprecated + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + public String getProject() { return project; } @@ -52,11 +62,6 @@ public Builder toBuilder() { return new Builder(this); } - private LocationName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - } - public static LocationName of(String project, String location) { return newBuilder().setProject(project).setLocation(location).build(); } @@ -70,7 +75,7 @@ public static LocationName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION.validatedMatch( formattedString, "LocationName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location")); } @@ -84,7 +89,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (LocationName value : values) { if (value == null) { list.add(""); @@ -96,16 +101,21 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -119,15 +129,39 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project, "location", location); + return PROJECT_LOCATION.instantiate("project", project, "location", location); } - /** Builder for LocationName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { private String project; private String location; + protected Builder() {} + public String getProject() { return project; } @@ -146,8 +180,6 @@ public Builder setLocation(String location) { return this; } - private Builder() {} - private Builder(LocationName locationName) { project = locationName.project; location = locationName.location; @@ -157,26 +189,4 @@ public LocationName build() { return new LocationName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof LocationName) { - LocationName that = (LocationName) o; - return (this.project.equals(that.project)) && (this.location.equals(that.location)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - return h; - } } diff --git a/synth.metadata b/synth.metadata index a40c28bc..45a83292 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-video-transcoder.git", - "sha": "cdda44135282dbe29685bc735992906e4a484bf4" + "sha": "b94e01a681e1e5583791702ab58e3cf9b5bd2aa2" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "054339f961e16b2a359b0efc35a927b5f899c90f", - "internalRef": "334639492" + "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", + "internalRef": "346372957" } }, {