From f80c33d5201b333bebe1aced4c255fb4e67912a1 Mon Sep 17 00:00:00 2001 From: summerji Date: Wed, 18 Nov 2020 17:35:46 -0800 Subject: [PATCH] Implement unary callable rpc menthod's samplecode --- .../composer/SampleCodeHelperComposer.java | 60 ++++++++++++++- .../gapic/composer/goldens/EchoClient.golden | 9 ++- .../composer/goldens/IdentityClient.golden | 26 ++++++- .../goldens/asset/AssetServiceClient.java | 31 ++++++-- .../logging/ConfigServiceV2Client.java | 75 ++++++++++++++++--- .../logging/LoggingServiceV2Client.java | 20 ++++- .../logging/MetricsServiceV2Client.java | 30 +++++++- .../goldens/redis/CloudRedisClient.java | 5 +- 8 files changed, 221 insertions(+), 35 deletions(-) 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 index 99aa9061d6..cd80e263c0 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/SampleCodeHelperComposer.java @@ -653,12 +653,64 @@ private static TryCatchStatement composeLroRpcCallableMethodSampleCode( private static TryCatchStatement composeUnaryRpcCallableMethodSampleCode( Method method, TypeNode clientType, Map resourceNames) { + // TODO (summerji): Add unit test. + // If variant method signatures exists, use the first one. + List arguments = + method.methodSignatures().isEmpty() + ? Collections.emptyList() + : method.methodSignatures().get(0); + // Assign method argument with default values. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // Create request variable with set attributes based on method argument. + bodyStatements.add( + ExprStatement.withExpr(createRequestBuilderExpr(method.inputType(), arguments))); + // Create ApiFuture variable with invoking client method callable method by passing the request. + TypeNode apiFutureType = + TypeNode.withReference( + ConcreteReference.builder() + .setClazz(ApiFuture.class) + .setGenerics(method.outputType().reference()) + .build()); + VariableExpr apiFutureVarExpr = createVariableExpr(FUTURE, apiFutureType); + MethodInvocationExpr callableMethodInvocationExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr( + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(getCallableMethodName(method.name())) + .build()) + .setMethodName("futureCall") + .setReturnType(apiFutureType) + .setArguments(createVariableExpr(REQUEST, method.inputType())) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(apiFutureVarExpr.toBuilder().setIsDecl(true).build()) + .setValueExpr(callableMethodInvocationExpr) + .build())); + // Create response variable by assigning future.get() method. + MethodInvocationExpr futureGetMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(apiFutureVarExpr) + .setMethodName("get") + .setReturnType(method.outputType()) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(RESPONSE, method.outputType())) + .setValueExpr(futureGetMethodExpr) + .build())); return TryCatchStatement.builder() .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) - .setTryBody( - Arrays.asList( - createLineCommentStatement( - "Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code."))) + .setTryBody(bodyStatements) .setIsSampleCode(true) .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 315fab6742..0149f76652 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 @@ -306,7 +306,10 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   ResourceName parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoRequest request = EchoRequest.newBuilder().setParent(parent).build();
+   *   ApiFuture future = echoClient.echoCallable().futureCall(request);
+   *   EchoResponse response = future.get();
    * }
    * }
*/ @@ -597,7 +600,9 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   BlockRequest request = BlockRequest.newBuilder().build();
+   *   ApiFuture future = echoClient.blockCallable().futureCall(request);
+   *   BlockResponse response = future.get();
    * }
    * }
*/ 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 e454bc7dbe..3cad790404 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 @@ -230,7 +230,17 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   String parent = "parent-995424086";
+   *   String display_name = "display_name1615086568";
+   *   String email = "email96619420";
+   *   CreateUserRequest request =
+   *       CreateUserRequest.newBuilder()
+   *           .setParent(parent)
+   *           .setDisplayName(display_name)
+   *           .setEmail(email)
+   *           .build();
+   *   ApiFuture future = identityClient.createUserCallable().futureCall(request);
+   *   User response = future.get();
    * }
    * }
*/ @@ -302,7 +312,10 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   UserName name = UserName.of("[USER]");
+   *   GetUserRequest request = GetUserRequest.newBuilder().setName(name).build();
+   *   ApiFuture future = identityClient.getUserCallable().futureCall(request);
+   *   User response = future.get();
    * }
    * }
*/ @@ -334,7 +347,9 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   UpdateUserRequest request = UpdateUserRequest.newBuilder().build();
+   *   ApiFuture future = identityClient.updateUserCallable().futureCall(request);
+   *   User response = future.get();
    * }
    * }
*/ @@ -408,7 +423,10 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   UserName name = UserName.of("[USER]");
+   *   DeleteUserRequest request = DeleteUserRequest.newBuilder().setName(name).build();
+   *   ApiFuture future = identityClient.deleteUserCallable().futureCall(request);
+   *   Empty response = future.get();
    * }
    * }
