Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow custom HttpRules for REST LROs #1288

Merged
merged 92 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
4c14e48
fix: Allow custom http bindings for LROs
lqiu96 Jan 31, 2023
8f5e313
fix: Update generator and GAX to support custom HTTP Bindings for ope…
lqiu96 Jan 31, 2023
a693085
fix: Use static Map for custom Operation REST Http Bindings
lqiu96 Jan 31, 2023
f4baa0a
chore: Update golden test cases
lqiu96 Jan 31, 2023
7bde2cf
chore: Update showcase tests
lqiu96 Jan 31, 2023
a3527e1
chore: Update golden ITs
lqiu96 Jan 31, 2023
2e1acbc
chore: Add back origin HttpJsonOperationStub.create() methods
lqiu96 Feb 1, 2023
5f3dfe2
fix(deps): update dependency com.google.auth:google-auth-library-bom …
renovate-bot Jan 31, 2023
d8761bc
doc: Update DEVELOPMENT.md for local development. (#1237)
blakeli0 Feb 1, 2023
d837f97
chore: Create a default mapping in OperationStub
lqiu96 Feb 1, 2023
dfd1e5a
chore: Do not generate custom bindings if there are none
lqiu96 Feb 1, 2023
0a891dc
chore: Update golden units
lqiu96 Feb 1, 2023
51bde57
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Feb 1, 2023
64fc726
chore: Update all test cases
lqiu96 Feb 1, 2023
09031c8
chore: Fix format issues
lqiu96 Feb 1, 2023
568ad44
fix: remove constant operation binding field
lqiu96 Feb 1, 2023
3a72781
chore: Clean up code
lqiu96 Feb 2, 2023
d7d1b12
chore: Resolve sonar comments
lqiu96 Feb 2, 2023
9b050d3
chore: DEVELOPMENT.md formatting fix (#1289)
meltsufin Feb 1, 2023
5b31d41
ci: use java-shared-dependencies in google-cloud-java repository for …
suztomo Feb 1, 2023
316621c
fix(java): initialize netty-shaded at run-time and add reflection con…
mpeddada1 Feb 1, 2023
d8e488f
ci(showcase): disable rest_numeric_enum for showcase testing (#1284)
mpeddada1 Feb 2, 2023
46156e0
chore(main): release 2.15.0 (#1269)
release-please[bot] Feb 2, 2023
8a3ba93
chore(main): release 2.15.1-SNAPSHOT (#1292)
release-please[bot] Feb 2, 2023
1cd51fb
chore: Pin Bazel version to 5.2.0 (#1304)
blakeli0 Feb 8, 2023
ec8ce91
build(deps): bump cryptography from 38.0.3 to 39.0.1 in /.kokoro (#1297)
dependabot[bot] Feb 8, 2023
443adec
chore: (cleanup) removing unused files (#1265)
ddixit14 Feb 8, 2023
c70d183
chore: removing unused Gradle files in api-common-java, gax-java, jav…
suztomo Feb 8, 2023
db34e1d
chore: updated gax-java contribution doc (#1334)
suztomo Feb 8, 2023
5fce328
fix: use pkg_tar from rules_pkg (#1303)
parthea Feb 9, 2023
5af299d
chore: Fix pre-commit. (#1294)
blakeli0 Feb 10, 2023
5f3e732
chore: update CONTRIBUTING.md (#1346)
JoeWang1127 Feb 13, 2023
78c6d89
fix(deps): update dependency io.grpc:grpc-bom to v1.53.0 (#1345)
renovate-bot Feb 13, 2023
472a3ba
chore(deps): update dependency org.apache.maven.plugins:maven-deploy-…
renovate-bot Feb 13, 2023
ebe84cc
chore(deps): update dependency org.apache.maven.plugins:maven-surefir…
renovate-bot Feb 14, 2023
6f8cbe0
chore: add rules_pkg to renovate bot ignoreDeps (#1349)
emmileaf Feb 14, 2023
1ae7726
chore: fix renovate bot ignoreDeps (#1353)
emmileaf Feb 14, 2023
e8d86df
fix(batcher): exceptions in unaryCaller bubble up (#1166)
diegomarquezp Feb 14, 2023
b8afde0
fix(deps): update dependency com.google.auth:google-auth-library-bom …
renovate-bot Feb 15, 2023
445769c
chore(deps): update dependency org.apache.maven.plugins:maven-javadoc…
renovate-bot Feb 15, 2023
9b42094
chore(main): release 2.15.1 (#1339)
release-please[bot] Feb 15, 2023
24dabca
chore: refactoring README and DEVELOPMENT.md (#1351)
suztomo Feb 15, 2023
dc40d5a
chore(main): release 2.15.2-SNAPSHOT (#1358)
release-please[bot] Feb 15, 2023
eeb5665
chore: renovate to group Protobuf artifacts (#1362)
suztomo Feb 15, 2023
40e49da
chore: README.md to explain service_config.proto (#1361)
suztomo Feb 21, 2023
4356783
chore: Telling owlbot to ignore these files & it's a monorepo (#1372)
ddixit14 Feb 22, 2023
9a636bb
fix: Change the default scope of gax from implementation to api in au…
blakeli0 Feb 22, 2023
1b3e292
chore: Update variable name
lqiu96 Feb 2, 2023
a64100f
chore: Fix format issues
lqiu96 Feb 2, 2023
e8fb415
fix: Use HttpRule as Value for Custom Bindings
lqiu96 Feb 22, 2023
09b787c
fix: Use HttpRule as Value for Custom Bindings
lqiu96 Feb 22, 2023
94c00fb
chore: Add comments
lqiu96 Feb 23, 2023
d5453b7
chore: Update tests
lqiu96 Feb 23, 2023
667c3cf
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Feb 23, 2023
e24b42f
fix(deps): update dependency com.google.auth:google-auth-library-bom …
renovate-bot Jan 31, 2023
62edb0e
doc: Update DEVELOPMENT.md for local development. (#1237)
blakeli0 Feb 1, 2023
c2cc0a8
chore: Add tests
lqiu96 Feb 23, 2023
4f9015f
chore: Cleanup files
lqiu96 Feb 23, 2023
c7631ba
chore: Format the files
lqiu96 Feb 23, 2023
674d814
chore: Add NoCredentialsProvider
lqiu96 Feb 23, 2023
52aaa23
chore: Fix sonar comments
lqiu96 Feb 23, 2023
1670957
chore: Add serviceyaml file for parsing for rest showcase tests
lqiu96 Feb 23, 2023
abebe3d
chore: Use service yaml file in test
lqiu96 Feb 23, 2023
0a70fe7
chore: Fix Echo showcase test
lqiu96 Feb 23, 2023
ff142e2
chore: Clean up tests
lqiu96 Feb 23, 2023
3f250ab
chore: Sort the map entry to get a consistent ordering for the test
lqiu96 Feb 24, 2023
71b1244
chore: Update showcase and integration tests
lqiu96 Feb 24, 2023
98c1cfb
chore: Resolve sonar comments
lqiu96 Feb 24, 2023
25acf97
chore: Update comments
lqiu96 Feb 24, 2023
f0a1692
chore: Remove a few public constructors
lqiu96 Feb 24, 2023
85bcf90
chore: test ci
lqiu96 Feb 24, 2023
166f6c4
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Feb 27, 2023
7af9882
chore: Remove the cache for java 8
lqiu96 Feb 27, 2023
a68927e
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Feb 28, 2023
0c4eec3
chore: Update from PR feedback
lqiu96 Feb 28, 2023
da232d2
chore: Update comments
lqiu96 Feb 28, 2023
1f40c11
chore: Fix sonar issue
lqiu96 Feb 28, 2023
88f7961
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Feb 28, 2023
8f7aed0
chore: Fix comment
lqiu96 Feb 28, 2023
31932b1
chore: Update to have multiple additional_bindings
lqiu96 Mar 7, 2023
88487e3
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Mar 7, 2023
4f6e39c
chore: Update grpcrest golden test to include httprule
lqiu96 Mar 8, 2023
8d4d54c
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Mar 9, 2023
9a4f437
chore: HttpJsonOperationsStub's MethodDescriptors are not static
lqiu96 Mar 9, 2023
350b811
chore: Add unit tests for HttpJson Operations logic
lqiu96 Mar 9, 2023
bfe3753
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Mar 9, 2023
1d5d967
chore: Resolve lint issues
lqiu96 Mar 9, 2023
fe6c4c7
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Mar 9, 2023
c15e2b5
chore: Clean up test code
lqiu96 Mar 9, 2023
2c489ff
chore: Resolve pr comments
lqiu96 Mar 10, 2023
78be800
chore: Add VisibleForTesting annotation
lqiu96 Mar 10, 2023
f179078
Merge branch 'main' into main-fix_custom_LRO_httpbindings
lqiu96 Mar 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci-maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ jobs:
with:
java-version: 8
distribution: temurin
cache: maven
- run: java -version
- name: Run tests in Java 8 with the source compiled in Java 11 for gapic-generator-java
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ for gapic-generator-java's Bazel build.

```sh
mvn fmt:format
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ protected List<MethodDefinition> createConstructorMethods(
if (generateOperationsStubLogic(service)) {
secondCtorExprs.addAll(
createOperationsStubInitExpr(
context,
service,
thisExpr,
operationsStubClassVarExpr,
Expand Down Expand Up @@ -758,6 +759,7 @@ protected List<MethodDefinition> createConstructorMethods(
}

protected List<Expr> createOperationsStubInitExpr(
GapicContext context,
Service service,
Expr thisExpr,
VariableExpr operationsStubClassVarExpr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.api.generator.gapic.composer.rest;

import com.google.api.HttpRule;
import com.google.api.core.InternalApi;
import com.google.api.gax.httpjson.ApiMethodDescriptor;
import com.google.api.gax.httpjson.ApiMethodDescriptor.MethodType;
Expand Down Expand Up @@ -63,6 +64,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.protobuf.TypeRegistry;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -73,10 +75,10 @@
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class HttpJsonServiceStubClassComposer extends AbstractTransportServiceStubClassComposer {

private static final HttpJsonServiceStubClassComposer INSTANCE =
new HttpJsonServiceStubClassComposer();

Expand All @@ -89,6 +91,7 @@ public class HttpJsonServiceStubClassComposer extends AbstractTransportServiceSt
.setType(FIXED_REST_TYPESTORE.get(TypeRegistry.class.getSimpleName()))
.build())
.build();
private static final String LRO_NAME_PREFIX = "google.longrunning.Operations";

protected HttpJsonServiceStubClassComposer() {
super(RestContext.instance());
Expand All @@ -109,7 +112,9 @@ private static TypeStore createStaticTypes() {
HttpJsonCallSettings.class,
HttpJsonOperationSnapshot.class,
HttpJsonStubCallableFactory.class,
HttpRule.class,
Map.class,
ImmutableMap.class,
ProtoMessageRequestFormatter.class,
ProtoMessageResponseParser.class,
ProtoRestSerializer.class,
Expand Down Expand Up @@ -1075,6 +1080,7 @@ private List<Expr> getMethodTypeExpr(Method protoMethod) {

@Override
protected List<Expr> createOperationsStubInitExpr(
GapicContext context,
Service service,
Expr thisExpr,
VariableExpr operationsStubClassVarExpr,
Expand All @@ -1089,6 +1095,47 @@ protected List<Expr> createOperationsStubInitExpr(
arguments.add(TYPE_REGISTRY_VAR_EXPR);
}

// If the Service contains custom HttpRules for Operations, we pass a map of the custom rules to
// the Operations Client
Map<String, HttpRule> operationCustomHttpRules = parseOperationsCustomHttpRules(context);
if (operationCustomHttpRules.size() > 0) {
Expr operationCustomHttpBindingsBuilderExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(FIXED_REST_TYPESTORE.get(ImmutableMap.class.getSimpleName()))
.setMethodName("builder")
.setGenerics(
Arrays.asList(
TypeNode.STRING.reference(),
FIXED_REST_TYPESTORE.get(HttpRule.class.getSimpleName()).reference()))
.build();

// Sorting is done to ensure consistent ordering of the entries in the Custom HttpRule Map
for (String selector :
operationCustomHttpRules.keySet().stream().sorted().collect(Collectors.toList())) {
HttpRule httpRule = operationCustomHttpRules.get(selector);
Expr httpRuleBuilderExpr = createHttpRuleExpr(httpRule, true);

operationCustomHttpBindingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(operationCustomHttpBindingsBuilderExpr)
.setMethodName("put")
.setArguments(
Arrays.asList(
ValueExpr.withValue(StringObjectValue.withValue(selector)),
httpRuleBuilderExpr))
.build();
}

operationCustomHttpBindingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(operationCustomHttpBindingsBuilderExpr)
.setMethodName("build")
.setReturnType(FIXED_REST_TYPESTORE.get(ImmutableMap.class.getSimpleName()))
.build();

arguments.add(operationCustomHttpBindingsBuilderExpr);
}

return Collections.singletonList(
AssignmentExpr.builder()
.setVariableExpr(
Expand All @@ -1103,6 +1150,73 @@ protected List<Expr> createOperationsStubInitExpr(
.build());
}

/* Build an Expr that creates an HttpRule. Creates a builder and adds the http verb, custom path, and any additional bindings. `additional_bindings` can only be nested one layer deep, so we only check once */
private Expr createHttpRuleExpr(HttpRule httpRule, boolean checkAdditionalBindings) {
Expr httpRuleBuilderExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(FIXED_REST_TYPESTORE.get(HttpRule.class.getSimpleName()))
.setMethodName("newBuilder")
.build();

httpRuleBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(httpRuleBuilderExpr)
// toLowerCase as the PatternCase result is all uppercase
.setMethodName(setMethodFormat(httpRule.getPatternCase().toString().toLowerCase()))
.setArguments(
ValueExpr.withValue(
StringObjectValue.withValue(getOperationsURIValueFromHttpRule(httpRule))))
.setReturnType(FIXED_REST_TYPESTORE.get(HttpRule.class.getSimpleName()))
.build();

if (checkAdditionalBindings) {
for (HttpRule additionalBindings : httpRule.getAdditionalBindingsList()) {
httpRuleBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(httpRuleBuilderExpr)
.setMethodName("addAdditionalBindings")
.setArguments(Arrays.asList(createHttpRuleExpr(additionalBindings, false)))
.build();
}
}

httpRuleBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(httpRuleBuilderExpr)
.setMethodName("build")
.setReturnType(FIXED_REST_TYPESTORE.get(HttpRule.class.getSimpleName()))
.build();
return httpRuleBuilderExpr;
}

/* Parses the Service Yaml file's for custom HttpRules. Filter the HttpRules for ones that match Operations */
private Map<String, HttpRule> parseOperationsCustomHttpRules(GapicContext context) {
Predicate<HttpRule> predicate = x -> x.getSelector().contains(LRO_NAME_PREFIX);
com.google.api.Service service = context.serviceYamlProto();
if (service == null || service.getHttp() == null) {
return ImmutableMap.of();
}
return service.getHttp().getRulesList().stream()
.filter(predicate)
.collect(Collectors.toMap(HttpRule::getSelector, x -> x));
}

/* This is meant to be used for the OperationsClient Mixin OperationsClient's RPCs are mapped to GET/POST/DELETE and this function only expects those HttpVerbs to be used */
private String getOperationsURIValueFromHttpRule(HttpRule httpRule) {
switch (httpRule.getPatternCase().getNumber()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good if we can provide a reference to the http proto for these mappings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remember to add it in later. I'm not sure if this is the best approach yet, so I haven't been adding any docs or tests yet.

case 2:
return httpRule.getGet();
case 4:
return httpRule.getPost();
case 5:
return httpRule.getDelete();
default:
throw new IllegalArgumentException(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably write some true unit tests for this method and the method above, as the input and output are very easy to mock and verify, but I know they are mostly already covered in the golden unit tests, so as long as we covered all the cases, it's fine to me.
However, this branch couldn't be covered by golden tests, so we should add a unit test for it(by changing the scope of this method to default).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, this branch couldn't be covered by golden tests, so we should add a unit test for it

I'm a bit lost of this part. The Echo goldens for rest should have it right?
https://github.com/googleapis/gapic-generator-java/blob/88487e38f86494e2ba18d4bf7c7f23c6671aeb24/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonEchoStub.golden#L360-L405

"Operations HttpRule should only contain GET/POST/DELETE. Invalid: "
+ httpRule.getSelector());
}
}

@Override
protected List<Statement> createLongRunningClient(Service service, TypeStore typeStore) {
Method pollingMethod = service.operationPollingMethod();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public void setUp() throws Exception {
}

@Test
public void generateServiceClasses() {
public void generateComplianceServiceClasses() {
GapicContext context = RestTestProtoLoader.instance().parseCompliance();
Service echoProtoService = context.services().get(0);
GapicClass clazz = composer.generate(context, echoProtoService);
Service complianceProtoServices = context.services().get(0);
GapicClass clazz = composer.generate(context, complianceProtoServices);

JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Expand All @@ -52,6 +52,19 @@ public void generateServiceClasses() {
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}

@Test
public void generateEchoServiceClasses() {
GapicContext context = RestTestProtoLoader.instance().parseEcho();
Service echoProtoService = context.services().get(0);
GapicClass clazz = composer.generate(context, echoProtoService);

JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "HttpJsonEchoStub.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "HttpJsonEchoStub.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}

@Test
public void
getBindingFieldMethodName_shouldReturnGetFieldListIfTheFieldIsInLastPositionAndIsRepeated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

package com.google.api.generator.gapic.composer.rest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static com.google.common.truth.Truth.assertThat;

import com.google.api.generator.gapic.composer.common.TestProtoLoader;
import com.google.api.generator.gapic.model.GapicContext;
Expand All @@ -26,9 +25,13 @@
import com.google.api.generator.gapic.model.Transport;
import com.google.api.generator.gapic.protoparser.Parser;
import com.google.api.generator.gapic.protoparser.ServiceConfigParser;
import com.google.api.generator.gapic.protoparser.ServiceYamlParser;
import com.google.longrunning.OperationsProto;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.ServiceDescriptor;
import com.google.protobuf.StructProto;
import com.google.showcase.v1beta1.ComplianceOuterClass;
import com.google.showcase.v1beta1.EchoOuterClass;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
Expand All @@ -49,28 +52,71 @@ public static RestTestProtoLoader instance() {
}

public GapicContext parseCompliance() {
FileDescriptor echoFileDescriptor = ComplianceOuterClass.getDescriptor();
FileDescriptor complianceFileDescriptor = ComplianceOuterClass.getDescriptor();
ServiceDescriptor complianceServiceDescriptor = complianceFileDescriptor.getServices().get(0);
assertThat(complianceServiceDescriptor.getName()).isEqualTo("Compliance");

Map<String, Message> messageTypes = Parser.parseMessages(complianceFileDescriptor);
Map<String, ResourceName> resourceNames = Parser.parseResourceNames(complianceFileDescriptor);
Set<ResourceName> outputResourceNames = new HashSet<>();
List<Service> services =
Parser.parseService(
complianceFileDescriptor,
messageTypes,
resourceNames,
Optional.empty(),
outputResourceNames);

String jsonFilename = "showcase_grpc_service_config.json";
Path jsonPath = Paths.get(getTestFilesDirectory(), jsonFilename);
Optional<GapicServiceConfig> configOpt = ServiceConfigParser.parse(jsonPath.toString());
assertThat(configOpt.isPresent()).isTrue();
GapicServiceConfig config = configOpt.get();

return GapicContext.builder()
.setMessages(messageTypes)
.setResourceNames(resourceNames)
.setServices(services)
.setServiceConfig(config)
.setHelperResourceNames(outputResourceNames)
.setTransport(getTransport())
.setRestNumericEnumsEnabled(true)
.build();
}

public GapicContext parseEcho() {
FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor();
ServiceDescriptor echoServiceDescriptor = echoFileDescriptor.getServices().get(0);
assertEquals(echoServiceDescriptor.getName(), "Compliance");
assertThat(echoServiceDescriptor.getName()).isEqualTo("Echo");

String serviceYamlFileName = "showcase_v1beta1.yaml";
Path serviceYamlPath = Paths.get(getTestFilesDirectory(), serviceYamlFileName);
Optional<com.google.api.Service> serviceYamlOpt =
ServiceYamlParser.parse(serviceYamlPath.toString());
assertThat(serviceYamlOpt.isPresent()).isTrue();
com.google.api.Service service = serviceYamlOpt.get();

Map<String, Message> messageTypes = Parser.parseMessages(echoFileDescriptor);
messageTypes.putAll(Parser.parseMessages(OperationsProto.getDescriptor()));
messageTypes.putAll(Parser.parseMessages(StructProto.getDescriptor()));
Map<String, ResourceName> resourceNames = Parser.parseResourceNames(echoFileDescriptor);
Set<ResourceName> outputResourceNames = new HashSet<>();
List<Service> services =
Parser.parseService(
echoFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
echoFileDescriptor, messageTypes, resourceNames, serviceYamlOpt, outputResourceNames);

String jsonFilename = "showcase_grpc_service_config.json";
Path jsonPath = Paths.get(getTestFilesDirectory(), jsonFilename);
Optional<GapicServiceConfig> configOpt = ServiceConfigParser.parse(jsonPath.toString());
assertTrue(configOpt.isPresent());
assertThat(configOpt.isPresent()).isTrue();
GapicServiceConfig config = configOpt.get();

return GapicContext.builder()
.setMessages(messageTypes)
.setResourceNames(resourceNames)
.setServices(services)
.setServiceConfig(config)
.setServiceYamlProto(service)
.setHelperResourceNames(outputResourceNames)
.setTransport(getTransport())
.setRestNumericEnumsEnabled(true)
Expand Down
Loading