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 e43e2427bd5..95305eeceef 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 @@ -31,6 +31,7 @@ import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.utils.JavaStyle; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -47,7 +48,7 @@ public static TryCatchStatement composeRpcMethodSampleCode( Map resourceNames) { // Default Unary RPC method. if (arguments.isEmpty()) { - return composeUnaryRpcDefaultMethodSampleCode(method, clientType); + return composeUnaryRpcDefaultMethodSampleCode(method, clientType, resourceNames); } // Paged Unary RPC method. if (method.isPaged()) { @@ -174,18 +175,78 @@ private static TryCatchStatement composePagedUnaryRpcMethodSampleCode( } private static TryCatchStatement composeUnaryRpcDefaultMethodSampleCode( - Method method, TypeNode clientType) { + Method method, TypeNode clientType, Map resourceNames) { // TODO(summerji): compose sample code for unary default rpc method. // TODO(summerji): Add unit tests. - String content = - String.format( - "Note: Not Implement yet, placeholder for unary %s rpc method sample code.", - (!method.hasLro() && !method.isPaged() - ? "default" - : (method.hasLro() ? "lro default" : "paged default"))); + // If variant method signatures exists, use the first one. + List arguments = + !method.methodSignatures().isEmpty() + ? method.methodSignatures().get(0) + : Collections.emptyList(); + // Assign each method arguments with default value. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // Assign request variables with set argument attributes. + // e.g EchoRequest + bodyStatements.add( + ExprStatement.withExpr(createRequestBuilderExpr(method.inputType(), arguments))); + + if (method.isPaged()) { + // For loop on invoke client method's iterator with comment. + // e.g. for (EchoClient echoClient : echoClient.PagedExpand(request).iterateAll()) {//..} + bodyStatements.add( + ForStatement.builder() + .setLocalVariableExpr(createVariableDeclExpr(getClientName(clientType), clientType)) + .setCollectionExpr(createIteratorAllMethodExpr(method, clientType, arguments)) + .setBody(Arrays.asList(createLineCommentStatement("doThingsWith(element);"))) + .build()); + } else if (method.hasLro()) { + // Create response variable by invoke client's async method. + // e.g Operation response = EchoClient.waitAsync(request).get(); + Expr getResponseMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr( + MethodInvocationExpr.builder() + .setStaticReferenceType(clientType) + .setMethodName(getLroMethodName(method.name())) + .setArguments( + Arrays.asList(createVariableExpr(REQUEST_VAR_NAME, method.inputType()))) + .build()) + .setMethodName("get") + .setReturnType(method.outputType()) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(RESPONSE_VAR_NAME, method.outputType())) + .setValueExpr(getResponseMethodExpr) + .build())); + } else { + // Create response variable by invoke client's method by passing request. + // e.g. EchoResponse response = echoClient.Echo(request); + Expr invokeMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(method.name()) + .setArguments(createVariableExpr("request", method.inputType())) + .setReturnType(method.outputType()) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(RESPONSE_VAR_NAME, method.outputType())) + .setValueExpr(invokeMethodExpr) + .build())); + } + return TryCatchStatement.builder() .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) - .setTryBody(Arrays.asList(createLineCommentStatement(content))) + .setTryBody(bodyStatements) .setIsSampleCode(true) .build(); } @@ -206,6 +267,37 @@ private static AssignmentExpr assignClientVariableWithCreateMethodExpr(TypeNode .build(); } + // Create request variable by set attributes. + // e.g. EchoRequest request = EchoRequest.newBuilder().setParent(parent).build(); + private static Expr createRequestBuilderExpr( + TypeNode requestType, List arguments) { + MethodInvocationExpr newBuilderExpr = + MethodInvocationExpr.builder() + .setStaticReferenceType(requestType) + .setMethodName("newBuilder") + .build(); + for (MethodArgument arg : arguments) { + newBuilderExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderExpr) + .setMethodName(String.format("set%s", JavaStyle.toUpperCamelCase(arg.name()))) + .setArguments( + VariableExpr.withVariable( + Variable.builder().setName(arg.name()).setType(arg.type()).build())) + .build(); + } + MethodInvocationExpr requestBuildExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr(newBuilderExpr) + .setMethodName("build") + .setReturnType(requestType) + .build(); + return AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr("request", requestType)) + .setValueExpr(requestBuildExpr) + .build(); + } + private static Expr assignMethodArgumentWithDefaultValue( MethodArgument argument, Map resourceNames) { return AssignmentExpr.builder() 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 887f6f6cef4..2bcd6812357 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 @@ -40,6 +40,7 @@ public class ServiceClientSampleCodeComposer { // TODO(summerji): Add unit tests for ServiceClientSampleCodeComposer. + // TODO(summerji): Refactor signatures as sample code context. public static String composeClassHeaderCredentialsSampleCode( TypeNode clientType, TypeNode settingsType) { 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 dc556ad007f..077c35e1567 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 @@ -287,7 +287,9 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   ResourceName parent = FoobarName.ofProjectFoobarName("[PROJECT]", "[FOOBAR]");
+   *   EchoRequest request = EchoRequest.newBuilder().setParent(parent).build();
+   *   EchoResponse response = echoClient.Echo(request);
    * }
    * }