*/ diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index 43cbe6093f..bff5c6105f 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -274,7 +274,10 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder().build();
+   *   ApiFuture future =
+   *       assetServiceClient.batchGetAssetsHistoryCallable().futureCall(request);
+   *   BatchGetAssetsHistoryResponse response = future.get();
    * }
    * }
*/ @@ -336,7 +339,10 @@ public final Feed createFeed(CreateFeedRequest request) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   String parent = "parent-995424086";
+   *   CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent(parent).build();
+   *   ApiFuture future = assetServiceClient.createFeedCallable().futureCall(request);
+   *   Feed response = future.get();
    * }
    * }
*/ @@ -420,7 +426,10 @@ public final Feed getFeed(GetFeedRequest request) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   GetFeedRequest request = GetFeedRequest.newBuilder().setName(name).build();
+   *   ApiFuture future = assetServiceClient.getFeedCallable().futureCall(request);
+   *   Feed response = future.get();
    * }
    * }
*/ @@ -480,7 +489,11 @@ public final ListFeedsResponse listFeeds(ListFeedsRequest request) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   String parent = "parent-995424086";
+   *   ListFeedsRequest request = ListFeedsRequest.newBuilder().setParent(parent).build();
+   *   ApiFuture future =
+   *       assetServiceClient.listFeedsCallable().futureCall(request);
+   *   ListFeedsResponse response = future.get();
    * }
    * }
*/ @@ -540,7 +553,10 @@ public final Feed updateFeed(UpdateFeedRequest request) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   Feed feed = Feed.newBuilder().build();
+   *   UpdateFeedRequest request = UpdateFeedRequest.newBuilder().setFeed(feed).build();
+   *   ApiFuture future = assetServiceClient.updateFeedCallable().futureCall(request);
+   *   Feed response = future.get();
    * }
    * }
*/ @@ -626,7 +642,10 @@ public final Empty deleteFeed(DeleteFeedRequest request) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   DeleteFeedRequest request = DeleteFeedRequest.newBuilder().setName(name).build();
+   *   ApiFuture future = assetServiceClient.deleteFeedCallable().futureCall(request);
+   *   Empty response = future.get();
    * }
    * }
*/ diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java index dd89f0c15f..23da46e48e 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -416,7 +416,9 @@ public final LogBucket getBucket(GetBucketRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   GetBucketRequest request = GetBucketRequest.newBuilder().build();
+   *   ApiFuture future = configServiceV2Client.getBucketCallable().futureCall(request);
+   *   LogBucket response = future.get();
    * }
    * }
*/ @@ -470,7 +472,10 @@ public final LogBucket updateBucket(UpdateBucketRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   UpdateBucketRequest request = UpdateBucketRequest.newBuilder().build();
+   *   ApiFuture future =
+   *       configServiceV2Client.updateBucketCallable().futureCall(request);
+   *   LogBucket response = future.get();
    * }
    * }
*/ @@ -780,7 +785,10 @@ public final LogSink getSink(GetSinkRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(sink_name).build();
+   *   ApiFuture future = configServiceV2Client.getSinkCallable().futureCall(request);
+   *   LogSink response = future.get();
    * }
    * }
*/ @@ -992,7 +1000,12 @@ public final LogSink createSink(CreateSinkRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   CreateSinkRequest request =
+   *       CreateSinkRequest.newBuilder().setParent(parent).setSink(sink).build();
+   *   ApiFuture future = configServiceV2Client.createSinkCallable().futureCall(request);
+   *   LogSink response = future.get();
    * }
    * }
*/ @@ -1210,7 +1223,12 @@ public final LogSink updateSink(UpdateSinkRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   UpdateSinkRequest request =
+   *       UpdateSinkRequest.newBuilder().setSinkName(sink_name).setSink(sink).build();
+   *   ApiFuture future = configServiceV2Client.updateSinkCallable().futureCall(request);
+   *   LogSink response = future.get();
    * }
    * }
*/ @@ -1308,7 +1326,10 @@ public final Empty deleteSink(DeleteSinkRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   DeleteSinkRequest request = DeleteSinkRequest.newBuilder().setSinkName(sink_name).build();
+   *   ApiFuture future = configServiceV2Client.deleteSinkCallable().futureCall(request);
+   *   Empty response = future.get();
    * }
    * }
*/ @@ -1621,7 +1642,11 @@ public final LogExclusion getExclusion(GetExclusionRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   GetExclusionRequest request = GetExclusionRequest.newBuilder().setName(name).build();
+   *   ApiFuture future =
+   *       configServiceV2Client.getExclusionCallable().futureCall(request);
+   *   LogExclusion response = future.get();
    * }
    * }
*/ @@ -1819,7 +1844,13 @@ public final LogExclusion createExclusion(CreateExclusionRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   CreateExclusionRequest request =
+   *       CreateExclusionRequest.newBuilder().setParent(parent).setExclusion(exclusion).build();
+   *   ApiFuture future =
+   *       configServiceV2Client.createExclusionCallable().futureCall(request);
+   *   LogExclusion response = future.get();
    * }
    * }
