diff --git a/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java b/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java index c7970e2990..2a0c2a45c4 100644 --- a/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java +++ b/src/main/java/com/google/api/generator/engine/ast/MethodInvocationExpr.java @@ -126,6 +126,9 @@ public MethodInvocationExpr build() { "generics", String.format("method invocation of %s", methodInvocationExpr.methodIdentifier().name())); + // TODO(v2): If type-checking is ever added for arguments, beware of lambdas and their type + // workarounds. + return methodInvocationExpr; } } diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java index 2d1163b5c4..07f583af62 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java @@ -613,13 +613,13 @@ private static Expr createPagedListDescriptorAssignExpr( .setReturnType(returnType) .build(); thenExpr = - MethodInvocationExpr.builder() - .setStaticReferenceType( - TypeNode.withReference(ConcreteReference.withClazz(ImmutableList.class))) - .setGenerics(Arrays.asList(repeatedResponseType.reference())) - .setMethodName("of") - .setReturnType(returnType) - .build(); + MethodInvocationExpr.builder() + .setStaticReferenceType( + TypeNode.withReference(ConcreteReference.withClazz(ImmutableList.class))) + .setGenerics(Arrays.asList(repeatedResponseType.reference())) + .setMethodName("of") + .setReturnType(returnType) + .build(); elseExpr = getResponsesExpr; } // While protobufs should not be null, this null-check is needed to protect against NPEs diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/ServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/common/ServiceClientClassComposer.java index d0afbca0e5..5a38db0562 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/common/ServiceClientClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/common/ServiceClientClassComposer.java @@ -30,7 +30,6 @@ import com.google.api.gax.rpc.ServerStreamingCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.api.generator.engine.ast.AnnotationNode; -import com.google.api.generator.engine.ast.AnonymousClassExpr; import com.google.api.generator.engine.ast.AssignmentExpr; import com.google.api.generator.engine.ast.CastExpr; import com.google.api.generator.engine.ast.ClassDefinition; @@ -38,6 +37,7 @@ 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.LambdaExpr; import com.google.api.generator.engine.ast.MethodDefinition; import com.google.api.generator.engine.ast.MethodInvocationExpr; import com.google.api.generator.engine.ast.NewObjectExpr; @@ -1165,23 +1165,14 @@ private static ClassDefinition createNestedRpcPagedResponseClass( .setClazz(ApiFunction.class) .setGenerics(Arrays.asList(methodPageType.reference(), thisClassType.reference())) .build()); + + // Overrides ApiFunction.apply. + // (https://github.com/googleapis/api-common-java/blob/debf25960dea0367b0d3b5e16d57d76c1d01947e/src/main/java/com/google/api/core/ApiFunction.java). Expr pageToTransformExpr = - AnonymousClassExpr.builder() - .setType(anonClassType) - .setMethods( - Arrays.asList( - MethodDefinition.builder() - .setIsOverride(true) - .setScope(ScopeNode.PUBLIC) - .setReturnType(thisClassType) - .setName("apply") - .setArguments(inputVarExpr.toBuilder().setIsDecl(true).build()) - .setReturnExpr( - NewObjectExpr.builder() - .setType(thisClassType) - .setArguments(inputVarExpr) - .build()) - .build())) + LambdaExpr.builder() + .setArguments(inputVarExpr.toBuilder().setIsDecl(true).build()) + .setReturnExpr( + NewObjectExpr.builder().setType(thisClassType).setArguments(inputVarExpr).build()) .build(); // createAsync method - return expression. @@ -1739,9 +1730,7 @@ private static boolean isProtoEmptyType(TypeNode type) { private static void updateGapicMetadata( GapicContext context, String protoPackage, String javaPackage) { context.updateGapicMetadata( - context - .gapicMetadata() - .toBuilder() + context.gapicMetadata().toBuilder() .setProtoPackage(protoPackage) .setLibraryPackage(javaPackage) .build()); diff --git a/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java index 07ffa34d3b..f079aba780 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposer.java @@ -16,13 +16,12 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.generator.engine.ast.AnonymousClassExpr; import com.google.api.generator.engine.ast.AssignmentExpr; import com.google.api.generator.engine.ast.ConcreteReference; import com.google.api.generator.engine.ast.EnumRefExpr; import com.google.api.generator.engine.ast.Expr; import com.google.api.generator.engine.ast.ExprStatement; +import com.google.api.generator.engine.ast.LambdaExpr; import com.google.api.generator.engine.ast.MethodDefinition; import com.google.api.generator.engine.ast.MethodInvocationExpr; import com.google.api.generator.engine.ast.ScopeNode; @@ -223,7 +222,7 @@ protected Expr createTransportSettingsInitExpr( MethodInvocationExpr.builder() .setExprReferenceExpr(callSettingsBuilderExpr) .setMethodName("setParamsExtractor") - .setArguments(createRequestParamsExtractorAnonClass(method)) + .setArguments(createRequestParamsExtractorClassInstance(method)) .build(); } @@ -255,7 +254,7 @@ protected String getProtoRpcFullMethodName(Service protoService, Method protoMet return String.format("google.iam.v1.IAMPolicy/%s", protoMethod.name()); } - private AnonymousClassExpr createRequestParamsExtractorAnonClass(Method method) { + private LambdaExpr createRequestParamsExtractorClassInstance(Method method) { Preconditions.checkState( method.hasHttpBindings(), String.format("Method %s has no HTTP binding", method.name())); @@ -339,24 +338,13 @@ private AnonymousClassExpr createRequestParamsExtractorAnonClass(Method method) .setReturnType(returnType) .build(); - MethodDefinition extractMethod = - MethodDefinition.builder() - .setIsOverride(true) - .setScope(ScopeNode.PUBLIC) - .setReturnType(returnType) - .setName("extract") - .setArguments(requestVarExpr.toBuilder().setIsDecl(true).build()) - .setBody( - bodyExprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList())) - .setReturnExpr(returnExpr) - .build(); - - TypeNode anonClassType = - TypeNode.withReference( - ConcreteReference.builder() - .setClazz(RequestParamsExtractor.class) - .setGenerics(method.inputType().reference()) - .build()); - return AnonymousClassExpr.builder().setType(anonClassType).setMethods(extractMethod).build(); + // Overrides extract(). + // https://github.com/googleapis/gax-java/blob/8d45d186e36ae97b789a6f89d80ae5213a773b65/gax/src/main/java/com/google/api/gax/rpc/RequestParamsExtractor.java#L55 + return LambdaExpr.builder() + .setArguments(requestVarExpr.toBuilder().setIsDecl(true).build()) + .setBody( + bodyExprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList())) + .setReturnExpr(returnExpr) + .build(); } } diff --git a/src/main/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposer.java index 5ef204d741..2f77f6aa75 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/grpc/MockServiceImplClassComposer.java @@ -354,7 +354,7 @@ private static MethodDefinition createGenericClientStreamingProtoMethodOverride( AssignmentExpr.builder() .setVariableExpr(requestObserverVarExpr.toBuilder().setIsDecl(true).build()) .setValueExpr( - createStreamObserverAnonymousClassExpr( + createStreamObserverClassInstance( protoMethod, returnType, responseObserverVarExpr, @@ -364,7 +364,7 @@ private static MethodDefinition createGenericClientStreamingProtoMethodOverride( .build(); } - private static AnonymousClassExpr createStreamObserverAnonymousClassExpr( + private static AnonymousClassExpr createStreamObserverClassInstance( Method protoMethod, TypeNode classType, VariableExpr responseObserverVarExpr, diff --git a/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java index 1dbae8e302..901dceacc6 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java @@ -24,13 +24,13 @@ import com.google.api.gax.httpjson.ProtoMessageResponseParser; import com.google.api.gax.httpjson.ProtoRestSerializer; import com.google.api.generator.engine.ast.AnnotationNode; -import com.google.api.generator.engine.ast.AnonymousClassExpr; import com.google.api.generator.engine.ast.AssignmentExpr; import com.google.api.generator.engine.ast.ConcreteReference; import com.google.api.generator.engine.ast.EnumRefExpr; import com.google.api.generator.engine.ast.Expr; import com.google.api.generator.engine.ast.ExprStatement; import com.google.api.generator.engine.ast.IfStatement; +import com.google.api.generator.engine.ast.LambdaExpr; import com.google.api.generator.engine.ast.MethodDefinition; import com.google.api.generator.engine.ast.MethodInvocationExpr; import com.google.api.generator.engine.ast.NewObjectExpr; @@ -277,7 +277,7 @@ private List getRequestFormatterExpr(Method protoMethod) { ValueExpr.withValue( StringObjectValue.withValue( protoMethod.httpBindings().patternLowerCamel())), - createFieldsExtractorAnonClass( + createFieldsExtractorClassInstance( protoMethod, extractorVarType, protoMethod.httpBindings().pathParameters(), @@ -303,7 +303,7 @@ private List getRequestFormatterExpr(Method protoMethod) { .apply( "setQueryParamsExtractor", Arrays.asList( - createFieldsExtractorAnonClass( + createFieldsExtractorClassInstance( protoMethod, extractorVarType, protoMethod.httpBindings().queryParameters(), @@ -316,7 +316,7 @@ private List getRequestFormatterExpr(Method protoMethod) { .apply( "setRequestBodyExtractor", Arrays.asList( - createFieldsExtractorAnonClass( + createFieldsExtractorClassInstance( protoMethod, extractorVarType, protoMethod.httpBindings().bodyParameters(), @@ -356,7 +356,7 @@ private List setResponseParserExpr(Method protoMethod) { return Collections.singletonList(expr); } - private Expr createFieldsExtractorAnonClass( + private Expr createFieldsExtractorClassInstance( Method method, TypeNode extractorReturnType, Set httpBindingFieldNames, @@ -495,25 +495,13 @@ private Expr createFieldsExtractorAnonClass( } } - MethodDefinition extractMethod = - MethodDefinition.builder() - .setIsOverride(true) - .setScope(ScopeNode.PUBLIC) - .setReturnType(extractorReturnType) - .setName("extract") - .setArguments(requestVarExpr.toBuilder().setIsDecl(true).build()) - .setBody(bodyStatements) - .setReturnExpr(returnExpr) - .build(); - - TypeNode anonClassType = - TypeNode.withReference( - ConcreteReference.builder() - .setClazz(FieldsExtractor.class) - .setGenerics(method.inputType().reference(), extractorReturnType.reference()) - .build()); - - return AnonymousClassExpr.builder().setType(anonClassType).setMethods(extractMethod).build(); + // Overrides FieldsExtractor + // (https://github.com/googleapis/gax-java/blob/12b18ee255d3fabe13bb3969df40753b29f830d5/gax-httpjson/src/main/java/com/google/api/gax/httpjson/FieldsExtractor.java). + return LambdaExpr.builder() + .setArguments(requestVarExpr.toBuilder().setIsDecl(true).build()) + .setBody(bodyStatements) + .setReturnExpr(returnExpr) + .build(); } private List getHttpMethodTypeExpr(Method protoMethod) { diff --git a/src/test/java/com/google/api/generator/gapic/composer/common/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/common/goldens/EchoClient.golden index 7759efb2f9..3e6735f6bd 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/common/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/common/goldens/EchoClient.golden @@ -1,6 +1,5 @@ package com.google.showcase.v1beta1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -860,14 +859,7 @@ public class EchoClient implements BackgroundResource { ApiFuture futurePage = PagedExpandPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public PagedExpandPagedResponse apply(PagedExpandPage input) { - return new PagedExpandPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new PagedExpandPagedResponse(input), MoreExecutors.directExecutor()); } private PagedExpandPagedResponse(PagedExpandPage page) { @@ -941,12 +933,7 @@ public class EchoClient implements BackgroundResource { SimplePagedExpandPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public SimplePagedExpandPagedResponse apply(SimplePagedExpandPage input) { - return new SimplePagedExpandPagedResponse(input); - } - }, + input -> new SimplePagedExpandPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/src/test/java/com/google/api/generator/gapic/composer/common/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/common/goldens/IdentityClient.golden index 2081b3bd1c..235c0055b6 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/common/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/common/goldens/IdentityClient.golden @@ -1,6 +1,5 @@ package com.google.showcase.v1beta1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -644,14 +643,7 @@ public class IdentityClient implements BackgroundResource { ApiFuture futurePage = ListUsersPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListUsersPagedResponse apply(ListUsersPage input) { - return new ListUsersPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListUsersPagedResponse(input), MoreExecutors.directExecutor()); } private ListUsersPagedResponse(ListUsersPage page) { diff --git a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcPublisherStub.golden b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcPublisherStub.golden index 84cc56d029..b0f6557279 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcPublisherStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcPublisherStub.golden @@ -9,7 +9,6 @@ import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.longrunning.stub.GrpcOperationsStub; @@ -190,65 +189,50 @@ public class GrpcPublisherStub extends PublisherStub { GrpcCallSettings.newBuilder() .setMethodDescriptor(createTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(Topic request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings updateTopicTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateTopicRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic.name", String.valueOf(request.getTopic().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic.name", String.valueOf(request.getTopic().getName())); + return params.build(); }) .build(); GrpcCallSettings publishTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(publishMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(PublishRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings getTopicTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetTopicRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings listTopicsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listTopicsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTopicsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("project", String.valueOf(request.getProject())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("project", String.valueOf(request.getProject())); + return params.build(); }) .build(); GrpcCallSettings @@ -257,13 +241,10 @@ public class GrpcPublisherStub extends PublisherStub { .newBuilder() .setMethodDescriptor(listTopicSubscriptionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTopicSubscriptionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings @@ -271,26 +252,20 @@ public class GrpcPublisherStub extends PublisherStub { GrpcCallSettings.newBuilder() .setMethodDescriptor(listTopicSnapshotsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTopicSnapshotsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings deleteTopicTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteTopicRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings @@ -298,13 +273,10 @@ public class GrpcPublisherStub extends PublisherStub { GrpcCallSettings.newBuilder() .setMethodDescriptor(detachSubscriptionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DetachSubscriptionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); diff --git a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcTestingStub.golden b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcTestingStub.golden index b22b976287..7312b79d37 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcTestingStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcTestingStub.golden @@ -9,7 +9,6 @@ import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.longrunning.stub.GrpcOperationsStub; @@ -186,13 +185,10 @@ public class GrpcTestingStub extends TestingStub { GrpcCallSettings.newBuilder() .setMethodDescriptor(getSessionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetSessionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listSessionsTransportSettings = @@ -203,83 +199,65 @@ public class GrpcTestingStub extends TestingStub { GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteSessionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteSessionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings reportSessionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(reportSessionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ReportSessionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings getTestTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getTestMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetTestRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listTestsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listTestsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTestsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings deleteTestTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteTestMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteTestRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings verifyTestTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(verifyTestMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(VerifyTestRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("answer", String.valueOf(request.getAnswer())); - params.put("foo", String.valueOf(request.getFoo())); - params.put("name", String.valueOf(request.getName())); - params.put( - "test_to_verify.name", String.valueOf(request.getTestToVerify().getName())); - params.put("type", String.valueOf(request.getType())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("answer", String.valueOf(request.getAnswer())); + params.put("foo", String.valueOf(request.getFoo())); + params.put("name", String.valueOf(request.getName())); + params.put( + "test_to_verify.name", String.valueOf(request.getTestToVerify().getName())); + params.put("type", String.valueOf(request.getType())); + return params.build(); }) .build(); diff --git a/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden b/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden index 15b0a124b1..5324f21655 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonComplianceStub.golden @@ -6,7 +6,6 @@ import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.httpjson.ApiMethodDescriptor; -import com.google.api.gax.httpjson.FieldsExtractor; import com.google.api.gax.httpjson.HttpJsonCallSettings; import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; @@ -43,33 +42,23 @@ public class HttpJsonComplianceStub extends ComplianceStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/repeat:body", - new FieldsExtractor>() { - @Override - public Map extract(RepeatRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(RepeatRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - return fields; - } + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; }) .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(RepeatRequest request) { - return ProtoRestSerializer.create() - .toBody("serverVerify", request.getServerVerify()); - } - }) + request -> + ProtoRestSerializer.create() + .toBody("serverVerify", request.getServerVerify())) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -86,35 +75,24 @@ public class HttpJsonComplianceStub extends ComplianceStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/repeat:bodyinfo", - new FieldsExtractor>() { - @Override - public Map extract(RepeatRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(RepeatRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putQueryParam(fields, "name", request.getName()); - serializer.putQueryParam( - fields, "serverVerify", request.getServerVerify()); - return fields; - } + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "name", request.getName()); + serializer.putQueryParam( + fields, "serverVerify", request.getServerVerify()); + return fields; }) .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(RepeatRequest request) { - return ProtoRestSerializer.create().toBody("info", request.getInfo()); - } - }) + request -> ProtoRestSerializer.create().toBody("info", request.getInfo())) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -131,36 +109,24 @@ public class HttpJsonComplianceStub extends ComplianceStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/repeat:query", - new FieldsExtractor>() { - @Override - public Map extract(RepeatRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(RepeatRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putQueryParam(fields, "info", request.getInfo()); - serializer.putQueryParam(fields, "name", request.getName()); - serializer.putQueryParam( - fields, "serverVerify", request.getServerVerify()); - return fields; - } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(RepeatRequest request) { - return null; - } + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "info", request.getInfo()); + serializer.putQueryParam(fields, "name", request.getName()); + serializer.putQueryParam( + fields, "serverVerify", request.getServerVerify()); + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -177,48 +143,36 @@ public class HttpJsonComplianceStub extends ComplianceStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/repeat/{info.fString}/{info.fInt32}/{info.fDouble}/{info.fBool}/{info.fKingdom}:simplepath", - new FieldsExtractor>() { - @Override - public Map extract(RepeatRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - if (request.getInfo().hasFBool()) { - serializer.putPathParam( - fields, "info.fBool", request.getInfo().getFBool()); - } - serializer.putPathParam( - fields, "info.fDouble", request.getInfo().getFDouble()); - serializer.putPathParam( - fields, "info.fInt32", request.getInfo().getFInt32()); - serializer.putPathParam( - fields, "info.fKingdom", request.getInfo().getFKingdom()); + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + if (request.getInfo().hasFBool()) { serializer.putPathParam( - fields, "info.fString", request.getInfo().getFString()); - return fields; + fields, "info.fBool", request.getInfo().getFBool()); } + serializer.putPathParam( + fields, "info.fDouble", request.getInfo().getFDouble()); + serializer.putPathParam( + fields, "info.fInt32", request.getInfo().getFInt32()); + serializer.putPathParam( + fields, "info.fKingdom", request.getInfo().getFKingdom()); + serializer.putPathParam( + fields, "info.fString", request.getInfo().getFString()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(RepeatRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putQueryParam(fields, "info", request.getInfo()); - serializer.putQueryParam(fields, "name", request.getName()); - serializer.putQueryParam( - fields, "serverVerify", request.getServerVerify()); - return fields; - } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(RepeatRequest request) { - return null; - } + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "info", request.getInfo()); + serializer.putQueryParam(fields, "name", request.getName()); + serializer.putQueryParam( + fields, "serverVerify", request.getServerVerify()); + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -235,46 +189,34 @@ public class HttpJsonComplianceStub extends ComplianceStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/repeat/{info.fString=first/*}/{info.fChild.fString=second/*}/bool/{info.fBool}:pathresource", - new FieldsExtractor>() { - @Override - public Map extract(RepeatRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - if (request.getInfo().hasFBool()) { - serializer.putPathParam( - fields, "info.fBool", request.getInfo().getFBool()); - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + if (request.getInfo().hasFBool()) { serializer.putPathParam( - fields, - "info.fChild.fString", - request.getInfo().getFChild().getFString()); - serializer.putPathParam( - fields, "info.fString", request.getInfo().getFString()); - return fields; + fields, "info.fBool", request.getInfo().getFBool()); } + serializer.putPathParam( + fields, + "info.fChild.fString", + request.getInfo().getFChild().getFString()); + serializer.putPathParam( + fields, "info.fString", request.getInfo().getFString()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(RepeatRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putQueryParam(fields, "info", request.getInfo()); - serializer.putQueryParam(fields, "name", request.getName()); - serializer.putQueryParam( - fields, "serverVerify", request.getServerVerify()); - return fields; - } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(RepeatRequest request) { - return null; - } + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "info", request.getInfo()); + serializer.putQueryParam(fields, "name", request.getName()); + serializer.putQueryParam( + fields, "serverVerify", request.getServerVerify()); + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -292,42 +234,30 @@ public class HttpJsonComplianceStub extends ComplianceStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/repeat/{info.fString=first/*}/{info.fChild.fString=second/**}:pathtrailingresource", - new FieldsExtractor>() { - @Override - public Map extract(RepeatRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putPathParam( - fields, - "info.fChild.fString", - request.getInfo().getFChild().getFString()); - serializer.putPathParam( - fields, "info.fString", request.getInfo().getFString()); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "info.fChild.fString", + request.getInfo().getFChild().getFString()); + serializer.putPathParam( + fields, "info.fString", request.getInfo().getFString()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(RepeatRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putQueryParam(fields, "info", request.getInfo()); - serializer.putQueryParam(fields, "name", request.getName()); - serializer.putQueryParam( - fields, "serverVerify", request.getServerVerify()); - return fields; - } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(RepeatRequest request) { - return null; - } + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "info", request.getInfo()); + serializer.putQueryParam(fields, "name", request.getName()); + serializer.putQueryParam( + fields, "serverVerify", request.getServerVerify()); + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() diff --git a/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClient.java b/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClient.java index 85ee1c5686..1860b0cca4 100644 --- a/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClient.java +++ b/test/integration/goldens/asset/com/google/cloud/asset/v1/AssetServiceClient.java @@ -16,7 +16,6 @@ package com.google.cloud.asset.v1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -1453,14 +1452,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListAssetsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListAssetsPagedResponse apply(ListAssetsPage input) { - return new ListAssetsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListAssetsPagedResponse(input), MoreExecutors.directExecutor()); } private ListAssetsPagedResponse(ListAssetsPage page) { @@ -1535,12 +1527,7 @@ public static ApiFuture createAsync( SearchAllResourcesPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public SearchAllResourcesPagedResponse apply(SearchAllResourcesPage input) { - return new SearchAllResourcesPagedResponse(input); - } - }, + input -> new SearchAllResourcesPagedResponse(input), MoreExecutors.directExecutor()); } @@ -1625,12 +1612,7 @@ public static ApiFuture createAsync( SearchAllIamPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public SearchAllIamPoliciesPagedResponse apply(SearchAllIamPoliciesPage input) { - return new SearchAllIamPoliciesPagedResponse(input); - } - }, + input -> new SearchAllIamPoliciesPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/GrpcAssetServiceStub.java b/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/GrpcAssetServiceStub.java index 082fb7fa95..d884f02bf9 100644 --- a/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/GrpcAssetServiceStub.java +++ b/test/integration/goldens/asset/com/google/cloud/asset/v1/stub/GrpcAssetServiceStub.java @@ -26,7 +26,6 @@ import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest; import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse; @@ -257,26 +256,20 @@ protected GrpcAssetServiceStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(exportAssetsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ExportAssetsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings listAssetsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listAssetsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListAssetsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings @@ -285,78 +278,60 @@ public Map extract(ListAssetsRequest request) { .newBuilder() .setMethodDescriptor(batchGetAssetsHistoryMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(BatchGetAssetsHistoryRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings createFeedTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createFeedMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getFeedTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getFeedMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listFeedsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listFeedsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListFeedsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateFeedTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateFeedMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("feed.name", String.valueOf(request.getFeed().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("feed.name", String.valueOf(request.getFeed().getName())); + return params.build(); }) .build(); GrpcCallSettings deleteFeedTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteFeedMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -364,13 +339,10 @@ public Map extract(DeleteFeedRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(searchAllResourcesMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SearchAllResourcesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("scope", String.valueOf(request.getScope())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("scope", String.valueOf(request.getScope())); + return params.build(); }) .build(); GrpcCallSettings @@ -378,13 +350,10 @@ public Map extract(SearchAllResourcesRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(searchAllIamPoliciesMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SearchAllIamPoliciesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("scope", String.valueOf(request.getScope())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("scope", String.valueOf(request.getScope())); + return params.build(); }) .build(); GrpcCallSettings @@ -392,15 +361,12 @@ public Map extract(SearchAllIamPoliciesRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(analyzeIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(AnalyzeIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "analysis_query.scope", - String.valueOf(request.getAnalysisQuery().getScope())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put( + "analysis_query.scope", + String.valueOf(request.getAnalysisQuery().getScope())); + return params.build(); }) .build(); GrpcCallSettings @@ -408,16 +374,12 @@ public Map extract(AnalyzeIamPolicyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(analyzeIamPolicyLongrunningMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - AnalyzeIamPolicyLongrunningRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "analysis_query.scope", - String.valueOf(request.getAnalysisQuery().getScope())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put( + "analysis_query.scope", + String.valueOf(request.getAnalysisQuery().getScope())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/compute/com/google/cloud/compute/v1/AddressesClient.java b/test/integration/goldens/compute/com/google/cloud/compute/v1/AddressesClient.java index 17aa70fee5..eb9db7ce24 100644 --- a/test/integration/goldens/compute/com/google/cloud/compute/v1/AddressesClient.java +++ b/test/integration/goldens/compute/com/google/cloud/compute/v1/AddressesClient.java @@ -16,7 +16,6 @@ package com.google.cloud.compute.v1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -618,12 +617,7 @@ public static ApiFuture createAsync( AggregatedListPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public AggregatedListPagedResponse apply(AggregatedListPage input) { - return new AggregatedListPagedResponse(input); - } - }, + input -> new AggregatedListPagedResponse(input), MoreExecutors.directExecutor()); } @@ -709,14 +703,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListPagedResponse apply(ListPage input) { - return new ListPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListPagedResponse(input), MoreExecutors.directExecutor()); } private ListPagedResponse(ListPage page) { diff --git a/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonAddressesStub.java b/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonAddressesStub.java index 11ebe42475..d8d960d342 100644 --- a/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonAddressesStub.java +++ b/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonAddressesStub.java @@ -25,7 +25,6 @@ import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.httpjson.ApiMethodDescriptor; -import com.google.api.gax.httpjson.FieldsExtractor; import com.google.api.gax.httpjson.HttpJsonCallSettings; import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; @@ -66,55 +65,38 @@ public class HttpJsonAddressesStub extends AddressesStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/compute/v1/projects/{project}/aggregated/addresses", - new FieldsExtractor< - AggregatedListAddressesRequest, Map>() { - @Override - public Map extract( - AggregatedListAddressesRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putPathParam(fields, "project", request.getProject()); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "project", request.getProject()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor< - AggregatedListAddressesRequest, Map>>() { - @Override - public Map> extract( - AggregatedListAddressesRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - if (request.hasFilter()) { - serializer.putQueryParam(fields, "filter", request.getFilter()); - } - if (request.hasIncludeAllScopes()) { - serializer.putQueryParam( - fields, "includeAllScopes", request.getIncludeAllScopes()); - } - if (request.hasMaxResults()) { - serializer.putQueryParam( - fields, "maxResults", request.getMaxResults()); - } - if (request.hasOrderBy()) { - serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); - } - if (request.hasPageToken()) { - serializer.putQueryParam( - fields, "pageToken", request.getPageToken()); - } - return fields; + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + if (request.hasFilter()) { + serializer.putQueryParam(fields, "filter", request.getFilter()); } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(AggregatedListAddressesRequest request) { - return null; + if (request.hasIncludeAllScopes()) { + serializer.putQueryParam( + fields, "includeAllScopes", request.getIncludeAllScopes()); + } + if (request.hasMaxResults()) { + serializer.putQueryParam( + fields, "maxResults", request.getMaxResults()); + } + if (request.hasOrderBy()) { + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); } + if (request.hasPageToken()) { + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + } + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -130,38 +112,26 @@ public String extract(AggregatedListAddressesRequest request) { ProtoMessageRequestFormatter.newBuilder() .setPath( "/compute/v1/projects/{project}/regions/{region}/addresses/{address}", - new FieldsExtractor>() { - @Override - public Map extract(DeleteAddressRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putPathParam(fields, "address", request.getAddress()); - serializer.putPathParam(fields, "project", request.getProject()); - serializer.putPathParam(fields, "region", request.getRegion()); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "address", request.getAddress()); + serializer.putPathParam(fields, "project", request.getProject()); + serializer.putPathParam(fields, "region", request.getRegion()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(DeleteAddressRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - if (request.hasRequestId()) { - serializer.putQueryParam(fields, "requestId", request.getRequestId()); - } - return fields; - } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(DeleteAddressRequest request) { - return null; + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + if (request.hasRequestId()) { + serializer.putQueryParam(fields, "requestId", request.getRequestId()); } + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -177,38 +147,28 @@ public String extract(DeleteAddressRequest request) { ProtoMessageRequestFormatter.newBuilder() .setPath( "/compute/v1/projects/{project}/regions/{region}/addresses", - new FieldsExtractor>() { - @Override - public Map extract(InsertAddressRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putPathParam(fields, "project", request.getProject()); - serializer.putPathParam(fields, "region", request.getRegion()); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "project", request.getProject()); + serializer.putPathParam(fields, "region", request.getRegion()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(InsertAddressRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - if (request.hasRequestId()) { - serializer.putQueryParam(fields, "requestId", request.getRequestId()); - } - return fields; + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + if (request.hasRequestId()) { + serializer.putQueryParam(fields, "requestId", request.getRequestId()); } + return fields; }) .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(InsertAddressRequest request) { - return ProtoRestSerializer.create() - .toBody("addressResource", request.getAddressResource()); - } - }) + request -> + ProtoRestSerializer.create() + .toBody("addressResource", request.getAddressResource())) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() @@ -224,44 +184,32 @@ public String extract(InsertAddressRequest request) { ProtoMessageRequestFormatter.newBuilder() .setPath( "/compute/v1/projects/{project}/regions/{region}/addresses", - new FieldsExtractor>() { - @Override - public Map extract(ListAddressesRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putPathParam(fields, "project", request.getProject()); - serializer.putPathParam(fields, "region", request.getRegion()); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "project", request.getProject()); + serializer.putPathParam(fields, "region", request.getRegion()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor>>() { - @Override - public Map> extract(ListAddressesRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - if (request.hasFilter()) { - serializer.putQueryParam(fields, "filter", request.getFilter()); - } - if (request.hasMaxResults()) { - serializer.putQueryParam(fields, "maxResults", request.getMaxResults()); - } - serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); - if (request.hasPageToken()) { - serializer.putQueryParam(fields, "pageToken", request.getPageToken()); - } - return fields; + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + if (request.hasFilter()) { + serializer.putQueryParam(fields, "filter", request.getFilter()); } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(ListAddressesRequest request) { - return null; + if (request.hasMaxResults()) { + serializer.putQueryParam(fields, "maxResults", request.getMaxResults()); + } + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + if (request.hasPageToken()) { + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); } + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() diff --git a/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonRegionOperationsStub.java b/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonRegionOperationsStub.java index 7e3217b1cb..9d90915792 100644 --- a/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonRegionOperationsStub.java +++ b/test/integration/goldens/compute/com/google/cloud/compute/v1/stub/HttpJsonRegionOperationsStub.java @@ -22,7 +22,6 @@ import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.httpjson.ApiMethodDescriptor; -import com.google.api.gax.httpjson.FieldsExtractor; import com.google.api.gax.httpjson.HttpJsonCallSettings; import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; @@ -58,37 +57,23 @@ public class HttpJsonRegionOperationsStub extends RegionOperationsStub { ProtoMessageRequestFormatter.newBuilder() .setPath( "/compute/v1/projects/{project}/regions/{region}/operations/{operation}", - new FieldsExtractor>() { - @Override - public Map extract(GetRegionOperationRequest request) { - Map fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - serializer.putPathParam(fields, "operation", request.getOperation()); - serializer.putPathParam(fields, "project", request.getProject()); - serializer.putPathParam(fields, "region", request.getRegion()); - return fields; - } + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "operation", request.getOperation()); + serializer.putPathParam(fields, "project", request.getProject()); + serializer.putPathParam(fields, "region", request.getRegion()); + return fields; }) .setQueryParamsExtractor( - new FieldsExtractor< - GetRegionOperationRequest, Map>>() { - @Override - public Map> extract( - GetRegionOperationRequest request) { - Map> fields = new HashMap<>(); - ProtoRestSerializer serializer = - ProtoRestSerializer.create(); - return fields; - } - }) - .setRequestBodyExtractor( - new FieldsExtractor() { - @Override - public String extract(GetRegionOperationRequest request) { - return null; - } + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; }) + .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() diff --git a/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/GrpcIamCredentialsStub.java b/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/GrpcIamCredentialsStub.java index 39e6e722c0..8d57d52a19 100644 --- a/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/GrpcIamCredentialsStub.java +++ b/test/integration/goldens/credentials/com/google/cloud/iam/credentials/v1/stub/GrpcIamCredentialsStub.java @@ -21,7 +21,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.iam.credentials.v1.GenerateAccessTokenRequest; import com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse; @@ -143,13 +142,10 @@ protected GrpcIamCredentialsStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(generateAccessTokenMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GenerateAccessTokenRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -157,39 +153,30 @@ public Map extract(GenerateAccessTokenRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(generateIdTokenMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GenerateIdTokenRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings signBlobTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(signBlobMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SignBlobRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings signJwtTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(signJwtMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SignJwtRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/iam/com/google/iam/v1/stub/GrpcIAMPolicyStub.java b/test/integration/goldens/iam/com/google/iam/v1/stub/GrpcIAMPolicyStub.java index 5b5440bd25..1e19326973 100644 --- a/test/integration/goldens/iam/com/google/iam/v1/stub/GrpcIAMPolicyStub.java +++ b/test/integration/goldens/iam/com/google/iam/v1/stub/GrpcIAMPolicyStub.java @@ -21,7 +21,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.iam.v1.GetIamPolicyRequest; @@ -122,26 +121,20 @@ protected GrpcIAMPolicyStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(setIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings getIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings @@ -149,13 +142,10 @@ public Map extract(GetIamPolicyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(testIamPermissionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(TestIamPermissionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClient.java b/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClient.java index cc3e563cff..f5beb4ea26 100644 --- a/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClient.java +++ b/test/integration/goldens/kms/com/google/cloud/kms/v1/KeyManagementServiceClient.java @@ -16,7 +16,6 @@ package com.google.cloud.kms.v1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -3429,12 +3428,7 @@ public static ApiFuture createAsync( ListKeyRingsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListKeyRingsPagedResponse apply(ListKeyRingsPage input) { - return new ListKeyRingsPagedResponse(input); - } - }, + input -> new ListKeyRingsPagedResponse(input), MoreExecutors.directExecutor()); } @@ -3509,12 +3503,7 @@ public static ApiFuture createAsync( ListCryptoKeysPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListCryptoKeysPagedResponse apply(ListCryptoKeysPage input) { - return new ListCryptoKeysPagedResponse(input); - } - }, + input -> new ListCryptoKeysPagedResponse(input), MoreExecutors.directExecutor()); } @@ -3591,12 +3580,7 @@ public static ApiFuture createAsync( ListCryptoKeyVersionsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListCryptoKeyVersionsPagedResponse apply(ListCryptoKeyVersionsPage input) { - return new ListCryptoKeyVersionsPagedResponse(input); - } - }, + input -> new ListCryptoKeyVersionsPagedResponse(input), MoreExecutors.directExecutor()); } @@ -3679,12 +3663,7 @@ public static ApiFuture createAsync( ListImportJobsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListImportJobsPagedResponse apply(ListImportJobsPage input) { - return new ListImportJobsPagedResponse(input); - } - }, + input -> new ListImportJobsPagedResponse(input), MoreExecutors.directExecutor()); } @@ -3760,12 +3739,7 @@ public static ApiFuture createAsync( ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListLocationsPagedResponse apply(ListLocationsPage input) { - return new ListLocationsPagedResponse(input); - } - }, + input -> new ListLocationsPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/GrpcKeyManagementServiceStub.java b/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/GrpcKeyManagementServiceStub.java index 499771b0f6..b1566ca46c 100644 --- a/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/GrpcKeyManagementServiceStub.java +++ b/test/integration/goldens/kms/com/google/cloud/kms/v1/stub/GrpcKeyManagementServiceStub.java @@ -27,7 +27,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.kms.v1.AsymmetricDecryptRequest; import com.google.cloud.kms.v1.AsymmetricDecryptResponse; @@ -451,13 +450,10 @@ protected GrpcKeyManagementServiceStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(listKeyRingsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListKeyRingsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings @@ -465,13 +461,10 @@ public Map extract(ListKeyRingsRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(listCryptoKeysMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListCryptoKeysRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings @@ -480,13 +473,10 @@ public Map extract(ListCryptoKeysRequest request) { .newBuilder() .setMethodDescriptor(listCryptoKeyVersionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListCryptoKeyVersionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings @@ -494,39 +484,30 @@ public Map extract(ListCryptoKeyVersionsRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(listImportJobsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListImportJobsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getKeyRingTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getKeyRingMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetKeyRingRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings getCryptoKeyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getCryptoKeyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetCryptoKeyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -534,65 +515,50 @@ public Map extract(GetCryptoKeyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(getCryptoKeyVersionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetCryptoKeyVersionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings getPublicKeyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getPublicKeyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetPublicKeyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings getImportJobTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getImportJobMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetImportJobRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings createKeyRingTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createKeyRingMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateKeyRingRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings createCryptoKeyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createCryptoKeyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateCryptoKeyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings @@ -600,13 +566,10 @@ public Map extract(CreateCryptoKeyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(createCryptoKeyVersionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateCryptoKeyVersionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings @@ -614,39 +577,30 @@ public Map extract(CreateCryptoKeyVersionRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(importCryptoKeyVersionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ImportCryptoKeyVersionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings createImportJobTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createImportJobMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateImportJobRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateCryptoKeyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateCryptoKeyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateCryptoKeyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("crypto_key.name", String.valueOf(request.getCryptoKey().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("crypto_key.name", String.valueOf(request.getCryptoKey().getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -654,41 +608,32 @@ public Map extract(UpdateCryptoKeyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(updateCryptoKeyVersionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateCryptoKeyVersionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "crypto_key_version.name", - String.valueOf(request.getCryptoKeyVersion().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put( + "crypto_key_version.name", + String.valueOf(request.getCryptoKeyVersion().getName())); + return params.build(); }) .build(); GrpcCallSettings encryptTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(encryptMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(EncryptRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings decryptTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(decryptMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DecryptRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -696,13 +641,10 @@ public Map extract(DecryptRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(asymmetricSignMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(AsymmetricSignRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -710,13 +652,10 @@ public Map extract(AsymmetricSignRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(asymmetricDecryptMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(AsymmetricDecryptRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -724,14 +663,10 @@ public Map extract(AsymmetricDecryptRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(updateCryptoKeyPrimaryVersionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - UpdateCryptoKeyPrimaryVersionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -739,13 +674,10 @@ public Map extract( GrpcCallSettings.newBuilder() .setMethodDescriptor(destroyCryptoKeyVersionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DestroyCryptoKeyVersionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -753,53 +685,41 @@ public Map extract(DestroyCryptoKeyVersionRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(restoreCryptoKeyVersionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(RestoreCryptoKeyVersionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings getIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings listLocationsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listLocationsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListLocationsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("filter", String.valueOf(request.getFilter())); - params.put("page_size", String.valueOf(request.getPageSize())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("filter", String.valueOf(request.getFilter())); + params.put("page_size", String.valueOf(request.getPageSize())); + return params.build(); }) .build(); GrpcCallSettings getLocationTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getLocationMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetLocationRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -807,13 +727,10 @@ public Map extract(GetLocationRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(testIamPermissionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(TestIamPermissionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClient.java b/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClient.java index df3a63cfff..3a758ad3f9 100644 --- a/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClient.java +++ b/test/integration/goldens/library/com/google/cloud/example/library/v1/LibraryServiceClient.java @@ -16,7 +16,6 @@ package com.google.cloud.example.library.v1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -1361,14 +1360,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListShelvesPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListShelvesPagedResponse apply(ListShelvesPage input) { - return new ListShelvesPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListShelvesPagedResponse(input), MoreExecutors.directExecutor()); } private ListShelvesPagedResponse(ListShelvesPage page) { @@ -1437,14 +1429,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListBooksPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListBooksPagedResponse apply(ListBooksPage input) { - return new ListBooksPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListBooksPagedResponse(input), MoreExecutors.directExecutor()); } private ListBooksPagedResponse(ListBooksPage page) { diff --git a/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/GrpcLibraryServiceStub.java b/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/GrpcLibraryServiceStub.java index 8a5429cefb..d1ff40a058 100644 --- a/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/GrpcLibraryServiceStub.java +++ b/test/integration/goldens/library/com/google/cloud/example/library/v1/stub/GrpcLibraryServiceStub.java @@ -24,7 +24,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.example.library.v1.Book; @@ -217,13 +216,10 @@ protected GrpcLibraryServiceStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(getShelfMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetShelfRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listShelvesTransportSettings = @@ -234,104 +230,80 @@ public Map extract(GetShelfRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteShelfMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteShelfRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings mergeShelvesTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(mergeShelvesMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(MergeShelvesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings createBookTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createBookMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateBookRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getBookTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getBookMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetBookRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listBooksTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listBooksMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListBooksRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings deleteBookTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteBookMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteBookRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings updateBookTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateBookMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateBookRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("book.name", String.valueOf(request.getBook().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("book.name", String.valueOf(request.getBook().getName())); + return params.build(); }) .build(); GrpcCallSettings moveBookTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(moveBookMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(MoveBookRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClient.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClient.java index 2ac4343fd8..2bce0705f4 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClient.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/ConfigClient.java @@ -16,7 +16,6 @@ package com.google.cloud.logging.v2; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -2855,14 +2854,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListBucketsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListBucketsPagedResponse apply(ListBucketsPage input) { - return new ListBucketsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListBucketsPagedResponse(input), MoreExecutors.directExecutor()); } private ListBucketsPagedResponse(ListBucketsPage page) { @@ -2935,14 +2927,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListViewsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListViewsPagedResponse apply(ListViewsPage input) { - return new ListViewsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListViewsPagedResponse(input), MoreExecutors.directExecutor()); } private ListViewsPagedResponse(ListViewsPage page) { @@ -3015,14 +3000,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListSinksPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListSinksPagedResponse apply(ListSinksPage input) { - return new ListSinksPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListSinksPagedResponse(input), MoreExecutors.directExecutor()); } private ListSinksPagedResponse(ListSinksPage page) { @@ -3096,12 +3074,7 @@ public static ApiFuture createAsync( ListExclusionsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListExclusionsPagedResponse apply(ListExclusionsPage input) { - return new ListExclusionsPagedResponse(input); - } - }, + input -> new ListExclusionsPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClient.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClient.java index 66f7afcda2..759c5d2c86 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClient.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/LoggingClient.java @@ -18,7 +18,6 @@ import com.google.api.MonitoredResource; import com.google.api.MonitoredResourceDescriptor; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -1032,12 +1031,7 @@ public static ApiFuture createAsync( ListLogEntriesPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListLogEntriesPagedResponse apply(ListLogEntriesPage input) { - return new ListLogEntriesPagedResponse(input); - } - }, + input -> new ListLogEntriesPagedResponse(input), MoreExecutors.directExecutor()); } @@ -1118,15 +1112,7 @@ public static ApiFuture createAsy .createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction< - ListMonitoredResourceDescriptorsPage, - ListMonitoredResourceDescriptorsPagedResponse>() { - @Override - public ListMonitoredResourceDescriptorsPagedResponse apply( - ListMonitoredResourceDescriptorsPage input) { - return new ListMonitoredResourceDescriptorsPagedResponse(input); - } - }, + input -> new ListMonitoredResourceDescriptorsPagedResponse(input), MoreExecutors.directExecutor()); } @@ -1214,14 +1200,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListLogsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListLogsPagedResponse apply(ListLogsPage input) { - return new ListLogsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListLogsPagedResponse(input), MoreExecutors.directExecutor()); } private ListLogsPagedResponse(ListLogsPage page) { diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClient.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClient.java index 987083a264..e1fdf43653 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClient.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/MetricsClient.java @@ -16,7 +16,6 @@ package com.google.cloud.logging.v2; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -734,12 +733,7 @@ public static ApiFuture createAsync( ListLogMetricsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListLogMetricsPagedResponse apply(ListLogMetricsPage input) { - return new ListLogMetricsPagedResponse(input); - } - }, + input -> new ListLogMetricsPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java index e8e5bf647e..34a747bca2 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcConfigServiceV2Stub.java @@ -26,7 +26,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.logging.v2.CmekSettings; @@ -362,208 +361,160 @@ protected GrpcConfigServiceV2Stub( GrpcCallSettings.newBuilder() .setMethodDescriptor(listBucketsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListBucketsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getBucketTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getBucketMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetBucketRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings createBucketTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createBucketMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateBucketRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateBucketTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateBucketMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateBucketRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings deleteBucketTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteBucketMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteBucketRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings undeleteBucketTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(undeleteBucketMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UndeleteBucketRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listViewsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listViewsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListViewsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getViewTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getViewMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetViewRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings createViewTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createViewMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateViewRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateViewTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateViewMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateViewRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings deleteViewTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteViewMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteViewRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listSinksTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listSinksMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListSinksRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getSinkTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getSinkMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetSinkRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("sink_name", String.valueOf(request.getSinkName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("sink_name", String.valueOf(request.getSinkName())); + return params.build(); }) .build(); GrpcCallSettings createSinkTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createSinkMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateSinkRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateSinkTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateSinkMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateSinkRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("sink_name", String.valueOf(request.getSinkName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("sink_name", String.valueOf(request.getSinkName())); + return params.build(); }) .build(); GrpcCallSettings deleteSinkTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteSinkMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteSinkRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("sink_name", String.valueOf(request.getSinkName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("sink_name", String.valueOf(request.getSinkName())); + return params.build(); }) .build(); GrpcCallSettings @@ -571,91 +522,70 @@ public Map extract(DeleteSinkRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(listExclusionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListExclusionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getExclusionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getExclusionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetExclusionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings createExclusionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createExclusionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateExclusionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateExclusionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateExclusionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateExclusionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings deleteExclusionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteExclusionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteExclusionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings getCmekSettingsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getCmekSettingsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetCmekSettingsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings updateCmekSettingsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateCmekSettingsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateCmekSettingsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java index 80c6b53aea..c7ce0b40f2 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcLoggingServiceV2Stub.java @@ -26,7 +26,6 @@ import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.BidiStreamingCallable; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.logging.v2.DeleteLogRequest; @@ -189,13 +188,10 @@ protected GrpcLoggingServiceV2Stub( GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteLogMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteLogRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("log_name", String.valueOf(request.getLogName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("log_name", String.valueOf(request.getLogName())); + return params.build(); }) .build(); GrpcCallSettings @@ -220,13 +216,10 @@ public Map extract(DeleteLogRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(listLogsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListLogsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings diff --git a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java index 6d5eefc13d..0fda0bb3db 100644 --- a/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java +++ b/test/integration/goldens/logging/com/google/cloud/logging/v2/stub/GrpcMetricsServiceV2Stub.java @@ -23,7 +23,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.logging.v2.CreateLogMetricRequest; @@ -157,65 +156,50 @@ protected GrpcMetricsServiceV2Stub( GrpcCallSettings.newBuilder() .setMethodDescriptor(listLogMetricsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListLogMetricsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getLogMetricTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getLogMetricMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetLogMetricRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("metric_name", String.valueOf(request.getMetricName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("metric_name", String.valueOf(request.getMetricName())); + return params.build(); }) .build(); GrpcCallSettings createLogMetricTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createLogMetricMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateLogMetricRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateLogMetricTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateLogMetricMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateLogMetricRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("metric_name", String.valueOf(request.getMetricName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("metric_name", String.valueOf(request.getMetricName())); + return params.build(); }) .build(); GrpcCallSettings deleteLogMetricTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteLogMetricMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteLogMetricRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("metric_name", String.valueOf(request.getMetricName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("metric_name", String.valueOf(request.getMetricName())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClient.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClient.java index f7b5f91ffe..fa217f1637 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClient.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SchemaServiceClient.java @@ -16,7 +16,6 @@ package com.google.cloud.pubsub.v1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -967,14 +966,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListSchemasPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListSchemasPagedResponse apply(ListSchemasPage input) { - return new ListSchemasPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListSchemasPagedResponse(input), MoreExecutors.directExecutor()); } private ListSchemasPagedResponse(ListSchemasPage page) { diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java index 62855712e7..a6adbe6945 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java @@ -16,7 +16,6 @@ package com.google.cloud.pubsub.v1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -2497,12 +2496,7 @@ public static ApiFuture createAsync( ListSubscriptionsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListSubscriptionsPagedResponse apply(ListSubscriptionsPage input) { - return new ListSubscriptionsPagedResponse(input); - } - }, + input -> new ListSubscriptionsPagedResponse(input), MoreExecutors.directExecutor()); } @@ -2582,12 +2576,7 @@ public static ApiFuture createAsync( ListSnapshotsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListSnapshotsPagedResponse apply(ListSnapshotsPage input) { - return new ListSnapshotsPagedResponse(input); - } - }, + input -> new ListSnapshotsPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClient.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClient.java index 48d61edc58..802fe3e940 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClient.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/TopicAdminClient.java @@ -16,7 +16,6 @@ package com.google.cloud.pubsub.v1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -1309,14 +1308,7 @@ public static ApiFuture createAsync( ApiFuture futurePage = ListTopicsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListTopicsPagedResponse apply(ListTopicsPage input) { - return new ListTopicsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); + futurePage, input -> new ListTopicsPagedResponse(input), MoreExecutors.directExecutor()); } private ListTopicsPagedResponse(ListTopicsPage page) { @@ -1390,12 +1382,7 @@ public static ApiFuture createAsync( ListTopicSubscriptionsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListTopicSubscriptionsPagedResponse apply(ListTopicSubscriptionsPage input) { - return new ListTopicSubscriptionsPagedResponse(input); - } - }, + input -> new ListTopicSubscriptionsPagedResponse(input), MoreExecutors.directExecutor()); } @@ -1475,12 +1462,7 @@ public static ApiFuture createAsync( ListTopicSnapshotsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListTopicSnapshotsPagedResponse apply(ListTopicSnapshotsPage input) { - return new ListTopicSnapshotsPagedResponse(input); - } - }, + input -> new ListTopicSnapshotsPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java index 950b722377..3b4330559f 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcPublisherStub.java @@ -25,7 +25,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.iam.v1.GetIamPolicyRequest; @@ -242,65 +241,50 @@ protected GrpcPublisherStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(createTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(Topic request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings updateTopicTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateTopicRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic.name", String.valueOf(request.getTopic().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic.name", String.valueOf(request.getTopic().getName())); + return params.build(); }) .build(); GrpcCallSettings publishTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(publishMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(PublishRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings getTopicTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetTopicRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings listTopicsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listTopicsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTopicsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("project", String.valueOf(request.getProject())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("project", String.valueOf(request.getProject())); + return params.build(); }) .build(); GrpcCallSettings @@ -309,13 +293,10 @@ public Map extract(ListTopicsRequest request) { .newBuilder() .setMethodDescriptor(listTopicSubscriptionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTopicSubscriptionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings @@ -323,26 +304,20 @@ public Map extract(ListTopicSubscriptionsRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(listTopicSnapshotsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTopicSnapshotsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings deleteTopicTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteTopicMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteTopicRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("topic", String.valueOf(request.getTopic())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("topic", String.valueOf(request.getTopic())); + return params.build(); }) .build(); GrpcCallSettings @@ -350,39 +325,30 @@ public Map extract(DeleteTopicRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(detachSubscriptionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DetachSubscriptionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings setIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(setIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings getIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings @@ -390,13 +356,10 @@ public Map extract(GetIamPolicyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(testIamPermissionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(TestIamPermissionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSchemaServiceStub.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSchemaServiceStub.java index 0ca41b379b..2ec4a27314 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSchemaServiceStub.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSchemaServiceStub.java @@ -23,7 +23,6 @@ import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.iam.v1.GetIamPolicyRequest; @@ -201,52 +200,40 @@ protected GrpcSchemaServiceStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(createSchemaMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateSchemaRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getSchemaTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getSchemaMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetSchemaRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings listSchemasTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listSchemasMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListSchemasRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings deleteSchemaTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteSchemaMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteSchemaRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -254,13 +241,10 @@ public Map extract(DeleteSchemaRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(validateSchemaMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ValidateSchemaRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings @@ -268,39 +252,30 @@ public Map extract(ValidateSchemaRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(validateMessageMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ValidateMessageRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings setIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(setIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings getIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings @@ -308,13 +283,10 @@ public Map extract(GetIamPolicyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(testIamPermissionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(TestIamPermissionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java index 878a2ad7d2..f4da747061 100644 --- a/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java +++ b/test/integration/goldens/pubsub/com/google/cloud/pubsub/v1/stub/GrpcSubscriberStub.java @@ -25,7 +25,6 @@ import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.BidiStreamingCallable; import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; import com.google.iam.v1.GetIamPolicyRequest; @@ -326,40 +325,31 @@ protected GrpcSubscriberStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(createSubscriptionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(Subscription request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings getSubscriptionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getSubscriptionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetSubscriptionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings updateSubscriptionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateSubscriptionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateSubscriptionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "subscription.name", String.valueOf(request.getSubscription().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put( + "subscription.name", String.valueOf(request.getSubscription().getName())); + return params.build(); }) .build(); GrpcCallSettings @@ -367,65 +357,50 @@ public Map extract(UpdateSubscriptionRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(listSubscriptionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListSubscriptionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("project", String.valueOf(request.getProject())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("project", String.valueOf(request.getProject())); + return params.build(); }) .build(); GrpcCallSettings deleteSubscriptionTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteSubscriptionMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteSubscriptionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings modifyAckDeadlineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(modifyAckDeadlineMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ModifyAckDeadlineRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings acknowledgeTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(acknowledgeMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(AcknowledgeRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings pullTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(pullMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(PullRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings streamingPullTransportSettings = @@ -436,117 +411,90 @@ public Map extract(PullRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(modifyPushConfigMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ModifyPushConfigRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings getSnapshotTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getSnapshotMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetSnapshotRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("snapshot", String.valueOf(request.getSnapshot())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("snapshot", String.valueOf(request.getSnapshot())); + return params.build(); }) .build(); GrpcCallSettings listSnapshotsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listSnapshotsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListSnapshotsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("project", String.valueOf(request.getProject())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("project", String.valueOf(request.getProject())); + return params.build(); }) .build(); GrpcCallSettings createSnapshotTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createSnapshotMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateSnapshotRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings updateSnapshotTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateSnapshotMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateSnapshotRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("snapshot.name", String.valueOf(request.getSnapshot().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("snapshot.name", String.valueOf(request.getSnapshot().getName())); + return params.build(); }) .build(); GrpcCallSettings deleteSnapshotTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteSnapshotMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteSnapshotRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("snapshot", String.valueOf(request.getSnapshot())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("snapshot", String.valueOf(request.getSnapshot())); + return params.build(); }) .build(); GrpcCallSettings seekTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(seekMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SeekRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("subscription", String.valueOf(request.getSubscription())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("subscription", String.valueOf(request.getSubscription())); + return params.build(); }) .build(); GrpcCallSettings setIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(setIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings getIamPolicyTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); GrpcCallSettings @@ -554,13 +502,10 @@ public Map extract(GetIamPolicyRequest request) { GrpcCallSettings.newBuilder() .setMethodDescriptor(testIamPermissionsMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(TestIamPermissionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); }) .build(); diff --git a/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/CloudRedisClient.java b/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/CloudRedisClient.java index f62dcd329d..fe918026ed 100644 --- a/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/CloudRedisClient.java +++ b/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/CloudRedisClient.java @@ -16,7 +16,6 @@ package com.google.cloud.redis.v1beta1; -import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; @@ -1463,12 +1462,7 @@ public static ApiFuture createAsync( ListInstancesPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, - new ApiFunction() { - @Override - public ListInstancesPagedResponse apply(ListInstancesPage input) { - return new ListInstancesPagedResponse(input); - } - }, + input -> new ListInstancesPagedResponse(input), MoreExecutors.directExecutor()); } diff --git a/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/GrpcCloudRedisStub.java b/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/GrpcCloudRedisStub.java index 4e6c502571..51347bcfd7 100644 --- a/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/GrpcCloudRedisStub.java +++ b/test/integration/goldens/redis/com/google/cloud/redis/v1beta1/stub/GrpcCloudRedisStub.java @@ -25,7 +25,6 @@ import com.google.api.gax.grpc.GrpcStubCallableFactory; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.redis.v1beta1.CreateInstanceRequest; import com.google.cloud.redis.v1beta1.DeleteInstanceRequest; @@ -220,117 +219,90 @@ protected GrpcCloudRedisStub( GrpcCallSettings.newBuilder() .setMethodDescriptor(listInstancesMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListInstancesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings getInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings createInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); }) .build(); GrpcCallSettings updateInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("instance.name", String.valueOf(request.getInstance().getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("instance.name", String.valueOf(request.getInstance().getName())); + return params.build(); }) .build(); GrpcCallSettings upgradeInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(upgradeInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpgradeInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings importInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(importInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ImportInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings exportInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(exportInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ExportInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings failoverInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(failoverInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(FailoverInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build(); GrpcCallSettings deleteInstanceTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteInstanceMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteInstanceRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); }) .build();