* @@ -334,7 +336,10 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   PagedExpandRequest request = PagedExpandRequest.newBuilder().build();
+   *   for (EchoClient echoClient : echoClient.PagedExpand(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -402,7 +407,9 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   Duration ttl = Duration.newBuilder().build();
+   *   WaitRequest request = WaitRequest.newBuilder().setTtl(ttl).build();
+   *   Operation response = EchoClient.waitAsync(request).get();
    * }
    * }
* @@ -431,7 +438,8 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   BlockRequest request = BlockRequest.newBuilder().build();
+   *   BlockResponse response = echoClient.Block(request);
    * }
    * }
* 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 55dfb989f9a..9cea5ba67a8 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 @@ -204,7 +204,16 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method 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();
+   *   User response = identityClient.CreateUser(request);
    * }
    * }
* @@ -266,7 +275,9 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   UserName name = UserName.of("[USER]");
+   *   GetUserRequest request = GetUserRequest.newBuilder().setName(name).build();
+   *   User response = identityClient.GetUser(request);
    * }
    * }
* @@ -289,7 +300,8 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   UpdateUserRequest request = UpdateUserRequest.newBuilder().build();
+   *   User response = identityClient.UpdateUser(request);
    * }
    * }
* @@ -353,7 +365,9 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   UserName name = UserName.of("[USER]");
+   *   DeleteUserRequest request = DeleteUserRequest.newBuilder().setName(name).build();
+   *   Empty response = identityClient.DeleteUser(request);
    * }
    * }
* @@ -376,7 +390,10 @@ public class IdentityClient implements BackgroundResource { * *
{@code
    * try (IdentityClient identityClient = IdentityClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   ListUsersRequest request = ListUsersRequest.newBuilder().build();
+   *   for (IdentityClient identityClient : identityClient.ListUsers(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index 2e0e5f68726..cfa2f86cfc4 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -170,7 +170,8 @@ public final OperationsClient getOperationsClient() { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   ExportAssetsRequest request = ExportAssetsRequest.newBuilder().build();
+   *   Operation response = AssetServiceClient.exportAssetsAsync(request).get();
    * }
    * }
* @@ -229,7 +230,8 @@ public final UnaryCallable exportAssetsCallable( * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder().build();
+   *   BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(request);
    * }
    * }
* @@ -288,7 +290,9 @@ public final Feed createFeed(String parent) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent(parent).build();
+   *   Feed response = assetServiceClient.CreateFeed(request);
    * }
    * }
* @@ -364,7 +368,9 @@ public final Feed getFeed(String name) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   GetFeedRequest request = GetFeedRequest.newBuilder().setName(name).build();
+   *   Feed response = assetServiceClient.GetFeed(request);
    * }
    * }
* @@ -416,7 +422,9 @@ public final ListFeedsResponse listFeeds(String parent) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   ListFeedsRequest request = ListFeedsRequest.newBuilder().setParent(parent).build();
+   *   ListFeedsResponse response = assetServiceClient.ListFeeds(request);
    * }
    * }
* @@ -468,7 +476,9 @@ public final Feed updateFeed(Feed feed) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   Feed feed = Feed.newBuilder().build();
+   *   UpdateFeedRequest request = UpdateFeedRequest.newBuilder().setFeed(feed).build();
+   *   Feed response = assetServiceClient.UpdateFeed(request);
    * }
    * }
