Skip to content

Commit

Permalink
fix: fix REST transport client creation generated javadoc sample (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
vam-google authored and emmileaf committed Nov 3, 2022
1 parent 2ebe948 commit 5346eef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected List<CommentStatement> createClassHeaderComments(
ServiceClientHeaderSampleComposer.composeSetEndpointSample(clientType, settingsType);
Sample transportSampleCode =
ServiceClientHeaderSampleComposer.composeTransportSample(
clientType, settingsType, "defaultHttpJsonTransportProviderBuilder");
clientType, settingsType, "newHttpJsonBuilder");
samples.addAll(
Arrays.asList(
classMethodSampleCode, credentialsSampleCode, endpointSampleCode, transportSampleCode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public static Sample composeSetEndpointSample(TypeNode clientType, TypeNode sett
}

public static Sample composeTransportSample(
TypeNode clientType, TypeNode settingsType, String transportProviderMethod) {
TypeNode clientType, TypeNode settingsType, String transportBuilderMethod) {
String settingsName = JavaStyle.toLowerCamelCase(settingsType.reference().name());
String clientName = JavaStyle.toLowerCamelCase(clientType.reference().name());
VariableExpr settingsVarExpr =
Expand All @@ -294,26 +294,11 @@ public static Sample composeTransportSample(
MethodInvocationExpr newBuilderMethodExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(settingsType)
.setMethodName("newBuilder")
.build();
MethodInvocationExpr transportChannelProviderArg =
MethodInvocationExpr.builder()
.setExprReferenceExpr(
MethodInvocationExpr.builder()
.setStaticReferenceType(settingsType)
.setMethodName(transportProviderMethod)
.build())
.setMethodName("build")
.build();
MethodInvocationExpr credentialsMethodExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(newBuilderMethodExpr)
.setArguments(transportChannelProviderArg)
.setMethodName("setTransportChannelProvider")
.setMethodName(transportBuilderMethod)
.build();
MethodInvocationExpr buildMethodExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(credentialsMethodExpr)
.setExprReferenceExpr(newBuilderMethodExpr)
.setReturnType(settingsType)
.setMethodName("build")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ import javax.annotation.Generated;
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* EchoSettings echoSettings =
* EchoSettings.newBuilder()
* .setTransportChannelProvider(
* EchoSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* EchoSettings echoSettings = EchoSettings.newHttpJsonBuilder().build();
* EchoClient echoClient = EchoClient.create(echoSettings);
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ import javax.annotation.Generated;
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* EchoEmpySettings echoEmpySettings =
* EchoEmpySettings.newBuilder()
* .setTransportChannelProvider(
* EchoEmpySettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* EchoEmpySettings echoEmpySettings = EchoEmpySettings.newHttpJsonBuilder().build();
* EchoEmpyClient echoEmpyClient = EchoEmpyClient.create(echoEmpySettings);
* }</pre>
*
Expand Down

0 comments on commit 5346eef

Please sign in to comment.