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 e5bc4643eb..95305eecee 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 @@ -16,9 +16,9 @@ import com.google.api.generator.engine.ast.AssignmentExpr; import com.google.api.generator.engine.ast.CommentStatement; -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.ForStatement; import com.google.api.generator.engine.ast.LineComment; import com.google.api.generator.engine.ast.MethodInvocationExpr; import com.google.api.generator.engine.ast.Statement; @@ -30,14 +30,16 @@ import com.google.api.generator.gapic.model.MethodArgument; import com.google.api.generator.gapic.model.ResourceName; import com.google.api.generator.gapic.utils.JavaStyle; -import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public final class SampleCodeHelperComposer { private static String RESPONSE_VAR_NAME = "response"; + private static String REQUEST_VAR_NAME = "request"; + private static String ASYNC_NAME_PATTERN = "%sAsync"; public static TryCatchStatement composeRpcMethodSampleCode( Method method, @@ -46,15 +48,15 @@ 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()) { - return composePagedUnaryRpcMethodSampleCode(method, arguments, clientType); + return composePagedUnaryRpcMethodSampleCode(method, arguments, clientType, resourceNames); } // Long run operation Unary RPC method. if (method.hasLro()) { - return composeLroUnaryRpcMethodSampleCode(method, arguments, clientType); + return composeLroUnaryRpcMethodSampleCode(method, arguments, clientType, resourceNames); } // Pure Unary RPC method. return composeUnaryRpcMethodSampleCode(method, arguments, clientType, resourceNames); @@ -101,46 +103,150 @@ private static TryCatchStatement composeUnaryRpcMethodSampleCode( } private static TryCatchStatement composeLroUnaryRpcMethodSampleCode( - Method method, List arguments, TypeNode clientType) { + Method method, + List arguments, + TypeNode clientType, + Map resourceNames) { // TODO(summerji): compose sample code for unary lro rpc method. // TODO(summerji): Add unit tests. + // Assign each method arguments with default value. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // Assign response variable with get method. + // e.g EchoResponse response = echoClient.waitAsync().get(); + Expr getResponseMethodExpr = + MethodInvocationExpr.builder() + .setExprReferenceExpr( + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(getLroMethodName(method.name())) + .setArguments(mapMethodArgumentsToVariableExprs(arguments)) + .build()) + .setMethodName("get") + .setReturnType(method.outputType()) + .build(); + bodyStatements.add( + ExprStatement.withExpr( + AssignmentExpr.builder() + .setVariableExpr(createVariableDeclExpr(RESPONSE_VAR_NAME, method.outputType())) + .setValueExpr(getResponseMethodExpr) + .build())); return TryCatchStatement.builder() .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) - .setTryBody( - Arrays.asList( - createLineCommentStatement( - "Note: Not Implement yet, placeholder for lro Unary rpc method sample code."))) + .setTryBody(bodyStatements) .setIsSampleCode(true) .build(); } private static TryCatchStatement composePagedUnaryRpcMethodSampleCode( - Method method, List arguments, TypeNode clientType) { - // TODO(summerji): compose sample code for unary paged rpc method. - // TODO(summerji): Add unit tests. + Method method, + List arguments, + TypeNode clientType, + Map resourceNames) { + // TODO(summerji): Add unit test. + // Assign each method arguments with default value. + List bodyStatements = + arguments.stream() + .map( + methodArg -> + ExprStatement.withExpr( + assignMethodArgumentWithDefaultValue(methodArg, resourceNames))) + .collect(Collectors.toList()); + // For loop client on iterateAll method. + // e.g. for (LoggingServiceV2Client loggingServiceV2Client : + // loggingServiceV2Client.ListLogs(parent).iterateAll()) { + // //doThingsWith(element);} + bodyStatements.add( + ForStatement.builder() + .setLocalVariableExpr(createVariableDeclExpr(getClientName(clientType), clientType)) + .setCollectionExpr(createIteratorAllMethodExpr(method, clientType, arguments)) + .setBody(Arrays.asList(createLineCommentStatement("doThingsWith(element);"))) + .build()); return TryCatchStatement.builder() .setTryResourceExpr(assignClientVariableWithCreateMethodExpr(clientType)) - .setTryBody( - Arrays.asList( - createLineCommentStatement( - "Note: Not Implement yet, placeholder for paged unary rpc method sample code."))) + .setTryBody(bodyStatements) .setIsSampleCode(true) .build(); } 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(); } @@ -161,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() @@ -190,14 +327,37 @@ private static Expr createAssignExprForVariableWithClientMethod( } private static List mapMethodArgumentsToVariableExprs(List arguments) { - return arguments.stream().map(arg -> createVariableExpr(arg.name(), arg.type())).collect( - Collectors.toList()); + return arguments.stream() + .map(arg -> createVariableExpr(arg.name(), arg.type())) + .collect(Collectors.toList()); + } + + private static Expr createIteratorAllMethodExpr( + Method method, TypeNode clientType, List arguments) { + // e.g echoClient.echo(name).iterateAll() + return MethodInvocationExpr.builder() + .setExprReferenceExpr( + MethodInvocationExpr.builder() + .setExprReferenceExpr(createVariableExpr(getClientName(clientType), clientType)) + .setMethodName(method.name()) + .setArguments( + !arguments.isEmpty() + ? mapMethodArgumentsToVariableExprs(arguments) + : Arrays.asList(createVariableExpr("request", method.inputType()))) + .build()) + .setMethodName("iterateAll") + .setReturnType(clientType) + .build(); } private static String getClientName(TypeNode clientType) { return JavaStyle.toLowerCamelCase(clientType.reference().name()); } + private static String getLroMethodName(String methodName) { + return JavaStyle.toLowerCamelCase(String.format(ASYNC_NAME_PATTERN, methodName)); + } + private static CommentStatement createLineCommentStatement(String content) { return CommentStatement.withComment(LineComment.withComment(content)); } 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 887f6f6cef..2bcd681235 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 2cb88527c4..077c35e156 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);
+   *   }
    * }
    * }