* @@ -546,7 +556,9 @@ public final Empty deleteFeed(String name) { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   DeleteFeedRequest request = DeleteFeedRequest.newBuilder().setName(name).build();
+   *   Empty response = assetServiceClient.DeleteFeed(request);
    * }
    * }
* @@ -657,7 +669,19 @@ public final SearchAllResourcesPagedResponse searchAllResources( * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   List asset_types = new ArrayList<>();
+   *   SearchAllResourcesRequest request =
+   *       SearchAllResourcesRequest.newBuilder()
+   *           .setScope(scope)
+   *           .setQuery(query)
+   *           .setAssetTypes(asset_types)
+   *           .build();
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllResources(scope, query, asset_types).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -768,7 +792,14 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   SearchAllIamPoliciesRequest request =
+   *       SearchAllIamPoliciesRequest.newBuilder().setScope(scope).setQuery(query).build();
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllIamPolicies(scope, query).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* diff --git a/test/integration/goldens/logging/ConfigServiceV2Client.java b/test/integration/goldens/logging/ConfigServiceV2Client.java index 80338abe61f..2042747d895 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -316,7 +316,13 @@ public final ListBucketsPagedResponse listBuckets(String parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   BillingAccountLocationName parent =
+   *       BillingAccountLocationName.of("[BILLING_ACCOUNT]", "[LOCATION]");
+   *   ListBucketsRequest request = ListBucketsRequest.newBuilder().setParent(parent).build();
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -356,7 +362,8 @@ public final UnaryCallable listBucketsC * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   GetBucketRequest request = GetBucketRequest.newBuilder().build();
+   *   LogBucket response = configServiceV2Client.GetBucket(request);
    * }
    * }
* @@ -394,7 +401,8 @@ public final UnaryCallable getBucketCallable() { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   UpdateBucketRequest request = UpdateBucketRequest.newBuilder().build();
+   *   LogBucket response = configServiceV2Client.UpdateBucket(request);
    * }
    * }
* @@ -574,7 +582,12 @@ public final ListSinksPagedResponse listSinks(String parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   ListSinksRequest request = ListSinksRequest.newBuilder().setParent(parent).build();
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -668,7 +681,9 @@ public final LogSink getSink(String sinkName) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(sink_name).build();
+   *   LogSink response = configServiceV2Client.GetSink(request);
    * }
    * }
* @@ -867,7 +882,11 @@ public final LogSink createSink(String parent, LogSink sink) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   CreateSinkRequest request =
+   *       CreateSinkRequest.newBuilder().setParent(parent).setSink(sink).build();
+   *   LogSink response = configServiceV2Client.CreateSink(request);
    * }
    * }
* @@ -1074,7 +1093,11 @@ public final LogSink updateSink(String sinkName, LogSink sink, FieldMask updateM * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   LogSink sink = LogSink.newBuilder().build();
+   *   UpdateSinkRequest request =
+   *       UpdateSinkRequest.newBuilder().setSinkName(sink_name).setSink(sink).build();
+   *   LogSink response = configServiceV2Client.UpdateSink(request);
    * }
    * }
* @@ -1167,7 +1190,9 @@ public final Empty deleteSink(String sinkName) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogSinkName sink_name = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
+   *   DeleteSinkRequest request = DeleteSinkRequest.newBuilder().setSinkName(sink_name).build();
+   *   Empty response = configServiceV2Client.DeleteSink(request);
    * }
    * }
* @@ -1339,7 +1364,12 @@ public final ListExclusionsPagedResponse listExclusions(String parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   ListExclusionsRequest request = ListExclusionsRequest.newBuilder().setParent(parent).build();
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -1435,7 +1465,9 @@ public final LogExclusion getExclusion(String name) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   GetExclusionRequest request = GetExclusionRequest.newBuilder().setName(name).build();
+   *   LogExclusion response = configServiceV2Client.GetExclusion(request);
    * }
    * }
* @@ -1622,7 +1654,11 @@ public final LogExclusion createExclusion(String parent, LogExclusion exclusion) * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   LogExclusion exclusion = LogExclusion.newBuilder().build();
+   *   CreateExclusionRequest request =
+   *       CreateExclusionRequest.newBuilder().setParent(parent).setExclusion(exclusion).build();
+   *   LogExclusion response = configServiceV2Client.CreateExclusion(request);
    * }
    * }
