From de732d4ad462a25de8b60241704bfde4849860e6 Mon Sep 17 00:00:00 2001 From: summerji Date: Mon, 16 Nov 2020 00:25:18 -0800 Subject: [PATCH 01/11] Implement sample code of customize credentials in service client class header --- .../api/generator/gapic/composer/BUILD.bazel | 2 + .../composer/ServiceClientClassComposer.java | 2 +- .../ServiceClientCommentComposer.java | 7 +- .../ServiceClientSampleCodeComposer.java | 107 ++++++++++++++++++ .../gapic/composer/goldens/EchoClient.golden | 8 ++ .../composer/goldens/IdentityClient.golden | 8 ++ .../goldens/asset/AssetServiceClient.java | 8 ++ .../logging/ConfigServiceV2Client.java | 9 ++ .../logging/LoggingServiceV2Client.java | 9 ++ .../logging/MetricsServiceV2Client.java | 9 ++ .../goldens/redis/CloudRedisClient.java | 8 ++ 11 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java diff --git a/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel index f90d35bd99..503561e307 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel +++ b/src/main/java/com/google/api/generator/gapic/composer/BUILD.bazel @@ -15,9 +15,11 @@ java_library( deps = [ "//:service_config_java_proto", "//src/main/java/com/google/api/generator/engine/ast", + "//src/main/java/com/google/api/generator/engine/writer", "//src/main/java/com/google/api/generator/gapic:status_java_proto", "//src/main/java/com/google/api/generator/gapic/model", "//src/main/java/com/google/api/generator/gapic/utils", + "//src/main/java/com/google/api/generator/gapic/composer/samplecode", "@com_google_api_api_common//jar", "@com_google_api_gax_java//gax", "@com_google_api_gax_java//gax-grpc:gax_grpc", diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java index 02ff960025..8ed7331724 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java @@ -119,7 +119,7 @@ public GapicClass generate(Service service, Map messageTypes) { ClassDefinition classDef = ClassDefinition.builder() .setHeaderCommentStatements( - ServiceClientCommentComposer.createClassHeaderComments(service)) + ServiceClientCommentComposer.createClassHeaderComments(service, types)) .setPackageString(pakkage) .setAnnotations(createClassAnnotations(types)) .setScope(ScopeNode.PUBLIC) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index 1a0f8f2b0f..96cc59df77 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -103,7 +104,8 @@ class ServiceClientCommentComposer { "Returns the OperationsClient that can be used to query the status of a long-running" + " operation returned by another API method call."); - static List createClassHeaderComments(Service service) { + static List createClassHeaderComments( + Service service, Map types) { JavaDocComment.Builder classHeaderJavadocBuilder = JavaDocComment.builder(); if (service.hasDescription()) { classHeaderJavadocBuilder = @@ -134,7 +136,8 @@ static List createClassHeaderComments(Service service) { SERVICE_DESCRIPTION_CUSTOMIZE_SUMMARY_PATTERN, String.format("%sSettings", JavaStyle.toUpperCamelCase(service.name())))); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_CREDENTIALS_SUMMARY_STRING); - // TODO(summerji): Add credentials' customization sample code here. + classHeaderJavadocBuilder.addSampleCode( + ServiceClientSampleCodeComposer.composeClassHeaderCredentialsSampleCode(service, types)); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_ENDPOINT_SUMMARY_STRING); // TODO(summerji): Add endpoint customization sample code here. diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java new file mode 100644 index 0000000000..4e6381fd3d --- /dev/null +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -0,0 +1,107 @@ +package com.google.api.generator.gapic.composer; + +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.api.generator.engine.ast.AssignmentExpr; +import com.google.api.generator.engine.ast.ConcreteReference; +import com.google.api.generator.engine.ast.Expr; +import com.google.api.generator.engine.ast.ExprStatement; +import com.google.api.generator.engine.ast.MethodInvocationExpr; +import com.google.api.generator.engine.ast.Statement; +import com.google.api.generator.engine.ast.StringObjectValue; +import com.google.api.generator.engine.ast.TypeNode; +import com.google.api.generator.engine.ast.ValueExpr; +import com.google.api.generator.engine.ast.Variable; +import com.google.api.generator.engine.ast.VariableExpr; +import com.google.api.generator.engine.writer.JavaWriterVisitor; +import com.google.api.generator.gapic.composer.samplecode.SampleCodeJavaFormatter; +import com.google.api.generator.gapic.model.Service; +import com.google.api.generator.gapic.utils.JavaStyle; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class ServiceClientSampleCodeComposer { + private static final String SETTINGS_NAME_PATTERN = "%sSettings"; + private static final String CLASS_NAME_PATTERN = "%sClient"; + + public static String composeClassHeaderCredentialsSampleCode( + Service service, Map types) { + String settingsVarName = JavaStyle.toLowerCamelCase(getSettingsName(service.name())); + TypeNode settingsVarType = types.get(getSettingsName(service.name())); + VariableExpr settingsVarExpr = createVariableExpr(settingsVarName, settingsVarType); + MethodInvocationExpr newBuilderMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(settingsVarType) + .setMethodName("newBuilder") + .build(); + TypeNode fixedCredentialProvideType = + TypeNode.withReference(ConcreteReference.withClazz(FixedCredentialsProvider.class)); + MethodInvocationExpr credentialArgExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(fixedCredentialProvideType) + .setArguments(ValueExpr.withValue(StringObjectValue.withValue("myCredentials"))) + .setMethodName("create") + .build(); + MethodInvocationExpr credentialsMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderMethodExpr) + .setArguments(credentialArgExpr) + .setMethodName("setCredentialsProvider") + .build(); + MethodInvocationExpr buildMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(credentialsMethodExpr) + .setReturnType(settingsVarType) + .setMethodName("build") + .build(); + Expr initSettingsVarExpr = + AssignmentExpr.builder() + .setVariableExpr(settingsVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(buildMethodExpr) + .build(); + + String clientName = JavaStyle.toLowerCamelCase(getClientClassName(service.name())); + TypeNode clientType = types.get(getClientClassName(service.name())); + VariableExpr clientVarExpr = createVariableExpr(clientName, clientType); + MethodInvocationExpr createMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setArguments(settingsVarExpr) + .setMethodName("create") + .setReturnType(clientType) + .build(); + Expr initClientVarExpr = + AssignmentExpr.builder() + .setVariableExpr(clientVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(createMethodExpr) + .build(); + + return writeSampleCode(Arrays.asList(initSettingsVarExpr, initClientVarExpr)); + } + + // ======================================== Helpers ==========================================// + + private static String getClientClassName(String serviceName) { + return String.format(CLASS_NAME_PATTERN, serviceName); + } + + private static String getSettingsName(String serviceName) { + return String.format(SETTINGS_NAME_PATTERN, serviceName); + } + + private static String writeSampleCode(List exprs) { + List statements = + exprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList()); + JavaWriterVisitor visitor = new JavaWriterVisitor(); + for (Statement statement : statements) { + statement.accept(visitor); + } + return SampleCodeJavaFormatter.format(visitor.write()); + } + + private static VariableExpr createVariableExpr(String variableName, TypeNode type) { + return VariableExpr.withVariable( + Variable.builder().setName(variableName).setType(type).build()); + } +} diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden index 20a193853e..f6d876176c 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden @@ -63,6 +63,14 @@ import javax.annotation.Generated; * *

To customize credentials: * + *

{@code
+ * EchoSettings echoSettings =
+ *     EchoSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * EchoClient echoClient = EchoClient.create(echoSettings);
+ * }
+ * *

To customize the endpoint: */ @BetaApi diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index 0f48757f2b..fa121bc4d9 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -53,6 +53,14 @@ import javax.annotation.Generated; * *

To customize credentials: * + *

{@code
+ * IdentitySettings identitySettings =
+ *     IdentitySettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * IdentityClient identityClient = IdentityClient.create(identitySettings);
+ * }
+ * *

To customize the endpoint: */ @BetaApi diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index 103843b065..7ba8307058 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -75,6 +75,14 @@ * *

To customize credentials: * + *

{@code
+ * AssetServiceSettings assetServiceSettings =
+ *     AssetServiceSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings);
+ * }
+ * *

To customize the endpoint: */ @BetaApi diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java index b6516172fc..afb5fc89da 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -73,6 +73,15 @@ * *

To customize credentials: * + *

{@code
+ * ConfigServiceV2Settings configServiceV2Settings =
+ *     ConfigServiceV2Settings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * ConfigServiceV2Client configServiceV2Client =
+ *     ConfigServiceV2Client.create(configServiceV2Settings);
+ * }
+ * *

To customize the endpoint: */ @BetaApi diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java index d90cbfadf6..45d0ef7d89 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Client.java +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -75,6 +75,15 @@ * *

To customize credentials: * + *

{@code
+ * LoggingServiceV2Settings loggingServiceV2Settings =
+ *     LoggingServiceV2Settings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * LoggingServiceV2Client loggingServiceV2Client =
+ *     LoggingServiceV2Client.create(loggingServiceV2Settings);
+ * }
+ * *

To customize the endpoint: */ @BetaApi diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java index 19f6aef98d..c6735f8f00 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -72,6 +72,15 @@ * *

To customize credentials: * + *

{@code
+ * MetricsServiceV2Settings metricsServiceV2Settings =
+ *     MetricsServiceV2Settings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * MetricsServiceV2Client metricsServiceV2Client =
+ *     MetricsServiceV2Client.create(metricsServiceV2Settings);
+ * }
+ * *

To customize the endpoint: */ @BetaApi diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index c807b6dd8a..5fed1d2d0a 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -95,6 +95,14 @@ * *

To customize credentials: * + *

{@code
+ * CloudRedisSettings cloudRedisSettings =
+ *     CloudRedisSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create("myCredentials"))
+ *         .build();
+ * CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
+ * }
+ * *

To customize the endpoint: */ @BetaApi From e5df14bca56d5826d04c173a6a1b04e4ecd33242 Mon Sep 17 00:00:00 2001 From: summerji Date: Mon, 16 Nov 2020 00:27:33 -0800 Subject: [PATCH 02/11] Add license --- .../composer/ServiceClientSampleCodeComposer.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index 4e6381fd3d..b0b272f680 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -1,3 +1,17 @@ +// Copyright 2020 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 +// +// http://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.generator.gapic.composer; import com.google.api.gax.core.FixedCredentialsProvider; From e21482434a07401dd02d6d0736f1a6ab6ca319af Mon Sep 17 00:00:00 2001 From: summerji Date: Mon, 16 Nov 2020 17:49:01 -0800 Subject: [PATCH 03/11] Add comments in composer, add TODOs, refactor the signatures --- .../ServiceClientCommentComposer.java | 19 ++++++++++- .../ServiceClientSampleCodeComposer.java | 33 +++++++------------ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index 96cc59df77..b41b25992c 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -30,6 +30,10 @@ import java.util.stream.Stream; class ServiceClientCommentComposer { + // Name Pattern. + private static final String SETTINGS_NAME_PATTERN = "%sSettings"; + private static final String CLASS_NAME_PATTERN = "%sClient"; + // Tokens. private static final String COLON = ":"; private static final String EMPTY_STRING = ""; @@ -106,6 +110,10 @@ class ServiceClientCommentComposer { static List createClassHeaderComments( Service service, Map types) { + String settingsName = JavaStyle.toLowerCamelCase(getSettingsName(service.name())); + String clientName = JavaStyle.toLowerCamelCase(getClientClassName(service.name())); + TypeNode settingsType = types.get(getSettingsName(service.name())); + TypeNode clientType = types.get(getClientClassName(service.name())); JavaDocComment.Builder classHeaderJavadocBuilder = JavaDocComment.builder(); if (service.hasDescription()) { classHeaderJavadocBuilder = @@ -137,7 +145,8 @@ static List createClassHeaderComments( String.format("%sSettings", JavaStyle.toUpperCamelCase(service.name())))); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_CREDENTIALS_SUMMARY_STRING); classHeaderJavadocBuilder.addSampleCode( - ServiceClientSampleCodeComposer.composeClassHeaderCredentialsSampleCode(service, types)); + ServiceClientSampleCodeComposer.composeClassHeaderCredentialsSampleCode( + clientName, clientType, settingsName, settingsType)); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_ENDPOINT_SUMMARY_STRING); // TODO(summerji): Add endpoint customization sample code here. @@ -257,4 +266,12 @@ private static JavaDocComment.Builder processProtobufComment( return commentBuilder; } + + private static String getSettingsName(String serviceName) { + return String.format(SETTINGS_NAME_PATTERN, serviceName); + } + + private static String getClientClassName(String serviceName) { + return String.format(CLASS_NAME_PATTERN, serviceName); + } } diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index b0b272f680..9224dea527 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -28,25 +28,22 @@ import com.google.api.generator.engine.ast.VariableExpr; import com.google.api.generator.engine.writer.JavaWriterVisitor; import com.google.api.generator.gapic.composer.samplecode.SampleCodeJavaFormatter; -import com.google.api.generator.gapic.model.Service; -import com.google.api.generator.gapic.utils.JavaStyle; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; public class ServiceClientSampleCodeComposer { - private static final String SETTINGS_NAME_PATTERN = "%sSettings"; - private static final String CLASS_NAME_PATTERN = "%sClient"; + //TODO(summerji): Add unit tests for ServiceClientSampleCodeComposer. public static String composeClassHeaderCredentialsSampleCode( - Service service, Map types) { - String settingsVarName = JavaStyle.toLowerCamelCase(getSettingsName(service.name())); - TypeNode settingsVarType = types.get(getSettingsName(service.name())); - VariableExpr settingsVarExpr = createVariableExpr(settingsVarName, settingsVarType); + String clientName, TypeNode clientType, String settingsName, TypeNode settingsType) { + // Initialize clientSettings with builder() method. + // e.g. EchoSettings echoSettings = + // EchoSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create("myCredentials")).build(); + VariableExpr settingsVarExpr = createVariableExpr(settingsName, settingsType); MethodInvocationExpr newBuilderMethodExpr = MethodInvocationExpr.builder() - .setStaticReferenceType(settingsVarType) + .setStaticReferenceType(settingsType) .setMethodName("newBuilder") .build(); TypeNode fixedCredentialProvideType = @@ -66,7 +63,7 @@ public static String composeClassHeaderCredentialsSampleCode( MethodInvocationExpr buildMethodExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(credentialsMethodExpr) - .setReturnType(settingsVarType) + .setReturnType(settingsType) .setMethodName("build") .build(); Expr initSettingsVarExpr = @@ -75,8 +72,8 @@ public static String composeClassHeaderCredentialsSampleCode( .setValueExpr(buildMethodExpr) .build(); - String clientName = JavaStyle.toLowerCamelCase(getClientClassName(service.name())); - TypeNode clientType = types.get(getClientClassName(service.name())); + // Initialized client with create() method. + // e.g. EchoClient echoClient = EchoClient.create(echoSettings); VariableExpr clientVarExpr = createVariableExpr(clientName, clientType); MethodInvocationExpr createMethodExpr = MethodInvocationExpr.builder() @@ -95,15 +92,7 @@ public static String composeClassHeaderCredentialsSampleCode( } // ======================================== Helpers ==========================================// - - private static String getClientClassName(String serviceName) { - return String.format(CLASS_NAME_PATTERN, serviceName); - } - - private static String getSettingsName(String serviceName) { - return String.format(SETTINGS_NAME_PATTERN, serviceName); - } - + // TODO(summerji): Use writeSampleCode method in new class once PR#499 merged. private static String writeSampleCode(List exprs) { List statements = exprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList()); From b9f8024f36994444f6fdcc8c1ae0f3d70ee37abf Mon Sep 17 00:00:00 2001 From: summerji Date: Mon, 16 Nov 2020 18:31:19 -0800 Subject: [PATCH 04/11] format the files --- .../gapic/composer/ServiceClientSampleCodeComposer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index 9224dea527..519e6691f0 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -33,7 +33,7 @@ import java.util.stream.Collectors; public class ServiceClientSampleCodeComposer { - //TODO(summerji): Add unit tests for ServiceClientSampleCodeComposer. + // TODO(summerji): Add unit tests for ServiceClientSampleCodeComposer. public static String composeClassHeaderCredentialsSampleCode( String clientName, TypeNode clientType, String settingsName, TypeNode settingsType) { From 2ae0ccec2b4947349ce8973780aa64386d67386f Mon Sep 17 00:00:00 2001 From: summerji Date: Tue, 17 Nov 2020 12:24:19 -0800 Subject: [PATCH 05/11] refactor signature --- .../gapic/composer/ServiceClientClassComposer.java | 9 ++++++++- .../gapic/composer/ServiceClientCommentComposer.java | 5 +---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java index 8ed7331724..edc3b6a265 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java @@ -119,7 +119,10 @@ public GapicClass generate(Service service, Map messageTypes) { ClassDefinition classDef = ClassDefinition.builder() .setHeaderCommentStatements( - ServiceClientCommentComposer.createClassHeaderComments(service, types)) + ServiceClientCommentComposer.createClassHeaderComments( + service, + types.get(getClientClassName(service.name())), + types.get(getSettingsName(service.name())))) .setPackageString(pakkage) .setAnnotations(createClassAnnotations(types)) .setScope(ScopeNode.PUBLIC) @@ -1505,6 +1508,10 @@ private static String getClientClassName(String serviceName) { return String.format("%sClient", serviceName); } + private static String getSettingsName(String serviceName) { + return String.format("%sSettings", serviceName); + } + private static List getGenericsForCallable( CallableMethodKind kind, Method method, Map types) { if (kind.equals(CallableMethodKind.LRO)) { diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index b41b25992c..084de56303 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -109,11 +108,9 @@ class ServiceClientCommentComposer { + " operation returned by another API method call."); static List createClassHeaderComments( - Service service, Map types) { + Service service, TypeNode clientType, TypeNode settingsType) { String settingsName = JavaStyle.toLowerCamelCase(getSettingsName(service.name())); String clientName = JavaStyle.toLowerCamelCase(getClientClassName(service.name())); - TypeNode settingsType = types.get(getSettingsName(service.name())); - TypeNode clientType = types.get(getClientClassName(service.name())); JavaDocComment.Builder classHeaderJavadocBuilder = JavaDocComment.builder(); if (service.hasDescription()) { classHeaderJavadocBuilder = From cc843c6369fd95ed76a14c46da7f6ec2943e7e69 Mon Sep 17 00:00:00 2001 From: summerji Date: Tue, 17 Nov 2020 13:46:47 -0800 Subject: [PATCH 06/11] simplify the input parameters --- .../gapic/composer/ServiceClientCommentComposer.java | 2 +- .../gapic/composer/ServiceClientSampleCodeComposer.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index 084de56303..e3708ecffa 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -143,7 +143,7 @@ static List createClassHeaderComments( classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_CREDENTIALS_SUMMARY_STRING); classHeaderJavadocBuilder.addSampleCode( ServiceClientSampleCodeComposer.composeClassHeaderCredentialsSampleCode( - clientName, clientType, settingsName, settingsType)); + clientType, settingsType)); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_ENDPOINT_SUMMARY_STRING); // TODO(summerji): Add endpoint customization sample code here. diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index 519e6691f0..29fb34e45d 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -28,6 +28,7 @@ import com.google.api.generator.engine.ast.VariableExpr; import com.google.api.generator.engine.writer.JavaWriterVisitor; import com.google.api.generator.gapic.composer.samplecode.SampleCodeJavaFormatter; +import com.google.api.generator.gapic.utils.JavaStyle; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -36,10 +37,12 @@ public class ServiceClientSampleCodeComposer { // TODO(summerji): Add unit tests for ServiceClientSampleCodeComposer. public static String composeClassHeaderCredentialsSampleCode( - String clientName, TypeNode clientType, String settingsName, TypeNode settingsType) { + TypeNode clientType, TypeNode settingsType) { // Initialize clientSettings with builder() method. // e.g. EchoSettings echoSettings = // EchoSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create("myCredentials")).build(); + String settingsName = JavaStyle.toLowerCamelCase(settingsType.reference().name()); + String clientName = JavaStyle.toLowerCamelCase(clientType.reference().name()); VariableExpr settingsVarExpr = createVariableExpr(settingsName, settingsType); MethodInvocationExpr newBuilderMethodExpr = MethodInvocationExpr.builder() From 43266d65e1ec8041e55ec78c0a29fba11238b0a7 Mon Sep 17 00:00:00 2001 From: summerji Date: Mon, 16 Nov 2020 00:57:04 -0800 Subject: [PATCH 07/11] Implement set endpoint in service client class comment header --- .../ServiceClientCommentComposer.java | 3 +- .../ServiceClientSampleCodeComposer.java | 48 +++++++++++++++++++ .../gapic/composer/goldens/EchoClient.golden | 5 ++ .../composer/goldens/IdentityClient.golden | 6 +++ .../goldens/asset/AssetServiceClient.java | 6 +++ .../logging/ConfigServiceV2Client.java | 7 +++ .../logging/LoggingServiceV2Client.java | 7 +++ .../logging/MetricsServiceV2Client.java | 7 +++ .../goldens/redis/CloudRedisClient.java | 6 +++ 9 files changed, 94 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index e3708ecffa..f8a3524ecf 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -145,7 +145,8 @@ static List createClassHeaderComments( ServiceClientSampleCodeComposer.composeClassHeaderCredentialsSampleCode( clientType, settingsType)); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_ENDPOINT_SUMMARY_STRING); - // TODO(summerji): Add endpoint customization sample code here. + classHeaderJavadocBuilder.addSampleCode( + ServiceClientSampleCodeComposer.composeClassHeaderEndpointSampleCode(service, types)); return Arrays.asList( CommentComposer.AUTO_GENERATED_CLASS_COMMENT, diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index 29fb34e45d..68e686bc16 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -94,6 +94,54 @@ public static String composeClassHeaderCredentialsSampleCode( return writeSampleCode(Arrays.asList(initSettingsVarExpr, initClientVarExpr)); } + public static String composeClassHeaderEndpointSampleCode( + Service service, Map types) { + String settingsVarName = JavaStyle.toLowerCamelCase(getSettingsName(service.name())); + TypeNode settingsVarType = types.get(getSettingsName(service.name())); + VariableExpr settingsVarExpr = createVariableExpr(settingsVarName, settingsVarType); + MethodInvocationExpr newBuilderMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(settingsVarType) + .setMethodName("newBuilder") + .build(); + MethodInvocationExpr credentialsMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderMethodExpr) + .setArguments(ValueExpr.withValue(StringObjectValue.withValue("myEndpoint"))) + .setMethodName("setEndpoint") + .build(); + MethodInvocationExpr buildMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(credentialsMethodExpr) + .setReturnType(settingsVarType) + .setMethodName("build") + .build(); + + Expr initSettingsVarExpr = + AssignmentExpr.builder() + .setVariableExpr(settingsVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(buildMethodExpr) + .build(); + + String clientName = JavaStyle.toLowerCamelCase(getClientClassName(service.name())); + TypeNode clientType = types.get(getClientClassName(service.name())); + VariableExpr clientVarExpr = createVariableExpr(clientName, clientType); + MethodInvocationExpr createMethodExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setArguments(settingsVarExpr) + .setMethodName("create") + .setReturnType(clientType) + .build(); + Expr initClientVarExpr = + AssignmentExpr.builder() + .setVariableExpr(clientVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(createMethodExpr) + .build(); + + return writeSampleCode(Arrays.asList(initSettingsVarExpr, initClientVarExpr)); + } + // ======================================== Helpers ==========================================// // TODO(summerji): Use writeSampleCode method in new class once PR#499 merged. private static String writeSampleCode(List exprs) { diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden index f6d876176c..98a271a69a 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden @@ -72,6 +72,11 @@ import javax.annotation.Generated; * } * *

To customize the endpoint: + * + *

{@code
+ * EchoSettings echoSettings = EchoSettings.newBuilder().setEndpoint("myEndpoint").build();
+ * EchoClient echoClient = EchoClient.create(echoSettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index fa121bc4d9..2ac3ee2add 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -62,6 +62,12 @@ import javax.annotation.Generated; * } * *

To customize the endpoint: + * + *

{@code
+ * IdentitySettings identitySettings =
+ *     IdentitySettings.newBuilder().setEndpoint("myEndpoint").build();
+ * IdentityClient identityClient = IdentityClient.create(identitySettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index 7ba8307058..b3d174be9f 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -84,6 +84,12 @@ * } * *

To customize the endpoint: + * + *

{@code
+ * AssetServiceSettings assetServiceSettings =
+ *     AssetServiceSettings.newBuilder().setEndpoint("myEndpoint").build();
+ * AssetServiceClient assetServiceClient = AssetServiceClient.create(assetServiceSettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java index afb5fc89da..575980738f 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -83,6 +83,13 @@ * } * *

To customize the endpoint: + * + *

{@code
+ * ConfigServiceV2Settings configServiceV2Settings =
+ *     ConfigServiceV2Settings.newBuilder().setEndpoint("myEndpoint").build();
+ * ConfigServiceV2Client configServiceV2Client =
+ *     ConfigServiceV2Client.create(configServiceV2Settings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java index 45d0ef7d89..d50f10ebce 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Client.java +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -85,6 +85,13 @@ * } * *

To customize the endpoint: + * + *

{@code
+ * LoggingServiceV2Settings loggingServiceV2Settings =
+ *     LoggingServiceV2Settings.newBuilder().setEndpoint("myEndpoint").build();
+ * LoggingServiceV2Client loggingServiceV2Client =
+ *     LoggingServiceV2Client.create(loggingServiceV2Settings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java index c6735f8f00..09761c6979 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -82,6 +82,13 @@ * } * *

To customize the endpoint: + * + *

{@code
+ * MetricsServiceV2Settings metricsServiceV2Settings =
+ *     MetricsServiceV2Settings.newBuilder().setEndpoint("myEndpoint").build();
+ * MetricsServiceV2Client metricsServiceV2Client =
+ *     MetricsServiceV2Client.create(metricsServiceV2Settings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index 5fed1d2d0a..d04354c29b 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -104,6 +104,12 @@ * } * *

To customize the endpoint: + * + *

{@code
+ * CloudRedisSettings cloudRedisSettings =
+ *     CloudRedisSettings.newBuilder().setEndpoint("myEndpoint").build();
+ * CloudRedisClient cloudRedisClient = CloudRedisClient.create(cloudRedisSettings);
+ * }
*/ @BetaApi @Generated("by gapic-generator") From 555ad6d54e3f08f99d7f3f7d274dadcc85759475 Mon Sep 17 00:00:00 2001 From: summerji Date: Mon, 16 Nov 2020 17:57:17 -0800 Subject: [PATCH 08/11] Refactor signatures, add todos, and comments --- .../composer/ServiceClientCommentComposer.java | 3 ++- .../ServiceClientSampleCodeComposer.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index f8a3524ecf..a98ee66618 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -146,7 +146,8 @@ static List createClassHeaderComments( clientType, settingsType)); classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_ENDPOINT_SUMMARY_STRING); classHeaderJavadocBuilder.addSampleCode( - ServiceClientSampleCodeComposer.composeClassHeaderEndpointSampleCode(service, types)); + ServiceClientSampleCodeComposer.composeClassHeaderEndpointSampleCode( + clientName, clientType, settingsName, settingsType)); return Arrays.asList( CommentComposer.AUTO_GENERATED_CLASS_COMMENT, diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index 68e686bc16..05db494fbc 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -95,13 +95,13 @@ public static String composeClassHeaderCredentialsSampleCode( } public static String composeClassHeaderEndpointSampleCode( - Service service, Map types) { - String settingsVarName = JavaStyle.toLowerCamelCase(getSettingsName(service.name())); - TypeNode settingsVarType = types.get(getSettingsName(service.name())); - VariableExpr settingsVarExpr = createVariableExpr(settingsVarName, settingsVarType); + String clientName, TypeNode clientType, String settingsName, TypeNode settingsType) { + // Initialize client settings with builder() method. + // e.g. EchoSettings echoSettings = EchoSettings.newBuilder().setEndpoint("myEndpoint").build(); + VariableExpr settingsVarExpr = createVariableExpr(settingsName, settingsType); MethodInvocationExpr newBuilderMethodExpr = MethodInvocationExpr.builder() - .setStaticReferenceType(settingsVarType) + .setStaticReferenceType(settingsType) .setMethodName("newBuilder") .build(); MethodInvocationExpr credentialsMethodExpr = @@ -113,7 +113,7 @@ public static String composeClassHeaderEndpointSampleCode( MethodInvocationExpr buildMethodExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(credentialsMethodExpr) - .setReturnType(settingsVarType) + .setReturnType(settingsType) .setMethodName("build") .build(); @@ -123,8 +123,8 @@ public static String composeClassHeaderEndpointSampleCode( .setValueExpr(buildMethodExpr) .build(); - String clientName = JavaStyle.toLowerCamelCase(getClientClassName(service.name())); - TypeNode clientType = types.get(getClientClassName(service.name())); + // Initialize client with create() method. + // e.g. EchoClient echoClient = EchoClient.create(echoSettings); VariableExpr clientVarExpr = createVariableExpr(clientName, clientType); MethodInvocationExpr createMethodExpr = MethodInvocationExpr.builder() From 314c13ab893548250d4cc6e1caf4778b628fe554 Mon Sep 17 00:00:00 2001 From: summerji Date: Tue, 17 Nov 2020 13:54:51 -0800 Subject: [PATCH 09/11] simplify the input parameters --- .../gapic/composer/ServiceClientCommentComposer.java | 2 +- .../gapic/composer/ServiceClientSampleCodeComposer.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index a98ee66618..379de93c74 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -147,7 +147,7 @@ static List createClassHeaderComments( classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_ENDPOINT_SUMMARY_STRING); classHeaderJavadocBuilder.addSampleCode( ServiceClientSampleCodeComposer.composeClassHeaderEndpointSampleCode( - clientName, clientType, settingsName, settingsType)); + clientType, settingsType)); return Arrays.asList( CommentComposer.AUTO_GENERATED_CLASS_COMMENT, diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index 05db494fbc..ee51d4cb57 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -95,9 +95,11 @@ public static String composeClassHeaderCredentialsSampleCode( } public static String composeClassHeaderEndpointSampleCode( - String clientName, TypeNode clientType, String settingsName, TypeNode settingsType) { + TypeNode clientType, TypeNode settingsType) { // Initialize client settings with builder() method. // e.g. EchoSettings echoSettings = EchoSettings.newBuilder().setEndpoint("myEndpoint").build(); + String settingsName = JavaStyle.toLowerCamelCase(settingsType.reference().name()); + String clientName = JavaStyle.toLowerCamelCase(clientType.reference().name()); VariableExpr settingsVarExpr = createVariableExpr(settingsName, settingsType); MethodInvocationExpr newBuilderMethodExpr = MethodInvocationExpr.builder() From fbbc1916193b8991a4af6006a7df29d77ab7a3d6 Mon Sep 17 00:00:00 2001 From: summerji Date: Tue, 17 Nov 2020 15:58:41 -0800 Subject: [PATCH 10/11] Structure sample code in rpc methods --- .../composer/ServiceClientClassComposer.java | 25 +- .../ServiceClientCommentComposer.java | 10 +- .../ServiceClientSampleCodeComposer.java | 9 + .../gapic/composer/goldens/EchoClient.golden | 78 +++++ .../composer/goldens/IdentityClient.golden | 66 ++++ .../goldens/asset/AssetServiceClient.java | 108 ++++++ .../logging/ConfigServiceV2Client.java | 324 ++++++++++++++++++ .../logging/LoggingServiceV2Client.java | 90 +++++ .../logging/MetricsServiceV2Client.java | 90 +++++ .../goldens/redis/CloudRedisClient.java | 144 ++++++++ 10 files changed, 932 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java index edc3b6a265..e136c25402 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java @@ -157,7 +157,9 @@ private static List createClassMethods( methods.addAll(createStaticCreatorMethods(service, types)); methods.addAll(createConstructorMethods(service, types, hasLroClient)); methods.addAll(createGetterMethods(service, types, hasLroClient)); - methods.addAll(createServiceMethods(service, messageTypes, types)); + methods.addAll( + createServiceMethods( + service, messageTypes, types, types.get(getClientClassName(service.name())))); methods.addAll(createBackgroundResourceMethods(service, types)); return methods; } @@ -469,12 +471,15 @@ private static List createGetterMethods( } private static List createServiceMethods( - Service service, Map messageTypes, Map types) { + Service service, + Map messageTypes, + Map types, + TypeNode clientType) { List javaMethods = new ArrayList<>(); for (Method method : service.methods()) { if (method.stream().equals(Stream.NONE)) { - javaMethods.addAll(createMethodVariants(method, messageTypes, types)); - javaMethods.add(createMethodDefaultMethod(method, types)); + javaMethods.addAll(createMethodVariants(method, messageTypes, types, clientType)); + javaMethods.add(createMethodDefaultMethod(method, types, clientType)); } if (method.hasLro()) { javaMethods.add(createLroCallableMethod(service.name(), method, types)); @@ -488,7 +493,10 @@ private static List createServiceMethods( } private static List createMethodVariants( - Method method, Map messageTypes, Map types) { + Method method, + Map messageTypes, + Map types, + TypeNode clientType) { List javaMethods = new ArrayList<>(); String methodName = JavaStyle.toLowerCamelCase(method.name()); TypeNode methodInputType = method.inputType(); @@ -552,7 +560,8 @@ private static List createMethodVariants( javaMethods.add( MethodDefinition.builder() .setHeaderCommentStatements( - ServiceClientCommentComposer.createRpcMethodHeaderComment(method, signature)) + ServiceClientCommentComposer.createRpcMethodHeaderComment( + method, signature, clientType)) .setScope(ScopeNode.PUBLIC) .setIsFinal(true) .setReturnType(methodOutputType) @@ -567,7 +576,7 @@ private static List createMethodVariants( } private static MethodDefinition createMethodDefaultMethod( - Method method, Map types) { + Method method, Map types, TypeNode clientType) { String methodName = JavaStyle.toLowerCamelCase(method.name()); TypeNode methodInputType = method.inputType(); TypeNode methodOutputType = @@ -611,7 +620,7 @@ private static MethodDefinition createMethodDefaultMethod( .build(); return MethodDefinition.builder() .setHeaderCommentStatements( - ServiceClientCommentComposer.createRpcMethodHeaderComment(method)) + ServiceClientCommentComposer.createRpcMethodHeaderComment(method, clientType)) .setScope(ScopeNode.PUBLIC) .setIsFinal(true) .setReturnType(methodOutputType) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index 379de93c74..c57b1a894a 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -162,7 +162,7 @@ static CommentStatement createCreateMethodStubArgComment( } static List createRpcMethodHeaderComment( - Method method, List methodArguments) { + Method method, List methodArguments, TypeNode clientType) { JavaDocComment.Builder methodJavadocBuilder = JavaDocComment.builder(); if (method.hasDescription()) { @@ -171,7 +171,9 @@ static List createRpcMethodHeaderComment( } methodJavadocBuilder.addParagraph(METHOD_DESCRIPTION_SAMPLE_CODE_SUMMARY_STRING); - // TODO(summerji): Add sample code here. + methodJavadocBuilder.addSampleCode( + ServiceClientSampleCodeComposer.composeRpcMethodHeaderSampleCode( + method, methodArguments, clientType)); if (methodArguments.isEmpty()) { methodJavadocBuilder.addParam( @@ -192,8 +194,8 @@ static List createRpcMethodHeaderComment( CommentStatement.withComment(methodJavadocBuilder.build())); } - static List createRpcMethodHeaderComment(Method method) { - return createRpcMethodHeaderComment(method, Collections.emptyList()); + static List createRpcMethodHeaderComment(Method method, TypeNode clientType) { + return createRpcMethodHeaderComment(method, Collections.emptyList(), clientType); } static CommentStatement createMethodNoArgComment(String serviceName) { diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java index ee51d4cb57..838f703354 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientSampleCodeComposer.java @@ -28,6 +28,9 @@ import com.google.api.generator.engine.ast.VariableExpr; import com.google.api.generator.engine.writer.JavaWriterVisitor; import com.google.api.generator.gapic.composer.samplecode.SampleCodeJavaFormatter; +import com.google.api.generator.gapic.composer.samplecode.SampleCodeWriter; +import com.google.api.generator.gapic.model.Method; +import com.google.api.generator.gapic.model.MethodArgument; import com.google.api.generator.gapic.utils.JavaStyle; import java.util.Arrays; import java.util.List; @@ -144,6 +147,12 @@ public static String composeClassHeaderEndpointSampleCode( return writeSampleCode(Arrays.asList(initSettingsVarExpr, initClientVarExpr)); } + public static String composeRpcMethodHeaderSampleCode( + Method method, List arguments, TypeNode clientType) { + return SampleCodeWriter.write( + SampleCodeHelperComposer.composeRpcMethodSampleCode(method, arguments, clientType)); + } + // ======================================== Helpers ==========================================// // TODO(summerji): Use writeSampleCode method in new class once PR#499 merged. private static String writeSampleCode(List exprs) { diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden index 98a271a69a..0c6ba38ac9 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden @@ -145,6 +145,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -160,6 +166,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param error * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -172,6 +184,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -185,6 +203,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param content * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -197,6 +221,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -209,6 +239,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -221,6 +257,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param content * @param severity * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -235,6 +277,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -276,6 +324,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -300,6 +354,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param ttl * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -312,6 +372,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param end_time * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -324,6 +390,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -347,6 +419,12 @@ public class EchoClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (EchoClient echoClient = EchoClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index 2ac3ee2add..9b8a9741ad 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -125,6 +125,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent * @param display_name * @param email @@ -144,6 +150,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent * @param display_name * @param email @@ -178,6 +190,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -195,6 +213,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -208,6 +232,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -220,6 +250,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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,6 +273,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -254,6 +296,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -269,6 +317,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -281,6 +335,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -298,6 +358,12 @@ public class IdentityClient implements BackgroundResource { /** * Sample code: * + *
{@code
+   * try (IdentityClient identityClient = IdentityClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index b3d174be9f..7250e322c3 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -168,6 +168,12 @@ public final OperationsClient getOperationsClient() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -221,6 +227,12 @@ public final UnaryCallable exportAssetsCallable( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -250,6 +262,12 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The name of the project/folder/organization where this feed should be * created in. It can only be an organization number (such as "organizations/123"), a folder * number (such as "folders/123"), a project ID (such as "projects/my-project-id")", or a @@ -267,6 +285,12 @@ public final Feed createFeed(String parent) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -290,6 +314,12 @@ public final UnaryCallable createFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -307,6 +337,12 @@ public final Feed getFeed(FeedName name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The name of the Feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -323,6 +359,12 @@ public final Feed getFeed(String name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -346,6 +388,12 @@ public final UnaryCallable getFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent project/folder/organization whose feeds are to be listed. It * can only be using project/folder/organization number (such as "folders/12345")", or a * project ID (such as "projects/my-project-id"). @@ -362,6 +410,12 @@ public final ListFeedsResponse listFeeds(String parent) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -385,6 +439,12 @@ public final UnaryCallable listFeedsCallabl * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param feed Required. The new values of feed details. It must match an existing feed and the * field `name` must be in the format of: projects/project_number/feeds/feed_id or * folders/folder_number/feeds/feed_id or organizations/organization_number/feeds/feed_id. @@ -401,6 +461,12 @@ public final Feed updateFeed(Feed feed) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -424,6 +490,12 @@ public final UnaryCallable updateFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -443,6 +515,12 @@ public final Empty deleteFeed(FeedName name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The name of the feed and it must be in the format of: * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id * organizations/organization_number/feeds/feed_id @@ -459,6 +537,12 @@ public final Empty deleteFeed(String name) { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -484,6 +568,12 @@ public final UnaryCallable deleteFeedCallable() { * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param scope Required. A scope can be a project, a folder, or an organization. The search is * limited to the resources within the `scope`. The caller must be granted the * [`cloudasset.assets.searchAllResources`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) @@ -552,6 +642,12 @@ public final SearchAllResourcesPagedResponse searchAllResources( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -594,6 +690,12 @@ public final SearchAllResourcesPagedResponse searchAllResources( * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param scope Required. A scope can be a project, a folder, or an organization. The search is * limited to the IAM policies within the `scope`. The caller must be granted the * [`cloudasset.assets.searchAllIamPolicies`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) @@ -646,6 +748,12 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope * *

Sample code: * + *

{@code
+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java index 575980738f..e2ae38f74b 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -151,6 +151,12 @@ public ConfigServiceV2Stub getStub() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -174,6 +180,12 @@ public final ListBucketsPagedResponse listBuckets(BillingAccountLocationName par * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -197,6 +209,12 @@ public final ListBucketsPagedResponse listBuckets(FolderLocationName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -220,6 +238,12 @@ public final ListBucketsPagedResponse listBuckets(LocationName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -243,6 +267,12 @@ public final ListBucketsPagedResponse listBuckets(OrganizationLocationName paren * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose buckets are to be listed: *

"projects/[PROJECT_ID]/locations/[LOCATION_ID]" * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" @@ -263,6 +293,12 @@ public final ListBucketsPagedResponse listBuckets(String parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -297,6 +333,12 @@ public final UnaryCallable listBucketsC * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -329,6 +371,12 @@ public final UnaryCallable getBucketCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -361,6 +409,12 @@ public final UnaryCallable updateBucketCallable( * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -380,6 +434,12 @@ public final ListSinksPagedResponse listSinks(BillingAccountName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -399,6 +459,12 @@ public final ListSinksPagedResponse listSinks(FolderName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -418,6 +484,12 @@ public final ListSinksPagedResponse listSinks(OrganizationName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -437,6 +509,12 @@ public final ListSinksPagedResponse listSinks(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose sinks are to be listed: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -453,6 +531,12 @@ public final ListSinksPagedResponse listSinks(String parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -486,6 +570,12 @@ public final UnaryCallable listSinksCallabl * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The resource name of the sink: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -508,6 +598,12 @@ public final LogSink getSink(LogSinkName sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The resource name of the sink: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -527,6 +623,12 @@ public final LogSink getSink(String sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -553,6 +655,12 @@ public final UnaryCallable getSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -579,6 +687,12 @@ public final LogSink createSink(BillingAccountName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -605,6 +719,12 @@ public final LogSink createSink(FolderName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -631,6 +751,12 @@ public final LogSink createSink(OrganizationName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -657,6 +783,12 @@ public final LogSink createSink(ProjectName parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource in which to create the sink: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -680,6 +812,12 @@ public final LogSink createSink(String parent, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -710,6 +848,12 @@ public final UnaryCallable createSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -740,6 +884,12 @@ public final LogSink updateSink(LogSinkName sinkName, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -767,6 +917,12 @@ public final LogSink updateSink(String sinkName, LogSink sink) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -807,6 +963,12 @@ public final LogSink updateSink(LogSinkName sinkName, LogSink sink, FieldMask up * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -847,6 +1009,12 @@ public final LogSink updateSink(String sinkName, LogSink sink, FieldMask updateM * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -875,6 +1043,12 @@ public final UnaryCallable updateSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to delete, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -899,6 +1073,12 @@ public final Empty deleteSink(LogSinkName sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param sink_name Required. The full resource name of the sink to delete, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" @@ -920,6 +1100,12 @@ public final Empty deleteSink(String sinkName) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -944,6 +1130,12 @@ public final UnaryCallable deleteSinkCallable() { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -963,6 +1155,12 @@ public final ListExclusionsPagedResponse listExclusions(BillingAccountName paren * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -982,6 +1180,12 @@ public final ListExclusionsPagedResponse listExclusions(FolderName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1001,6 +1205,12 @@ public final ListExclusionsPagedResponse listExclusions(OrganizationName parent) * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1020,6 +1230,12 @@ public final ListExclusionsPagedResponse listExclusions(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource whose exclusions are to be listed. *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1036,6 +1252,12 @@ public final ListExclusionsPagedResponse listExclusions(String parent) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -1071,6 +1293,12 @@ public final ListExclusionsPagedResponse listExclusions(ListExclusionsRequest re * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1093,6 +1321,12 @@ public final LogExclusion getExclusion(LogExclusionName name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1112,6 +1346,12 @@ public final LogExclusion getExclusion(String name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -1136,6 +1376,12 @@ public final UnaryCallable getExclusionCallab * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1160,6 +1406,12 @@ public final LogExclusion createExclusion(BillingAccountName parent, LogExclusio * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1184,6 +1436,12 @@ public final LogExclusion createExclusion(FolderName parent, LogExclusion exclus * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1208,6 +1466,12 @@ public final LogExclusion createExclusion(OrganizationName parent, LogExclusion * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1232,6 +1496,12 @@ public final LogExclusion createExclusion(ProjectName parent, LogExclusion exclu * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The parent resource in which to create the exclusion: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -1253,6 +1523,12 @@ public final LogExclusion createExclusion(String parent, LogExclusion exclusion) * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -1277,6 +1553,12 @@ public final UnaryCallable createExclusion * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The resource name of the exclusion to update: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1310,6 +1592,12 @@ public final LogExclusion updateExclusion( * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The resource name of the exclusion to update: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1343,6 +1631,12 @@ public final LogExclusion updateExclusion( * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -1366,6 +1660,12 @@ public final UnaryCallable updateExclusion * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion to delete: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1388,6 +1688,12 @@ public final Empty deleteExclusion(LogExclusionName name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. The resource name of an existing exclusion to delete: *

"projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" @@ -1407,6 +1713,12 @@ public final Empty deleteExclusion(String name) { * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -1436,6 +1748,12 @@ public final UnaryCallable deleteExclusionCallabl * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -1476,6 +1794,12 @@ public final UnaryCallable getCmekSettings * *

Sample code: * + *

{@code
+   * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java index d50f10ebce..6ce1717123 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Client.java +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -155,6 +155,12 @@ public LoggingServiceV2Stub getStub() { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param log_name Required. The resource name of the log to delete: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" @@ -179,6 +185,12 @@ public final Empty deleteLog(LogName logName) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param log_name Required. The resource name of the log to delete: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" @@ -200,6 +212,12 @@ public final Empty deleteLog(String logName) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -228,6 +246,12 @@ public final UnaryCallable deleteLogCallable() { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param log_name Optional. A default log resource name that is assigned to all log entries in * `entries` that do not specify a value for `log_name`: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" @@ -292,6 +316,12 @@ public final WriteLogEntriesResponse writeLogEntries( * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param log_name Optional. A default log resource name that is assigned to all log entries in * `entries` that do not specify a value for `log_name`: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" @@ -356,6 +386,12 @@ public final WriteLogEntriesResponse writeLogEntries( * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -385,6 +421,12 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param resource_names Required. Names of one or more parent resources from which to retrieve * log entries: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" @@ -422,6 +464,12 @@ public final ListLogEntriesPagedResponse listLogEntries( * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -461,6 +509,12 @@ public final ListLogEntriesPagedResponse listLogEntries(ListLogEntriesRequest re * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -500,6 +554,12 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -520,6 +580,12 @@ public final ListLogsPagedResponse listLogs(BillingAccountName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -540,6 +606,12 @@ public final ListLogsPagedResponse listLogs(FolderName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -560,6 +632,12 @@ public final ListLogsPagedResponse listLogs(OrganizationName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -580,6 +658,12 @@ public final ListLogsPagedResponse listLogs(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name that owns the logs: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" @@ -597,6 +681,12 @@ public final ListLogsPagedResponse listLogs(String parent) { * *

Sample code: * + *

{@code
+   * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java index 09761c6979..e3d59680f4 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -150,6 +150,12 @@ public MetricsServiceV2Stub getStub() { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The name of the project containing the metrics: *

"projects/[PROJECT_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -168,6 +174,12 @@ public final ListLogMetricsPagedResponse listLogMetrics(ProjectName parent) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The name of the project containing the metrics: *

"projects/[PROJECT_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -183,6 +195,12 @@ public final ListLogMetricsPagedResponse listLogMetrics(String parent) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -218,6 +236,12 @@ public final ListLogMetricsPagedResponse listLogMetrics(ListLogMetricsRequest re * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the desired metric: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -236,6 +260,12 @@ public final LogMetric getLogMetric(LogMetricName metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the desired metric: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -252,6 +282,12 @@ public final LogMetric getLogMetric(String metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -275,6 +311,12 @@ public final UnaryCallable getLogMetricCallable( * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name of the project in which to create the metric: *

"projects/[PROJECT_ID]" *

The new metric must be provided in the request. @@ -297,6 +339,12 @@ public final LogMetric createLogMetric(ProjectName parent, LogMetric metric) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name of the project in which to create the metric: *

"projects/[PROJECT_ID]" *

The new metric must be provided in the request. @@ -316,6 +364,12 @@ public final LogMetric createLogMetric(String parent, LogMetric metric) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -339,6 +393,12 @@ public final UnaryCallable createLogMetricCal * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to update: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" *

The updated metric must be provided in the request and it's `name` field must be the @@ -362,6 +422,12 @@ public final LogMetric updateLogMetric(LogMetricName metricName, LogMetric metri * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to update: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" *

The updated metric must be provided in the request and it's `name` field must be the @@ -382,6 +448,12 @@ public final LogMetric updateLogMetric(String metricName, LogMetric metric) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -405,6 +477,12 @@ public final UnaryCallable updateLogMetricCal * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to delete: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -423,6 +501,12 @@ public final Empty deleteLogMetric(LogMetricName metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param metric_name Required. The resource name of the metric to delete: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -439,6 +523,12 @@ public final Empty deleteLogMetric(String metricName) { * *

Sample code: * + *

{@code
+   * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index d04354c29b..abca20f3ca 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -190,6 +190,12 @@ public final OperationsClient getOperationsClient() { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -218,6 +224,12 @@ public final ListInstancesPagedResponse listInstances(LocationName parent) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for paged unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -243,6 +255,12 @@ public final ListInstancesPagedResponse listInstances(String parent) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary paged rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -297,6 +315,12 @@ public final UnaryCallable listInst * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -316,6 +340,12 @@ public final Instance getInstance(InstanceName name) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Hold for pure unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -332,6 +362,12 @@ public final Instance getInstance(String name) { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary default rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -366,6 +402,12 @@ public final UnaryCallable getInstanceCallable() { * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @param instance_id Required. The logical name of the Redis instance in the customer project @@ -409,6 +451,12 @@ public final OperationFuture createInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. * @param instance_id Required. The logical name of the Redis instance in the customer project @@ -452,6 +500,12 @@ public final OperationFuture createInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -513,6 +567,12 @@ public final UnaryCallable createInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param update_mask Required. Mask of fields to update. At least one path must be supplied in * this field. The elements of the repeated paths field may only include these fields from * [Instance][google.cloud.redis.v1.Instance]: @@ -537,6 +597,12 @@ public final OperationFuture updateInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -580,6 +646,12 @@ public final UnaryCallable updateInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -602,6 +674,12 @@ public final OperationFuture upgradeInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -621,6 +699,12 @@ public final OperationFuture upgradeInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -662,6 +746,12 @@ public final UnaryCallable upgradeInstanceCal * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -687,6 +777,12 @@ public final OperationFuture importInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -739,6 +835,12 @@ public final UnaryCallable importInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -763,6 +865,12 @@ public final OperationFuture exportInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -809,6 +917,12 @@ public final UnaryCallable exportInstanceCalla * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -833,6 +947,12 @@ public final OperationFuture failoverInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -857,6 +977,12 @@ public final OperationFuture failoverInstanceAsync( * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ @@ -894,6 +1020,12 @@ public final UnaryCallable failoverInstanceC * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -913,6 +1045,12 @@ public final OperationFuture deleteInstanceAsync(Insta * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for lro Unary rpc method sample code.
+   * }
+   * }
+ * * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. @@ -929,6 +1067,12 @@ public final OperationFuture deleteInstanceAsync(Strin * *

Sample code: * + *

{@code
+   * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
+   *   // Note: Not Implement yet. Holder for unary lro rpc method sample code.
+   * }
+   * }
+ * * @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 */ From 0571bbc132bc9937fc47829b11407e41cb92145d Mon Sep 17 00:00:00 2001 From: summerji Date: Tue, 17 Nov 2020 16:01:09 -0800 Subject: [PATCH 11/11] add license --- .../composer/SampleCodeHelperComposer.java | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java diff --git a/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java b/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java new file mode 100644 index 0000000000..d3d7c86967 --- /dev/null +++ b/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java @@ -0,0 +1,149 @@ +// Copyright 2020 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 +// +// http://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.generator.gapic.composer; + +import com.google.api.generator.engine.ast.AssignmentExpr; +import com.google.api.generator.engine.ast.CommentStatement; +import com.google.api.generator.engine.ast.LineComment; +import com.google.api.generator.engine.ast.MethodInvocationExpr; +import com.google.api.generator.engine.ast.TryCatchStatement; +import com.google.api.generator.engine.ast.TypeNode; +import com.google.api.generator.engine.ast.Variable; +import com.google.api.generator.engine.ast.VariableExpr; +import com.google.api.generator.gapic.model.Method; +import com.google.api.generator.gapic.model.MethodArgument; +import com.google.api.generator.gapic.utils.JavaStyle; +import java.util.Arrays; +import java.util.List; + +public final class SampleCodeHelperComposer { + + public static TryCatchStatement composeRpcMethodSampleCode( + Method method, List arguments, TypeNode clientType) { + // Default Unary RPC method. + if (arguments.isEmpty()) { + return composeUnaryRpcDefaultMethodSampleCode(method, clientType); + } + // Paged Unary RPC method. + if (method.isPaged()) { + return composePagedUnaryRpcMethodSampleCode(method, arguments, clientType); + } + // Long run operation Unary RPC method. + if (method.hasLro()) { + return composeLroUnaryRpcMethodSampleCode(method, arguments, clientType); + } + // Pure Unary RPC method. + return composeUnaryRpcMethodSampleCode(method, arguments, clientType); + } + + private static TryCatchStatement composeUnaryRpcMethodSampleCode( + Method method, List arguments, TypeNode clientType) { + // TODO(summerji): compose sample code for unary rpc method. + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody( + Arrays.asList( + createLineCommentStatement( + "Note: Not Implement yet. Hold for pure unary rpc method sample code."))) + .setIsSampleCode(true) + .build(); + } + + private static TryCatchStatement composeLroUnaryRpcMethodSampleCode( + Method method, List arguments, TypeNode clientType) { + // TODO(summerji): compose sample code for unary lro rpc method. + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody( + Arrays.asList( + createLineCommentStatement( + "Note: Not Implement yet. Holder for lro Unary rpc method sample code."))) + .setIsSampleCode(true) + .build(); + } + + private static TryCatchStatement composePagedUnaryRpcMethodSampleCode( + Method method, List arguments, TypeNode clientType) { + // TODO(summerji): compose sample code for unary paged rpc method. + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody( + Arrays.asList( + createLineCommentStatement( + "Note: Not Implement yet. Holder for paged unary rpc method sample code."))) + .setIsSampleCode(true) + .build(); + } + + private static TryCatchStatement composeUnaryRpcDefaultMethodSampleCode( + Method method, TypeNode clientType) { + // TODO(summerji): compose sample code for unary default rpc method. + String content = + String.format( + "Note: Not Implement yet. Holder for unary %s rpc method sample code.", + (!method.hasLro() && !method.isPaged() + ? "default" + : (method.hasLro() ? "lro" : "paged"))); + return TryCatchStatement.builder() + .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) + .setTryBody(Arrays.asList(createLineCommentStatement(content))) + .setIsSampleCode(true) + .build(); + } + + // ==================================Helpers===================================================// + + // Assign client variable expr with create client. + // e.g EchoClient echoClient = EchoClient.create() + private static AssignmentExpr assignClientVariableWithCreateMethodExpr(TypeNode clientType) { + return AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(getClientName(clientType), clientType)) + .setValueExpr( + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setReturnType(clientType) + .setMethodName("create") + .build()) + .build(); + } + + private static String getClientName(TypeNode clientType) { + return JavaStyle.toLowerCamelCase(clientType.reference().name()); + } + + private static CommentStatement createLineCommentStatement(String content) { + return CommentStatement.withComment(LineComment.withComment(content)); + } + + private static VariableExpr createVariableExpr(String variableName, TypeNode type) { + return createVariableExpr(variableName, type, false); + } + + private static VariableExpr createVariableDeclExpr(String variableName, TypeNode type) { + return createVariableExpr(variableName, type, true); + } + + private static VariableExpr createVariableExpr( + String variableName, TypeNode type, boolean isDecl) { + return VariableExpr.builder() + .setVariable(createVariable(variableName, type)) + .setIsDecl(isDecl) + .build(); + } + + private static Variable createVariable(String varName, TypeNode type) { + return Variable.builder().setName(varName).setType(type).build(); + } +}