GeezerVison is showing github.com — feat: add mtls feature by arithmetic1728 · Pull Request #672 · googleapis/sdk-platform-java
This repository was archived by the owner on Oct 29, 2026. It is now read-only.
feat: add mtls feature
#672
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.golden
(5)
.java
(14)
No extension
(1)
All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
WORKSPACE
Original file line number
Diff line number
Diff line change
Expand Up
@@ -26,7 +26,7 @@ jvm_maven_import_external(
# gapic-generator-java dependencies to match the order in googleapis repository,
# which in its turn, prioritizes actual generated clients runtime dependencies
# over the generator dependencies.
_gax_java_version = "1.64.0 "
_gax_java_version = "1.65.1 "
http_archive(
name = "com_google_api_gax_java",
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -61,6 +61,8 @@ public class SettingsCommentComposer {
toSimpleComment("Returns a builder for the default ExecutorProvider for this service.");
public static final CommentStatement DEFAULT_SERVICE_ENDPOINT_METHOD_COMMENT =
toSimpleComment("Returns the default service endpoint.");
public static final CommentStatement DEFAULT_SERVICE_MTLS_ENDPOINT_METHOD_COMMENT =
toSimpleComment("Returns the default mTLS service endpoint.");
public static final CommentStatement DEFAULT_SERVICE_SCOPES_METHOD_COMMENT =
toSimpleComment("Returns the default service scopes.");
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -61,6 +61,7 @@
import com.google.api.generator.engine.ast.MethodDefinition;
import com.google.api.generator.engine.ast.MethodInvocationExpr;
import com.google.api.generator.engine.ast.NewObjectExpr;
import com.google.api.generator.engine.ast.PrimitiveValue;
import com.google.api.generator.engine.ast.Reference;
import com.google.api.generator.engine.ast.ReferenceConstructorExpr;
import com.google.api.generator.engine.ast.RelationalOperationExpr;
Expand Down
Expand Up
@@ -918,6 +919,22 @@ private List<MethodDefinition> createDefaultHelperAndGetterMethods(
.setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue(service.defaultHost())))
.build());
// Create the getDefaultMtlsEndpoint method.
returnType = TypeNode.STRING;
javaMethods.add(
MethodDefinition.builder()
.setHeaderCommentStatements(
SettingsCommentComposer.DEFAULT_SERVICE_MTLS_ENDPOINT_METHOD_COMMENT)
.setScope(ScopeNode.PUBLIC)
.setIsStatic(true)
.setReturnType(returnType)
.setName("getDefaultMtlsEndpoint")
.setReturnExpr(
ValueExpr.withValue(
StringObjectValue.withValue(
service.defaultHost().replace(".googleapis.com", ".mtls.googleapis.com"))))
.build());
// Create the getDefaultServiceScopes method.
returnType =
TypeNode.withReference(
Expand Down
Expand Up
@@ -1594,6 +1611,21 @@ private static MethodDefinition createNestedClassCreateDefaultMethod(TypeStore t
.setArguments(
MethodInvocationExpr.builder().setMethodName("getDefaultEndpoint").build())
.build());
bodyExprs.add(
MethodInvocationExpr.builder()
.setExprReferenceExpr(builderVarExpr)
.setMethodName("setMtlsEndpoint")
.setArguments(
MethodInvocationExpr.builder().setMethodName("getDefaultMtlsEndpoint").build())
.build());
bodyExprs.add(
MethodInvocationExpr.builder()
.setExprReferenceExpr(builderVarExpr)
.setMethodName("setSwitchToMtlsEndpointAllowed")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.BOOLEAN).setValue("true").build()))
.build());
bodyStatements.addAll(
bodyExprs.stream().map(e -> ExprStatement.withExpr(e)).collect(Collectors.toList()));
bodyStatements.add(EMPTY_LINE_STATEMENT);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -108,6 +108,11 @@ public class DeprecatedServiceStubSettings extends StubSettings<DeprecatedServic
return "localhost:7469";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "localhost:7469";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -225,6 +230,8 @@ public class DeprecatedServiceStubSettings extends StubSettings<DeprecatedServic
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -284,6 +284,11 @@ public class EchoStubSettings extends StubSettings<EchoStubSettings> {
return "localhost:7469";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "localhost:7469";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -461,6 +466,8 @@ public class EchoStubSettings extends StubSettings<EchoStubSettings> {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -428,6 +428,11 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
return "logging.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "logging.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -610,6 +615,8 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -437,6 +437,11 @@ public class PublisherStubSettings extends StubSettings<PublisherStubSettings> {
return "pubsub.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "pubsub.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -651,6 +656,8 @@ public class PublisherStubSettings extends StubSettings<PublisherStubSettings> {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -284,6 +284,11 @@ public class EchoStubSettings extends StubSettings<EchoStubSettings> {
return "localhost:7469";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "localhost:7469";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -462,6 +467,8 @@ public class EchoStubSettings extends StubSettings<EchoStubSettings> {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -375,6 +375,11 @@ public static String getDefaultEndpoint() {
return "cloudasset.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "cloudasset.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -623,6 +628,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -138,6 +138,11 @@ public static String getDefaultEndpoint() {
return "iamcredentials.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "iamcredentials.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -277,6 +282,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -125,6 +125,11 @@ public static String getDefaultEndpoint() {
return "iam-meta-api.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "iam-meta-api.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -250,6 +255,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -645,6 +645,11 @@ public static String getDefaultEndpoint() {
return "cloudkms.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "cloudkms.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -962,6 +967,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -303,6 +303,11 @@ public static String getDefaultEndpoint() {
return "library-example.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "library-example.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -473,6 +478,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -514,6 +514,11 @@ public static String getDefaultEndpoint() {
return "logging.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "logging.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -792,6 +797,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -444,6 +444,11 @@ public static String getDefaultEndpoint() {
return "logging.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "logging.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -626,6 +631,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -212,6 +212,11 @@ public static String getDefaultEndpoint() {
return "logging.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "logging.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -371,6 +376,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -478,6 +478,11 @@ public static String getDefaultEndpoint() {
return "pubsub.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "pubsub.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -711,6 +716,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -242,6 +242,11 @@ public static String getDefaultEndpoint() {
return "pubsub.googleapis.com:443";
}
/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "pubsub.mtls.googleapis.com:443";
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down
Expand Up
@@ -401,6 +406,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);
return initDefaults(builder);
}
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.