* @@ -1736,7 +1772,16 @@ public final LogExclusion updateExclusion( * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method 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();
+   *   LogExclusion response = configServiceV2Client.UpdateExclusion(request);
    * }
    * }
* @@ -1820,7 +1865,9 @@ public final Empty deleteExclusion(String name) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
+   *   DeleteExclusionRequest request = DeleteExclusionRequest.newBuilder().setName(name).build();
+   *   Empty response = configServiceV2Client.DeleteExclusion(request);
    * }
    * }
* @@ -1855,7 +1902,8 @@ public final UnaryCallable deleteExclusionCallabl * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   GetCmekSettingsRequest request = GetCmekSettingsRequest.newBuilder().build();
+   *   CmekSettings response = configServiceV2Client.GetCmekSettings(request);
    * }
    * }
* @@ -1901,7 +1949,8 @@ public final UnaryCallable getCmekSettings * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   UpdateCmekSettingsRequest request = UpdateCmekSettingsRequest.newBuilder().build();
+   *   CmekSettings response = configServiceV2Client.UpdateCmekSettings(request);
    * }
    * }
* diff --git a/test/integration/goldens/logging/LoggingServiceV2Client.java b/test/integration/goldens/logging/LoggingServiceV2Client.java index 3ef9ab541a6..efd1503cece 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Client.java +++ b/test/integration/goldens/logging/LoggingServiceV2Client.java @@ -216,7 +216,9 @@ public final Empty deleteLog(String logName) { * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogName log_name = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
+   *   DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(log_name).build();
+   *   Empty response = loggingServiceV2Client.DeleteLog(request);
    * }
    * }
* @@ -400,7 +402,18 @@ public final WriteLogEntriesResponse writeLogEntries( * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method 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();
+   *   WriteLogEntriesResponse response = loggingServiceV2Client.WriteLogEntries(request);
    * }
    * }
* @@ -484,7 +497,19 @@ public final ListLogEntriesPagedResponse listLogEntries( * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   List resource_names = new ArrayList<>();
+   *   String filter = "filter-1274492040";
+   *   String order_by = "order_by1234304744";
+   *   ListLogEntriesRequest request =
+   *       ListLogEntriesRequest.newBuilder()
+   *           .setResourceNames(resource_names)
+   *           .setFilter(filter)
+   *           .setOrderBy(order_by)
+   *           .build();
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogEntries(resource_names, filter, order_by).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -529,7 +554,12 @@ public final ListLogEntriesPagedResponse listLogEntries(ListLogEntriesRequest re * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   ListMonitoredResourceDescriptorsRequest request =
+   *       ListMonitoredResourceDescriptorsRequest.newBuilder().build();
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListMonitoredResourceDescriptors(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -721,7 +751,12 @@ public final ListLogsPagedResponse listLogs(String parent) { * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   ListLogsRequest request = ListLogsRequest.newBuilder().setParent(parent).build();
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* diff --git a/test/integration/goldens/logging/MetricsServiceV2Client.java b/test/integration/goldens/logging/MetricsServiceV2Client.java index 5ab7dc6ec80..bf3fac6f539 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -205,7 +205,12 @@ public final ListLogMetricsPagedResponse listLogMetrics(String parent) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(parent).build();
+   *   for (MetricsServiceV2Client metricsServiceV2Client :
+   *       metricsServiceV2Client.ListLogMetrics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -294,7 +299,10 @@ public final LogMetric getLogMetric(String metricName) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   GetLogMetricRequest request =
+   *       GetLogMetricRequest.newBuilder().setMetricName(metric_name).build();
+   *   LogMetric response = metricsServiceV2Client.GetLogMetric(request);
    * }
    * }
* @@ -380,7 +388,11 @@ public final LogMetric createLogMetric(String parent, LogMetric metric) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   CreateLogMetricRequest request =
+   *       CreateLogMetricRequest.newBuilder().setParent(parent).setMetric(metric).build();
+   *   LogMetric response = metricsServiceV2Client.CreateLogMetric(request);
    * }
    * }
* @@ -468,7 +480,11 @@ public final LogMetric updateLogMetric(String metricName, LogMetric metric) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   LogMetric metric = LogMetric.newBuilder().build();
+   *   UpdateLogMetricRequest request =
+   *       UpdateLogMetricRequest.newBuilder().setMetricName(metric_name).setMetric(metric).build();
+   *   LogMetric response = metricsServiceV2Client.UpdateLogMetric(request);
    * }
    * }