*/ @@ -1947,7 +1978,18 @@ public final LogExclusion updateExclusion(UpdateExclusionRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   UpdateExclusionRequest request =
+   *       UpdateExclusionRequest.newBuilder()
+   *           .setName(name)
+   *           .setExclusion(exclusion)
+   *           .setUpdateMask(update_mask)
+   *           .build();
+   *   ApiFuture future =
+   *       configServiceV2Client.updateExclusionCallable().futureCall(request);
+   *   LogExclusion response = future.get();
    * }
    * }
*/ @@ -2039,7 +2081,10 @@ public final Empty deleteExclusion(DeleteExclusionRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(name).build();
+   *   ApiFuture future = configServiceV2Client.deleteExclusionCallable().futureCall(request);
+   *   Empty response = future.get();
    * }
    * }
*/ @@ -2087,7 +2132,10 @@ public final CmekSettings getCmekSettings(GetCmekSettingsRequest request) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().build();
+   *   ApiFuture future =
+   *       configServiceV2Client.getCmekSettingsCallable().futureCall(request);
+   *   CmekSettings response = future.get();
    * }
    * }
*/ @@ -2145,7 +2193,10 @@ public final CmekSettings updateCmekSettings(UpdateCmekSettingsRequest request) * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   UpdateCmekSettingsRequest request = UpdateCmekSettingsRequest.newBuilder().build();
+   *   ApiFuture future =
+   *       configServiceV2Client.updateCmekSettingsCallable().futureCall(request);
+   *   CmekSettings response = future.get();
    * }
    * }
*/ diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java index 47cfc0ecce..6e7fd562e5 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Client.java +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -239,7 +239,10 @@ public final Empty deleteLog(DeleteLogRequest request) { * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogName log_name = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
+   *   DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(log_name).build();
+   *   ApiFuture future = loggingServiceV2Client.deleteLogCallable().futureCall(request);
+   *   Empty response = future.get();
    * }
    * }
*/ @@ -441,7 +444,20 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogName log_name = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
+   *   MonitoredResource resource = MonitoredResource.newBuilder().build();
+   *   Map labels = new HashMap<>();
+   *   List entries = new ArrayList<>();
+   *   WriteLogEntriesRequest request =
+   *       WriteLogEntriesRequest.newBuilder()
+   *           .setLogName(log_name)
+   *           .setResource(resource)
+   *           .setLabels(labels)
+   *           .setEntries(entries)
+   *           .build();
+   *   ApiFuture future =
+   *       loggingServiceV2Client.writeLogEntriesCallable().futureCall(request);
+   *   WriteLogEntriesResponse response = future.get();
    * }
    * }
*/ diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java index abdff0504a..030e4bb8d8 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -354,7 +354,12 @@ public final LogMetric getLogMetric(GetLogMetricRequest request) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   GetLogMetricRequest request =
+   *       GetLogMetricRequest.newBuilder().setMetricName(metric_name).build();
+   *   ApiFuture future =
+   *       metricsServiceV2Client.getLogMetricCallable().futureCall(request);
+   *   LogMetric response = future.get();
    * }
    * }
*/ @@ -450,7 +455,13 @@ public final LogMetric createLogMetric(CreateLogMetricRequest request) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   CreateLogMetricRequest request =
+   *       CreateLogMetricRequest.newBuilder().setParent(parent).setMetric(metric).build();
+   *   ApiFuture future =
+   *       metricsServiceV2Client.createLogMetricCallable().futureCall(request);
+   *   LogMetric response = future.get();
    * }
    * }
*/ @@ -548,7 +559,13 @@ public final LogMetric updateLogMetric(UpdateLogMetricRequest request) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   UpdateLogMetricRequest request =
+   *       UpdateLogMetricRequest.newBuilder().setMetricName(metric_name).setMetric(metric).build();
+   *   ApiFuture future =
+   *       metricsServiceV2Client.updateLogMetricCallable().futureCall(request);
+   *   LogMetric response = future.get();
    * }
    * }
*/ @@ -634,7 +651,12 @@ public final Empty deleteLogMetric(DeleteLogMetricRequest request) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   DeleteLogMetricRequest request =
+   *       DeleteLogMetricRequest.newBuilder().setMetricName(metric_name).build();
+   *   ApiFuture future =
+   *       metricsServiceV2Client.deleteLogMetricCallable().futureCall(request);
+   *   Empty response = future.get();
    * }
    * }
*/ diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index d5a14046fd..294ac2e43e 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -432,7 +432,10 @@ public final Instance getInstance(GetInstanceRequest request) { * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not implement yet, placeholder for Unary Rpc callable methods' sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   GetInstanceRequest request = GetInstanceRequest.newBuilder().setName(name).build();
+   *   ApiFuture future = cloudRedisClient.getInstanceCallable().futureCall(request);
+   *   Instance response = future.get();
    * }
    * }
*/