|
61 | 61 | import com.google.api.generator.engine.ast.MethodDefinition;
|
62 | 62 | import com.google.api.generator.engine.ast.MethodInvocationExpr;
|
63 | 63 | import com.google.api.generator.engine.ast.NewObjectExpr;
|
| 64 | +import com.google.api.generator.engine.ast.PrimitiveValue; |
64 | 65 | import com.google.api.generator.engine.ast.Reference;
|
65 | 66 | import com.google.api.generator.engine.ast.ReferenceConstructorExpr;
|
66 | 67 | import com.google.api.generator.engine.ast.RelationalOperationExpr;
|
@@ -918,6 +919,22 @@ private List<MethodDefinition> createDefaultHelperAndGetterMethods(
|
918 | 919 | .setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue(service.defaultHost())))
|
919 | 920 | .build());
|
920 | 921 |
|
| 922 | + // Create the getDefaultMtlsEndpoint method. |
| 923 | + returnType = TypeNode.STRING; |
| 924 | + javaMethods.add( |
| 925 | + MethodDefinition.builder() |
| 926 | + .setHeaderCommentStatements( |
| 927 | + SettingsCommentComposer.DEFAULT_SERVICE_MTLS_ENDPOINT_METHOD_COMMENT) |
| 928 | + .setScope(ScopeNode.PUBLIC) |
| 929 | + .setIsStatic(true) |
| 930 | + .setReturnType(returnType) |
| 931 | + .setName("getDefaultMtlsEndpoint") |
| 932 | + .setReturnExpr( |
| 933 | + ValueExpr.withValue( |
| 934 | + StringObjectValue.withValue( |
| 935 | + service.defaultHost().replace(".googleapis.com", ".mtls.googleapis.com")))) |
| 936 | + .build()); |
| 937 | + |
921 | 938 | // Create the getDefaultServiceScopes method.
|
922 | 939 | returnType =
|
923 | 940 | TypeNode.withReference(
|
@@ -1594,6 +1611,21 @@ private static MethodDefinition createNestedClassCreateDefaultMethod(TypeStore t
|
1594 | 1611 | .setArguments(
|
1595 | 1612 | MethodInvocationExpr.builder().setMethodName("getDefaultEndpoint").build())
|
1596 | 1613 | .build());
|
| 1614 | + bodyExprs.add( |
| 1615 | + MethodInvocationExpr.builder() |
| 1616 | + .setExprReferenceExpr(builderVarExpr) |
| 1617 | + .setMethodName("setMtlsEndpoint") |
| 1618 | + .setArguments( |
| 1619 | + MethodInvocationExpr.builder().setMethodName("getDefaultMtlsEndpoint").build()) |
| 1620 | + .build()); |
| 1621 | + bodyExprs.add( |
| 1622 | + MethodInvocationExpr.builder() |
| 1623 | + .setExprReferenceExpr(builderVarExpr) |
| 1624 | + .setMethodName("setSwitchToMtlsEndpointAllowed") |
| 1625 | + .setArguments( |
| 1626 | + ValueExpr.withValue( |
| 1627 | + PrimitiveValue.builder().setType(TypeNode.BOOLEAN).setValue("true").build())) |
| 1628 | + .build()); |
1597 | 1629 | bodyStatements.addAll(
|
1598 | 1630 | bodyExprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList()));
|
1599 | 1631 | bodyStatements.add(EMPTY_LINE_STATEMENT);
|
|
0 commit comments