* @@ -545,7 +561,10 @@ public final Empty deleteLogMetric(String metricName) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   LogMetricName metric_name = LogMetricName.of("[PROJECT]", "[METRIC]");
+   *   DeleteLogMetricRequest request =
+   *       DeleteLogMetricRequest.newBuilder().setMetricName(metric_name).build();
+   *   Empty response = metricsServiceV2Client.DeleteLogMetric(request);
    * }
    * }
* diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index 7607be4dd77..e20d84dca21 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -265,7 +265,12 @@ public final ListInstancesPagedResponse listInstances(String parent) { * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary paged default rpc method sample code.
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(parent).build();
+   *   for (CloudRedisClient cloudRedisClient :
+   *       cloudRedisClient.ListInstances(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -374,7 +379,9 @@ public final Instance getInstance(String name) { * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary default rpc method sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   GetInstanceRequest request = GetInstanceRequest.newBuilder().setName(name).build();
+   *   Instance response = cloudRedisClient.GetInstance(request);
    * }
    * }
* @@ -520,7 +527,16 @@ public final OperationFuture createInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String instance_id = "instance_id-2101995259";
+   *   Instance instance = Instance.newBuilder().build();
+   *   CreateInstanceRequest request =
+   *       CreateInstanceRequest.newBuilder()
+   *           .setParent(parent)
+   *           .setInstanceId(instance_id)
+   *           .setInstance(instance)
+   *           .build();
+   *   Operation response = CloudRedisClient.createInstanceAsync(request).get();
    * }
    * }
* @@ -619,7 +635,14 @@ public final OperationFuture updateInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   Instance instance = Instance.newBuilder().build();
+   *   UpdateInstanceRequest request =
+   *       UpdateInstanceRequest.newBuilder()
+   *           .setUpdateMask(update_mask)
+   *           .setInstance(instance)
+   *           .build();
+   *   Operation response = CloudRedisClient.updateInstanceAsync(request).get();
    * }
    * }
* @@ -725,7 +748,11 @@ public final OperationFuture upgradeInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   String redis_version = "redis_version-685310444";
+   *   UpgradeInstanceRequest request =
+   *       UpgradeInstanceRequest.newBuilder().setName(name).setRedisVersion(redis_version).build();
+   *   Operation response = CloudRedisClient.upgradeInstanceAsync(request).get();
    * }
    * }
* @@ -805,7 +832,11 @@ public final OperationFuture importInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   String name = "name3373707";
+   *   InputConfig input_config = InputConfig.newBuilder().build();
+   *   ImportInstanceRequest request =
+   *       ImportInstanceRequest.newBuilder().setName(name).setInputConfig(input_config).build();
+   *   Operation response = CloudRedisClient.importInstanceAsync(request).get();
    * }
    * }
* @@ -895,7 +926,11 @@ public final OperationFuture exportInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   String name = "name3373707";
+   *   OutputConfig output_config = OutputConfig.newBuilder().build();
+   *   ExportInstanceRequest request =
+   *       ExportInstanceRequest.newBuilder().setName(name).setOutputConfig(output_config).build();
+   *   Operation response = CloudRedisClient.exportInstanceAsync(request).get();
    * }
    * }
* @@ -1013,7 +1048,15 @@ public final OperationFuture failoverInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   FailoverInstanceRequest.DataProtectionMode data_protection_mode =
+   *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
+   *   FailoverInstanceRequest request =
+   *       FailoverInstanceRequest.newBuilder()
+   *           .setName(name)
+   *           .setDataProtectionMode(data_protection_mode)
+   *           .build();
+   *   Operation response = CloudRedisClient.failoverInstanceAsync(request).get();
    * }
    * }
* @@ -1105,7 +1148,9 @@ public final OperationFuture deleteInstanceAsync(Strin * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for unary lro default rpc method sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(name).build();
+   *   Operation response = CloudRedisClient.deleteInstanceAsync(request).get();
    * }
    * }
*