From 0e40f22636269b7db06281fe228cfb50dad2c0d5 Mon Sep 17 00:00:00 2001 From: Riya Mehta Date: Thu, 16 Jan 2025 12:33:19 -0800 Subject: [PATCH] add enum + javadocs. --- .../InstantiatingGrpcChannelProvider.java | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java index 6c94b155b7..3ee6b6fa58 100644 --- a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java +++ b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java @@ -126,12 +126,26 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP @Nullable private final Boolean allowNonDefaultServiceAccount; @VisibleForTesting final ImmutableMap directPathServiceConfig; @Nullable private final MtlsProvider mtlsProvider; - @Nullable private final List allowedHardBoundTokenTypes; + @Nullable private final List allowedHardBoundTokenTypes; @VisibleForTesting final Map headersWithDuplicatesRemoved = new HashMap<>(); @Nullable private final ApiFunction channelConfigurator; + /* + * Experimental feature + * + *

{@link HardBoundTokenTypes} specifies if hard bound tokens should be used if DirectPath + * or S2A is used to estabilsh a connection to Google APIs. + * + */ + public enum HardBoundTokenTypes { + // Use ALTS bound tokens when using DirectPath + ALTS, + // Use MTLS bound tokens when using S2A + MTLS_S2A + } + private InstantiatingGrpcChannelProvider(Builder builder) { this.processorCount = builder.processorCount; this.executor = builder.executor; @@ -622,7 +636,7 @@ public static final class Builder { @Nullable private Boolean attemptDirectPathXds; @Nullable private Boolean allowNonDefaultServiceAccount; @Nullable private ImmutableMap directPathServiceConfig; - @Nullable private List allowedHardBoundTokenTypes; + @Nullable private List allowedHardBoundTokenTypes; private Builder() { processorCount = Runtime.getRuntime().availableProcessors(); @@ -703,8 +717,26 @@ public Builder setEndpoint(String endpoint) { return this; } + /* + * Sets the allowed hard bound token types for this TransportChannelProvider. + * + *

This is optional; if it is not provided, bearer tokens will be used. + * + *

Examples: + * + *

allowedValues is {HardBoundTokenTypes.ALTS}: If DirectPath is used to create the channel, + * use hard ALTS-bound tokens for requests sent on that channel. + * + *

allowedValues is {HardBoundTokenTypes.MTLS_S2A}: If MTLS via S2A is used to create the + * channel, use hard MTLS-bound tokens for requests sent on that channel. + * + *

allowedValues is {HardBoundTokenTypes.ALTS, HardBoundTokenTypes.MTLS_S2A}: if DirectPath + * is used to create the channel, use hard ALTS-bound tokens for requests sent on that channel. + * If MTLS via S2A is used to create the channel, use hard MTLS-bound tokens for requests sent + * on that channel. + */ @InternalApi - public Builder setAllowHardBoundTokenTypes(List allowedValues) { + public Builder setAllowHardBoundTokenTypes(List allowedValues) { this.allowedHardBoundTokenTypes = allowedValues; return this; }