From a6309e805fd702ada04adf0e6f99d7531e822bdc Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Wed, 24 Apr 2024 15:45:00 -0400 Subject: [PATCH 1/6] feat: add comment to service client to disclose api version. --- .../composer/comment/ServiceClientCommentComposer.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java index 47d819378f..d72df38efd 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java @@ -40,6 +40,8 @@ public class ServiceClientCommentComposer { private static final String EXCEPTION_CONDITION = "if the remote call fails"; // Constants. + private static final String SERVICE_API_VERSION_STRING = + "This service client implements API version: %s."; private static final String SERVICE_DESCRIPTION_INTRO_STRING = "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:"; @@ -114,6 +116,11 @@ public static List createClassHeaderComments( classHeaderJavadocBuilder = classHeaderJavadocBuilder.addUnescapedComment(descriptionComment); } + if (service.hasApiVersion()) { + classHeaderJavadocBuilder.addParagraph( + String.format(SERVICE_API_VERSION_STRING, service.apiVersion())); + } + // Service introduction. classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_INTRO_STRING); classHeaderJavadocBuilder.addSampleCode(classMethodSampleCode); From 48fd04ed9d18fecfc43845997c3fcd471b009260 Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Wed, 24 Apr 2024 16:41:02 -0400 Subject: [PATCH 2/6] test: update showcase golden files. --- .../src/main/java/com/google/showcase/v1beta1/EchoClient.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/EchoClient.java b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/EchoClient.java index 5cd400c2aa..aa048a8c7d 100644 --- a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/EchoClient.java +++ b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/EchoClient.java @@ -59,6 +59,8 @@ * 'x-goog-request-params' metadata key on any method to have the values echoed in the response * headers. * + *

This service client implements API version: v1_20240408. + * *

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: * From c327c1cae58f9a78f8dbe9494ef83e1272b73031 Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Wed, 24 Apr 2024 17:04:01 -0400 Subject: [PATCH 3/6] test: add golden test for change with api_version_testing.proto. --- .../gapic/composer/grpc/ServiceClientClassComposerTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java index 151ccb578d..4bd9406481 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java @@ -60,6 +60,12 @@ public static Collection data() { "localhost:7469", "v1beta1" }, + { + "ApiVersionClient", + GrpcTestProtoLoader.instance().parseApiVersionTesting(), + "localhost:7469", + "v1" + }, }); } From 3ff49a6e92ee78a7fd9d090f6faefb37d7e7fab7 Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Mon, 6 May 2024 05:33:55 +0000 Subject: [PATCH 4/6] update golden to reflect changes. --- .../grpc/goldens/ApiVersionClient.golden | 443 ++++++++++++++++++ .../AsyncEchoWithVersionMethod.golden | 55 +++ .../SyncCreateSetCredentialsProvider.golden | 45 ++ .../SyncCreateSetEndpoint.golden | 42 ++ .../SyncEchoWithVersionMethod.golden | 51 ++ ...SyncEchoWithVersionMethodFoobarname.golden | 42 ++ .../SyncEchoWithVersionMethodNoargs.golden | 40 ++ ...ncEchoWithVersionMethodResourcename.golden | 43 ++ .../SyncEchoWithVersionMethodStatus.golden | 42 ++ .../SyncEchoWithVersionMethodString.golden | 41 ++ .../SyncEchoWithVersionMethodString1.golden | 42 ++ .../SyncEchoWithVersionMethodString2.golden | 42 ++ ...EchoWithVersionMethodStringSeverity.golden | 43 ++ 13 files changed, 971 insertions(+) create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionClient.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/AsyncEchoWithVersionMethod.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetCredentialsProvider.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetEndpoint.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethod.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodFoobarname.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodNoargs.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodResourcename.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStatus.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString1.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString2.golden create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStringSeverity.golden diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionClient.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionClient.golden new file mode 100644 index 0000000000..628285d4b1 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionClient.golden @@ -0,0 +1,443 @@ +package com.google.api.version.test; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.resourcenames.ResourceName; +import com.google.api.version.test.stub.EchoWithVersionStub; +import com.google.api.version.test.stub.EchoWithVersionStubSettings; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * This service client implements API version: fake_version. + * + *

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: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+ *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod();
+ * }
+ * }
+ * + *

Note: close() needs to be called on the EchoWithVersionClient object to clean up resources + * such as threads. In the example above, try-with-resources is used, which automatically calls + * close(). + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Methods
MethodDescriptionMethod Variants