* @@ -364,7 +369,8 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   Duration ttl = Duration.newBuilder().build();
+   *   Operation response = echoClient.waitAsync(ttl).get();
    * }
    * }
* @@ -382,7 +388,8 @@ public class EchoClient implements BackgroundResource { * *
{@code
    * try (EchoClient echoClient = EchoClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   Timestamp end_time = Timestamp.newBuilder().build();
+   *   Operation response = echoClient.waitAsync(end_time).get();
    * }
    * }
* @@ -400,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();
    * }
    * }
* @@ -429,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 55dfb989f9..9cea5ba67a 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 c086f9a693..cfa2f86cfc 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);
    * }
    * }
* @@ -577,7 +589,13 @@ public final UnaryCallable deleteFeedCallable() { * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   List asset_types = new ArrayList<>();
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllResources(scope, query, asset_types).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -651,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);
+   *   }
    * }
    * }
* @@ -699,7 +729,12 @@ public final SearchAllResourcesPagedResponse searchAllResources( * *
{@code
    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String scope = "scope109264468";
+   *   String query = "query107944136";
+   *   for (AssetServiceClient assetServiceClient :
+   *       assetServiceClient.SearchAllIamPolicies(scope, query).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -757,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 ed28beeef0..2042747d89 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Client.java +++ b/test/integration/goldens/logging/ConfigServiceV2Client.java @@ -153,7 +153,12 @@ public ConfigServiceV2Stub getStub() { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   BillingAccountLocationName parent =
+   *       BillingAccountLocationName.of("[BILLING_ACCOUNT]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -182,7 +187,11 @@ public final ListBucketsPagedResponse listBuckets(BillingAccountLocationName par * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   FolderLocationName parent = FolderLocationName.of("[FOLDER]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -211,7 +220,11 @@ public final ListBucketsPagedResponse listBuckets(FolderLocationName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -240,7 +253,11 @@ public final ListBucketsPagedResponse listBuckets(LocationName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -269,7 +286,11 @@ public final ListBucketsPagedResponse listBuckets(OrganizationLocationName paren * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListBuckets(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -295,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);
+   *   }
    * }
    * }
* @@ -335,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);
    * }
    * }
* @@ -373,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);
    * }
    * }