EchoWithVersionMethod

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • echoWithVersionMethod(EchoRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • echoWithVersionMethod() + *

  • echoWithVersionMethod(ResourceName parent) + *

  • echoWithVersionMethod(FoobarName name) + *

  • echoWithVersionMethod(Status error) + *

  • echoWithVersionMethod(String content) + *

  • echoWithVersionMethod(String name) + *

  • echoWithVersionMethod(String parent) + *

  • echoWithVersionMethod(String content, Severity severity) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • echoWithVersionMethodCallable() + *

+ *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of EchoWithVersionSettings to + * create(). For example: + * + *

To customize credentials: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * EchoWithVersionSettings echoWithVersionSettings =
+ *     EchoWithVersionSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * EchoWithVersionClient echoWithVersionClient =
+ *     EchoWithVersionClient.create(echoWithVersionSettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * EchoWithVersionSettings echoWithVersionSettings =
+ *     EchoWithVersionSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * EchoWithVersionClient echoWithVersionClient =
+ *     EchoWithVersionClient.create(echoWithVersionSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class EchoWithVersionClient implements BackgroundResource { + private final EchoWithVersionSettings settings; + private final EchoWithVersionStub stub; + + /** Constructs an instance of EchoWithVersionClient with default settings. */ + public static final EchoWithVersionClient create() throws IOException { + return create(EchoWithVersionSettings.newBuilder().build()); + } + + /** + * Constructs an instance of EchoWithVersionClient, using the given settings. The channels are + * created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final EchoWithVersionClient create(EchoWithVersionSettings settings) + throws IOException { + return new EchoWithVersionClient(settings); + } + + /** + * Constructs an instance of EchoWithVersionClient, using the given stub for making calls. This is + * for advanced usage - prefer using create(EchoWithVersionSettings). + */ + public static final EchoWithVersionClient create(EchoWithVersionStub stub) { + return new EchoWithVersionClient(stub); + } + + /** + * Constructs an instance of EchoWithVersionClient, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected EchoWithVersionClient(EchoWithVersionSettings settings) throws IOException { + this.settings = settings; + this.stub = ((EchoWithVersionStubSettings) settings.getStubSettings()).createStub(); + } + + protected EchoWithVersionClient(EchoWithVersionStub stub) { + this.settings = null; + this.stub = stub; + } + + public final EchoWithVersionSettings getSettings() { + return settings; + } + + public EchoWithVersionStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod();
+   * }
+   * }
+ * + * @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 + */ + public final EchoResponse echoWithVersionMethod() { + EchoRequest request = EchoRequest.newBuilder().build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   ResourceName parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(parent);
+   * }
+   * }
+ * + * @param parent + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(ResourceName parent) { + EchoRequest request = + EchoRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   FoobarName name = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(name);
+   * }
+   * }
+ * + * @param name + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(FoobarName name) { + EchoRequest request = + EchoRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   Status error = Status.newBuilder().build();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(error);
+   * }
+   * }
+ * + * @param error + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(Status error) { + EchoRequest request = EchoRequest.newBuilder().setError(error).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String content = "content951530617";
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(content);
+   * }
+   * }
+ * + * @param content + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String content) { + EchoRequest request = EchoRequest.newBuilder().setContent(content).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String name = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(name);
+   * }
+   * }
+ * + * @param name + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String name) { + EchoRequest request = EchoRequest.newBuilder().setName(name).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(parent);
+   * }
+   * }
+ * + * @param parent + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String parent) { + EchoRequest request = EchoRequest.newBuilder().setParent(parent).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String content = "content951530617";
+   *   Severity severity = Severity.forNumber(0);
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(content, severity);
+   * }
+   * }
+ * + * @param content + * @param severity + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String content, Severity severity) { + EchoRequest request = + EchoRequest.newBuilder().setContent(content).setSeverity(severity).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   EchoRequest request =
+   *       EchoRequest.newBuilder()
+   *           .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setSeverity(Severity.forNumber(0))
+   *           .setFoobar(Foobar.newBuilder().build())
+   *           .build();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(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 + */ + public final EchoResponse echoWithVersionMethod(EchoRequest request) { + return echoWithVersionMethodCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   EchoRequest request =
+   *       EchoRequest.newBuilder()
+   *           .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setSeverity(Severity.forNumber(0))
+   *           .setFoobar(Foobar.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       echoWithVersionClient.echoWithVersionMethodCallable().futureCall(request);
+   *   // Do something.
+   *   EchoResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable echoWithVersionMethodCallable() { + return stub.echoWithVersionMethodCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } +} diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/AsyncEchoWithVersionMethod.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/AsyncEchoWithVersionMethod.golden new file mode 100644 index 0000000000..6cd8e67be6 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/AsyncEchoWithVersionMethod.golden @@ -0,0 +1,55 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_async] +import com.google.api.core.ApiFuture; +import com.google.api.version.test.EchoRequest; +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.Foobar; +import com.google.api.version.test.FoobarName; +import com.google.api.version.test.Severity; + +public class AsyncEchoWithVersionMethod { + + public static void main(String[] args) throws Exception { + asyncEchoWithVersionMethod(); + } + + public static void asyncEchoWithVersionMethod() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + EchoRequest request = + EchoRequest.newBuilder() + .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString()) + .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString()) + .setSeverity(Severity.forNumber(0)) + .setFoobar(Foobar.newBuilder().build()) + .build(); + ApiFuture future = + echoWithVersionClient.echoWithVersionMethodCallable().futureCall(request); + // Do something. + EchoResponse response = future.get(); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_async] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetCredentialsProvider.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetCredentialsProvider.golden new file mode 100644 index 0000000000..900e4d59d3 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetCredentialsProvider.golden @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.EchoWithVersionSettings; +import com.google.api.version.test.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + EchoWithVersionSettings echoWithVersionSettings = + EchoWithVersionSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + EchoWithVersionClient echoWithVersionClient = + EchoWithVersionClient.create(echoWithVersionSettings); + } +} +// [END goldensample_generated_EchoWithVersion_Create_SetCredentialsProvider_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetEndpoint.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetEndpoint.golden new file mode 100644 index 0000000000..4b44cb1941 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncCreateSetEndpoint.golden @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_Create_SetEndpoint_sync] +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.EchoWithVersionSettings; +import com.google.api.version.test.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + EchoWithVersionSettings echoWithVersionSettings = + EchoWithVersionSettings.newBuilder().setEndpoint(myEndpoint).build(); + EchoWithVersionClient echoWithVersionClient = + EchoWithVersionClient.create(echoWithVersionSettings); + } +} +// [END goldensample_generated_EchoWithVersion_Create_SetEndpoint_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethod.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethod.golden new file mode 100644 index 0000000000..b9d298ad6b --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethod.golden @@ -0,0 +1,51 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_sync] +import com.google.api.version.test.EchoRequest; +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.Foobar; +import com.google.api.version.test.FoobarName; +import com.google.api.version.test.Severity; + +public class SyncEchoWithVersionMethod { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethod(); + } + + public static void syncEchoWithVersionMethod() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + EchoRequest request = + EchoRequest.newBuilder() + .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString()) + .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString()) + .setSeverity(Severity.forNumber(0)) + .setFoobar(Foobar.newBuilder().build()) + .build(); + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(request); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodFoobarname.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodFoobarname.golden new file mode 100644 index 0000000000..2f6b46b95f --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodFoobarname.golden @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Foobarname_sync] +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.FoobarName; + +public class SyncEchoWithVersionMethodFoobarname { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodFoobarname(); + } + + public static void syncEchoWithVersionMethodFoobarname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + FoobarName name = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]"); + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(name); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Foobarname_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodNoargs.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodNoargs.golden new file mode 100644 index 0000000000..b1a6ab80cf --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodNoargs.golden @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Noargs_sync] +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; + +public class SyncEchoWithVersionMethodNoargs { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodNoargs(); + } + + public static void syncEchoWithVersionMethodNoargs() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Noargs_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodResourcename.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodResourcename.golden new file mode 100644 index 0000000000..3a6edff05d --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodResourcename.golden @@ -0,0 +1,43 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.FoobarName; + +public class SyncEchoWithVersionMethodResourcename { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodResourcename(); + } + + public static void syncEchoWithVersionMethodResourcename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + ResourceName parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]"); + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(parent); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Resourcename_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStatus.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStatus.golden new file mode 100644 index 0000000000..baeb25af89 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStatus.golden @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Status_sync] +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.rpc.Status; + +public class SyncEchoWithVersionMethodStatus { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodStatus(); + } + + public static void syncEchoWithVersionMethodStatus() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + Status error = Status.newBuilder().build(); + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(error); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_Status_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString.golden new file mode 100644 index 0000000000..6406ecf5cc --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString.golden @@ -0,0 +1,41 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_String_sync] +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; + +public class SyncEchoWithVersionMethodString { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodString(); + } + + public static void syncEchoWithVersionMethodString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + String content = "content951530617"; + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(content); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_String_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString1.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString1.golden new file mode 100644 index 0000000000..639968cd8b --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString1.golden @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_String1_sync] +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.FoobarName; + +public class SyncEchoWithVersionMethodString1 { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodString1(); + } + + public static void syncEchoWithVersionMethodString1() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + String name = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString(); + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(name); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_String1_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString2.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString2.golden new file mode 100644 index 0000000000..271c4145a6 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodString2.golden @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_String2_sync] +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.FoobarName; + +public class SyncEchoWithVersionMethodString2 { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodString2(); + } + + public static void syncEchoWithVersionMethodString2() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + String parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString(); + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(parent); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_String2_sync] diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStringSeverity.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStringSeverity.golden new file mode 100644 index 0000000000..34011a4b90 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/apiversionclient/SyncEchoWithVersionMethodStringSeverity.golden @@ -0,0 +1,43 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.api.version.test.samples; + +// [START goldensample_generated_EchoWithVersion_EchoWithVersionMethod_StringSeverity_sync] +import com.google.api.version.test.EchoResponse; +import com.google.api.version.test.EchoWithVersionClient; +import com.google.api.version.test.Severity; + +public class SyncEchoWithVersionMethodStringSeverity { + + public static void main(String[] args) throws Exception { + syncEchoWithVersionMethodStringSeverity(); + } + + public static void syncEchoWithVersionMethodStringSeverity() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) { + String content = "content951530617"; + Severity severity = Severity.forNumber(0); + EchoResponse response = echoWithVersionClient.echoWithVersionMethod(content, severity); + } + } +} +// [END goldensample_generated_EchoWithVersion_EchoWithVersionMethod_StringSeverity_sync] From d3dbf0bef18804b73cff30d3d22c513811b851c5 Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Mon, 6 May 2024 05:36:08 +0000 Subject: [PATCH 5/6] test: revert api_version addition to echo_grpcrest.proto and relevant golden. --- .../composer/grpcrest/goldens/EchoStubSettings.golden | 7 +++---- gapic-generator-java/src/test/proto/echo_grpcrest.proto | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden index 565f38a483..fefa7643ba 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden @@ -348,8 +348,8 @@ public class EchoStubSettings extends StubSettings { public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(EchoStubSettings.class)) - .setTransportToken(GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()) - .setApiVersionToken("foo_version_for_tests"); + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { @@ -357,8 +357,7 @@ public class EchoStubSettings extends StubSettings { .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(EchoStubSettings.class)) .setTransportToken( GaxHttpJsonProperties.getHttpJsonTokenName(), - GaxHttpJsonProperties.getHttpJsonVersion()) - .setApiVersionToken("foo_version_for_tests"); + GaxHttpJsonProperties.getHttpJsonVersion()); } public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { diff --git a/gapic-generator-java/src/test/proto/echo_grpcrest.proto b/gapic-generator-java/src/test/proto/echo_grpcrest.proto index ea4a9392f3..fbab0c2553 100644 --- a/gapic-generator-java/src/test/proto/echo_grpcrest.proto +++ b/gapic-generator-java/src/test/proto/echo_grpcrest.proto @@ -47,7 +47,6 @@ service Echo { option (google.api.default_host) = "localhost:7469"; option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - option (google.api.api_version) = "foo_version_for_tests"; // This method simply echos the request. This method is showcases unary rpcs. rpc Echo(EchoRequest) returns (EchoResponse) { From 84654837c0760e6d37b510efaa77d757b2dd0279 Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Mon, 6 May 2024 06:03:50 +0000 Subject: [PATCH 6/6] test: add test to grpcrest service client composer. --- .../ServiceClientClassComposerTest.java | 55 +-- .../grpcrest/goldens/ApiVersionClient.golden | 458 ++++++++++++++++++ 2 files changed, 483 insertions(+), 30 deletions(-) create mode 100644 gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/ApiVersionClient.golden diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java index 66e88d87af..949bfaa50c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/ServiceClientClassComposerTest.java @@ -23,48 +23,43 @@ import com.google.api.generator.test.protoloader.GrpcRestTestProtoLoader; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collection; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +@RunWith(Parameterized.class) public class ServiceClientClassComposerTest { - @Test - public void generateServiceClasses() { - GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); - Service echoProtoService = context.services().get(0); - GapicClass clazz = ServiceClientClassComposer.instance().generate(context, echoProtoService); - - JavaWriterVisitor visitor = new JavaWriterVisitor(); - clazz.classDefinition().accept(visitor); - GoldenFileWriter.saveCodegenToFile(this.getClass(), "EchoClient.golden", visitor.write()); - Path goldenFilePath = - Paths.get(GoldenFileWriter.getGoldenDir(this.getClass()), "EchoClient.golden"); - Assert.assertCodeEquals(goldenFilePath, visitor.write()); + @Parameterized.Parameters + public static Collection data() { + return Arrays.asList( + new Object[][] { + {"EchoClient", GrpcRestTestProtoLoader.instance().parseShowcaseEcho(), 0}, + {"EchoEmpty", GrpcRestTestProtoLoader.instance().parseShowcaseEcho(), 1}, + {"WickedClient", GrpcRestTestProtoLoader.instance().parseShowcaseWicked(), 0}, + {"ApiVersionClient", GrpcRestTestProtoLoader.instance().parseApiVersionTesting(), 0}, + }); } - @Test - public void generateServiceClassesEmpty() { - GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho(); - Service echoProtoService = context.services().get(1); - GapicClass clazz = ServiceClientClassComposer.instance().generate(context, echoProtoService); + @Parameterized.Parameter public String name; - JavaWriterVisitor visitor = new JavaWriterVisitor(); - clazz.classDefinition().accept(visitor); - GoldenFileWriter.saveCodegenToFile(this.getClass(), "EchoEmpty.golden", visitor.write()); - Path goldenFilePath = - Paths.get(GoldenFileWriter.getGoldenDir(this.getClass()), "EchoEmpty.golden"); - Assert.assertCodeEquals(goldenFilePath, visitor.write()); - } + @Parameterized.Parameter(1) + public GapicContext context; + + @Parameterized.Parameter(2) + public int serviceIndex; @Test - public void generateServiceClassesWicked() { - GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); - Service wickedProtoService = context.services().get(0); - GapicClass clazz = ServiceClientClassComposer.instance().generate(context, wickedProtoService); + public void generateServiceClasses() { + Service echoProtoService = context.services().get(serviceIndex); + GapicClass clazz = ServiceClientClassComposer.instance().generate(context, echoProtoService); JavaWriterVisitor visitor = new JavaWriterVisitor(); clazz.classDefinition().accept(visitor); - GoldenFileWriter.saveCodegenToFile(this.getClass(), "WickedClient.golden", visitor.write()); + GoldenFileWriter.saveCodegenToFile(this.getClass(), name + ".golden", visitor.write()); Path goldenFilePath = - Paths.get(GoldenFileWriter.getGoldenDir(this.getClass()), "WickedClient.golden"); + Paths.get(GoldenFileWriter.getGoldenDir(this.getClass()), name + ".golden"); Assert.assertCodeEquals(goldenFilePath, visitor.write()); } } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/ApiVersionClient.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/ApiVersionClient.golden new file mode 100644 index 0000000000..1ad678cac7 --- /dev/null +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/ApiVersionClient.golden @@ -0,0 +1,458 @@ +package com.google.api.version.test; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.resourcenames.ResourceName; +import com.google.api.version.test.stub.EchoWithVersionStub; +import com.google.api.version.test.stub.EchoWithVersionStubSettings; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * This service client implements API version: fake_version. + * + *

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: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+ *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod();
+ * }
+ * }
+ * + *