* @@ -411,7 +440,11 @@ public final UnaryCallable updateBucketCallable( * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -436,7 +469,11 @@ public final ListSinksPagedResponse listSinks(BillingAccountName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -461,7 +498,11 @@ public final ListSinksPagedResponse listSinks(FolderName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -486,7 +527,11 @@ public final ListSinksPagedResponse listSinks(OrganizationName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -511,7 +556,11 @@ public final ListSinksPagedResponse listSinks(ProjectName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListSinks(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -533,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);
+   *   }
    * }
    * }
* @@ -627,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);
    * }
    * }
* @@ -826,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);
    * }
    * }
* @@ -1033,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);
    * }
    * }
* @@ -1126,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);
    * }
    * }
* @@ -1156,7 +1222,11 @@ public final UnaryCallable deleteSinkCallable() { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -1181,7 +1251,11 @@ public final ListExclusionsPagedResponse listExclusions(BillingAccountName paren * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -1206,7 +1280,11 @@ public final ListExclusionsPagedResponse listExclusions(FolderName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -1231,7 +1309,11 @@ public final ListExclusionsPagedResponse listExclusions(OrganizationName parent) * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -1256,7 +1338,11 @@ public final ListExclusionsPagedResponse listExclusions(ProjectName parent) { * *
{@code
    * try (ConfigServiceV2Client configServiceV2Client = ConfigServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   for (ConfigServiceV2Client configServiceV2Client :
+   *       configServiceV2Client.ListExclusions(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -1278,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);
+   *   }
    * }
    * }
* @@ -1374,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);
    * }
    * }
* @@ -1561,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);
    * }
    * }
* @@ -1675,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);
    * }
    * }
* @@ -1759,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);
    * }
    * }
* @@ -1794,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);
    * }
    * }
* @@ -1840,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 9309a543a7..efd1503cec 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);
    * }
    * }
* @@ -435,7 +448,13 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   List resource_names = new ArrayList<>();
+   *   String filter = "filter-1274492040";
+   *   String order_by = "order_by1234304744";
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogEntries(resource_names, filter, order_by).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -478,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);
+   *   }
    * }
    * }
* @@ -523,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);
+   *   }
    * }
    * }
* @@ -568,7 +604,11 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -594,7 +634,11 @@ public final ListLogsPagedResponse listLogs(BillingAccountName parent) { * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -620,7 +664,11 @@ public final ListLogsPagedResponse listLogs(FolderName parent) { * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -646,7 +694,11 @@ public final ListLogsPagedResponse listLogs(OrganizationName parent) { * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -672,7 +724,11 @@ public final ListLogsPagedResponse listLogs(ProjectName parent) { * *
{@code
    * try (LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   for (LoggingServiceV2Client loggingServiceV2Client :
+   *       loggingServiceV2Client.ListLogs(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -695,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 f072ec6551..bf3fac6f53 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Client.java +++ b/test/integration/goldens/logging/MetricsServiceV2Client.java @@ -152,7 +152,11 @@ public MetricsServiceV2Stub getStub() { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (MetricsServiceV2Client metricsServiceV2Client :
+   *       metricsServiceV2Client.ListLogMetrics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -176,7 +180,11 @@ public final ListLogMetricsPagedResponse listLogMetrics(ProjectName parent) { * *
{@code
    * try (MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   for (MetricsServiceV2Client metricsServiceV2Client :
+   *       metricsServiceV2Client.ListLogMetrics(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -197,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);
+   *   }
    * }
    * }
* @@ -286,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);
    * }
    * }
* @@ -372,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);
    * }
    * }
* @@ -460,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);
    * }
    * }
* @@ -537,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 cf6045a524..e20d84dca2 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -192,7 +192,11 @@ public final OperationsClient getOperationsClient() { * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   for (CloudRedisClient cloudRedisClient :
+   *       cloudRedisClient.ListInstances(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -226,7 +230,11 @@ public final ListInstancesPagedResponse listInstances(LocationName parent) { * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for paged unary rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   for (CloudRedisClient cloudRedisClient :
+   *       cloudRedisClient.ListInstances(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
    * }
    * }
* @@ -257,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);
+   *   }
    * }
    * }
* @@ -366,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);
    * }
    * }
* @@ -406,7 +421,11 @@ public final UnaryCallable getInstanceCallable() { * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   String instance_id = "instance_id-2101995259";
+   *   Instance instance = Instance.newBuilder().build();
+   *   Operation response =
+   *       cloudRedisClient.createInstanceAsync(parent, instance_id, instance).get();
    * }
    * }
* @@ -455,7 +474,11 @@ public final OperationFuture createInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   String parent = "parent-995424086";
+   *   String instance_id = "instance_id-2101995259";
+   *   Instance instance = Instance.newBuilder().build();
+   *   Operation response =
+   *       cloudRedisClient.createInstanceAsync(parent, instance_id, instance).get();
    * }
    * }
* @@ -504,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();
    * }
    * }
* @@ -571,7 +603,9 @@ public final UnaryCallable createInstanceCalla * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   FieldMask update_mask = FieldMask.newBuilder().build();
+   *   Instance instance = Instance.newBuilder().build();
+   *   Operation response = cloudRedisClient.updateInstanceAsync(update_mask, instance).get();
    * }
    * }
* @@ -601,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();
    * }
    * }
* @@ -650,7 +691,9 @@ public final UnaryCallable updateInstanceCalla * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   String redis_version = "redis_version-685310444";
+   *   Operation response = cloudRedisClient.upgradeInstanceAsync(name, redis_version).get();
    * }
    * }
* @@ -678,7 +721,9 @@ public final OperationFuture upgradeInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   String name = "name3373707";
+   *   String redis_version = "redis_version-685310444";
+   *   Operation response = cloudRedisClient.upgradeInstanceAsync(name, redis_version).get();
    * }
    * }
* @@ -703,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();
    * }
    * }
* @@ -750,7 +799,9 @@ public final UnaryCallable upgradeInstanceCal * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   String name = "name3373707";
+   *   InputConfig input_config = InputConfig.newBuilder().build();
+   *   Operation response = cloudRedisClient.importInstanceAsync(name, input_config).get();
    * }
    * }
* @@ -781,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();
    * }
    * }
* @@ -839,7 +894,9 @@ public final UnaryCallable importInstanceCalla * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   String name = "name3373707";
+   *   OutputConfig output_config = OutputConfig.newBuilder().build();
+   *   Operation response = cloudRedisClient.exportInstanceAsync(name, output_config).get();
    * }
    * }
* @@ -869,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();
    * }
    * }
* @@ -921,7 +982,10 @@ public final UnaryCallable exportInstanceCalla * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   FailoverInstanceRequest.DataProtectionMode data_protection_mode =
+   *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
+   *   Operation response = cloudRedisClient.failoverInstanceAsync(name, data_protection_mode).get();
    * }
    * }
* @@ -951,7 +1015,10 @@ public final OperationFuture failoverInstanceAsync( * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   String name = "name3373707";
+   *   FailoverInstanceRequest.DataProtectionMode data_protection_mode =
+   *       FailoverInstanceRequest.DataProtectionMode.forNumber(0);
+   *   Operation response = cloudRedisClient.failoverInstanceAsync(name, data_protection_mode).get();
    * }
    * }
* @@ -981,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();
    * }
    * }
* @@ -1024,7 +1099,8 @@ public final UnaryCallable failoverInstanceC * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
+   *   Operation response = cloudRedisClient.deleteInstanceAsync(name).get();
    * }
    * }
* @@ -1049,7 +1125,8 @@ public final OperationFuture deleteInstanceAsync(Insta * *
{@code
    * try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
-   *   // Note: Not Implement yet, placeholder for lro Unary rpc method sample code.
+   *   String name = "name3373707";
+   *   Operation response = cloudRedisClient.deleteInstanceAsync(name).get();
    * }
    * }
* @@ -1071,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();
    * }
    * }
*