Note: close() needs to be called on the EchoWithVersionClient object to clean up resources + * such as threads. In the example above, try-with-resources is used, which automatically calls + * close(). + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Methods
MethodDescriptionMethod Variants

EchoWithVersionMethod

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • echoWithVersionMethod(EchoRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • echoWithVersionMethod() + *

  • echoWithVersionMethod(ResourceName parent) + *

  • echoWithVersionMethod(FoobarName name) + *

  • echoWithVersionMethod(Status error) + *

  • echoWithVersionMethod(String content) + *

  • echoWithVersionMethod(String name) + *

  • echoWithVersionMethod(String parent) + *

  • echoWithVersionMethod(String content, Severity severity) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • echoWithVersionMethodCallable() + *

+ *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of EchoWithVersionSettings to + * create(). For example: + * + *

To customize credentials: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * EchoWithVersionSettings echoWithVersionSettings =
+ *     EchoWithVersionSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * EchoWithVersionClient echoWithVersionClient =
+ *     EchoWithVersionClient.create(echoWithVersionSettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * EchoWithVersionSettings echoWithVersionSettings =
+ *     EchoWithVersionSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * EchoWithVersionClient echoWithVersionClient =
+ *     EchoWithVersionClient.create(echoWithVersionSettings);
+ * }
+ * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * EchoWithVersionSettings echoWithVersionSettings =
+ *     EchoWithVersionSettings.newHttpJsonBuilder().build();
+ * EchoWithVersionClient echoWithVersionClient =
+ *     EchoWithVersionClient.create(echoWithVersionSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class EchoWithVersionClient implements BackgroundResource { + private final EchoWithVersionSettings settings; + private final EchoWithVersionStub stub; + + /** Constructs an instance of EchoWithVersionClient with default settings. */ + public static final EchoWithVersionClient create() throws IOException { + return create(EchoWithVersionSettings.newBuilder().build()); + } + + /** + * Constructs an instance of EchoWithVersionClient, using the given settings. The channels are + * created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final EchoWithVersionClient create(EchoWithVersionSettings settings) + throws IOException { + return new EchoWithVersionClient(settings); + } + + /** + * Constructs an instance of EchoWithVersionClient, using the given stub for making calls. This is + * for advanced usage - prefer using create(EchoWithVersionSettings). + */ + public static final EchoWithVersionClient create(EchoWithVersionStub stub) { + return new EchoWithVersionClient(stub); + } + + /** + * Constructs an instance of EchoWithVersionClient, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected EchoWithVersionClient(EchoWithVersionSettings settings) throws IOException { + this.settings = settings; + this.stub = ((EchoWithVersionStubSettings) settings.getStubSettings()).createStub(); + } + + protected EchoWithVersionClient(EchoWithVersionStub stub) { + this.settings = null; + this.stub = stub; + } + + public final EchoWithVersionSettings getSettings() { + return settings; + } + + public EchoWithVersionStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod();
+   * }
+   * }
+ * + * @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 + */ + public final EchoResponse echoWithVersionMethod() { + EchoRequest request = EchoRequest.newBuilder().build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   ResourceName parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(parent);
+   * }
+   * }
+ * + * @param parent + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(ResourceName parent) { + EchoRequest request = + EchoRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   FoobarName name = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(name);
+   * }
+   * }
+ * + * @param name + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(FoobarName name) { + EchoRequest request = + EchoRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   Status error = Status.newBuilder().build();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(error);
+   * }
+   * }
+ * + * @param error + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(Status error) { + EchoRequest request = EchoRequest.newBuilder().setError(error).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String content = "content951530617";
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(content);
+   * }
+   * }
+ * + * @param content + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String content) { + EchoRequest request = EchoRequest.newBuilder().setContent(content).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String name = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(name);
+   * }
+   * }
+ * + * @param name + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String name) { + EchoRequest request = EchoRequest.newBuilder().setName(name).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(parent);
+   * }
+   * }
+ * + * @param parent + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String parent) { + EchoRequest request = EchoRequest.newBuilder().setParent(parent).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   String content = "content951530617";
+   *   Severity severity = Severity.forNumber(0);
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(content, severity);
+   * }
+   * }
+ * + * @param content + * @param severity + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final EchoResponse echoWithVersionMethod(String content, Severity severity) { + EchoRequest request = + EchoRequest.newBuilder().setContent(content).setSeverity(severity).build(); + return echoWithVersionMethod(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   EchoRequest request =
+   *       EchoRequest.newBuilder()
+   *           .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setSeverity(Severity.forNumber(0))
+   *           .setFoobar(Foobar.newBuilder().build())
+   *           .build();
+   *   EchoResponse response = echoWithVersionClient.echoWithVersionMethod(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 + */ + public final EchoResponse echoWithVersionMethod(EchoRequest request) { + return echoWithVersionMethodCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sample code: + * + *
{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (EchoWithVersionClient echoWithVersionClient = EchoWithVersionClient.create()) {
+   *   EchoRequest request =
+   *       EchoRequest.newBuilder()
+   *           .setName(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setParent(FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]").toString())
+   *           .setSeverity(Severity.forNumber(0))
+   *           .setFoobar(Foobar.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       echoWithVersionClient.echoWithVersionMethodCallable().futureCall(request);
+   *   // Do something.
+   *   EchoResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable echoWithVersionMethodCallable() { + return stub.echoWithVersionMethodCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } +}