From 4942bc17e9c7261242ba3d03d85cd8b131ca2e5e Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Tue, 2 Apr 2024 20:12:59 +0000 Subject: [PATCH] feat: Client/StubSettings' getEndpoint() returns the resolved endpoint (#2440) ## Changes - Client|StubSettings `getEndpoint()` will now return the fully resolved endpoint - Client|StubSettings `getUniverseDomain()` will not return the fully resolved universe domain - Remove the generated `getEndpoint()` method in the {Client}StubSettings class. The call to `getEndpoint()` will now always hit the parent StubSettings and return the fully resolved endpoint. --------- Co-authored-by: Blake Li --- .../comment/SettingsCommentComposer.java | 3 - ...tractServiceStubSettingsClassComposer.java | 41 -- .../DeprecatedServiceStubSettings.golden | 18 - .../grpc/goldens/EchoStubSettings.golden | 18 - .../LoggingServiceV2StubSettings.golden | 18 - .../grpc/goldens/PublisherStubSettings.golden | 18 - .../grpcrest/goldens/EchoStubSettings.golden | 18 - .../goldens/WickedStubSettings.golden | 18 - .../goldens/ComplianceStubSettings.golden | 18 - .../google/api/gax/grpc/GrpcCallContext.java | 11 +- .../api/gax/httpjson/HttpJsonCallContext.java | 11 +- gax-java/gax/clirr-ignored-differences.xml | 5 + .../com/google/api/gax/rpc/ClientContext.java | 68 +-- .../google/api/gax/rpc/EndpointContext.java | 5 + .../com/google/api/gax/rpc/StubSettings.java | 117 +++-- .../google/api/gax/rpc/ClientContextTest.java | 12 +- .../api/gax/rpc/ClientSettingsTest.java | 8 +- .../api/gax/rpc/testing/FakeCallContext.java | 8 +- .../v1beta1/stub/ComplianceStubSettings.java | 18 - .../v1beta1/stub/EchoStubSettings.java | 18 - .../v1beta1/stub/IdentityStubSettings.java | 18 - .../v1beta1/stub/MessagingStubSettings.java | 18 - .../stub/SequenceServiceStubSettings.java | 18 - .../v1beta1/stub/TestingStubSettings.java | 18 - .../v1beta1/it/ITEndpointContext.java | 440 ++++++++++++++++-- .../it/util/TestClientInitializer.java | 34 +- .../stub/ConnectionServiceStubSettings.java | 18 - .../v1/stub/TetherStubSettings.java | 18 - .../v1/stub/AssetServiceStubSettings.java | 18 - .../data/v2/stub/BigtableStubSettings.java | 18 - .../v1small/stub/AddressesStubSettings.java | 18 - .../stub/RegionOperationsStubSettings.java | 18 - .../v1/stub/IamCredentialsStubSettings.java | 18 - .../iam/v1/stub/IAMPolicyStubSettings.java | 18 - .../KeyManagementServiceStubSettings.java | 18 - .../v1/stub/LibraryServiceStubSettings.java | 18 - .../v2/stub/ConfigServiceV2StubSettings.java | 18 - .../v2/stub/LoggingServiceV2StubSettings.java | 18 - .../v2/stub/MetricsServiceV2StubSettings.java | 18 - .../pubsub/v1/stub/PublisherStubSettings.java | 18 - .../v1/stub/SchemaServiceStubSettings.java | 18 - .../v1/stub/SubscriberStubSettings.java | 18 - .../v1beta1/stub/CloudRedisStubSettings.java | 18 - .../storage/v2/stub/StorageStubSettings.java | 18 - 44 files changed, 569 insertions(+), 752 deletions(-) diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java index aaad982c66..649ee62e77 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java @@ -52,9 +52,6 @@ public class SettingsCommentComposer { private static final String CLASS_HEADER_DEFAULTS_RETRIES_DESCRIPTION = "Retries are configured for idempotent methods but not for non-idempotent methods."; - public static final CommentStatement GET_ENDPOINT_COMMENT = - toSimpleComment( - "Returns the endpoint set by the user or the the service's default endpoint."); public static final CommentStatement DEFAULT_SCOPES_COMMENT = toSimpleComment("The default scopes of the service."); diff --git a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java index a64992df89..f8c00131be 100644 --- a/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java +++ b/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java @@ -999,7 +999,6 @@ private List createClassMethods( javaMethods.addAll( createMethodSettingsGetterMethods(methodSettingsMemberVarExprs, deprecatedSettingVarNames)); javaMethods.add(createCreateStubMethod(service, typeStore)); - javaMethods.add(createGetEndpointMethod()); javaMethods.addAll(createDefaultHelperAndGetterMethods(service, typeStore)); javaMethods.addAll( createNewBuilderMethods( @@ -1013,45 +1012,6 @@ private List createClassMethods( return javaMethods; } - // Helper method to create the getEndpoint method in the ServiceStubSettings class - private MethodDefinition createGetEndpointMethod() { - Expr getEndpointExpr = - MethodInvocationExpr.builder() - .setMethodName("getEndpoint") - .setExprReferenceExpr( - ValueExpr.withValue( - SuperObjectValue.withType( - TypeNode.withReference(ConcreteReference.withClazz(StubSettings.class))))) - .setReturnType(TypeNode.STRING) - .build(); - Expr isNotNullCheck = - RelationalOperationExpr.notEqualToWithExprs(getEndpointExpr, ValueExpr.createNullExpr()); - - IfStatement ifStatement = - IfStatement.builder() - .setConditionExpr(isNotNullCheck) - .setBody(ImmutableList.of(ExprStatement.withExpr(ReturnExpr.withExpr(getEndpointExpr)))) - .build(); - - Expr getDefaultEndpointExpr = - MethodInvocationExpr.builder() - .setMethodName("getDefaultEndpoint") - .setReturnType(TypeNode.STRING) - .build(); - ReturnExpr returnExpr = ReturnExpr.withExpr(getDefaultEndpointExpr); - - return MethodDefinition.builder() - .setHeaderCommentStatements(SettingsCommentComposer.GET_ENDPOINT_COMMENT) - .setScope(ScopeNode.PUBLIC) - .setIsStatic(false) - .setAnnotations(ImmutableList.of(AnnotationNode.OVERRIDE)) - .setReturnType(TypeNode.STRING) - .setName("getEndpoint") - .setBody(ImmutableList.of(ifStatement)) - .setReturnExpr(returnExpr) - .build(); - } - private static List createMethodSettingsGetterMethods( Map methodSettingsMemberVarExprs, final Set deprecatedSettingVarNames) { @@ -1497,7 +1457,6 @@ private List createNestedClassMethods( nestedClassMethods.addAll( createNestedClassSettingsBuilderGetterMethods( nestedMethodSettingsMemberVarExprs, nestedDeprecatedSettingVarNames)); - nestedClassMethods.add(createGetEndpointMethod()); nestedClassMethods.add(createNestedClassBuildMethod(service, typeStore)); return nestedClassMethods; } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/DeprecatedServiceStubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/DeprecatedServiceStubSettings.golden index 4c397ec405..d5bbe0d893 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/DeprecatedServiceStubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/DeprecatedServiceStubSettings.golden @@ -101,15 +101,6 @@ public class DeprecatedServiceStubSettings extends StubSettings { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -635,15 +626,6 @@ public class EchoStubSettings extends StubSettings { return collideNameSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public EchoStubSettings build() throws IOException { return new EchoStubSettings(this); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/LoggingServiceV2StubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/LoggingServiceV2StubSettings.golden index 9aafbdc9c9..264f6da6ff 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/LoggingServiceV2StubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/LoggingServiceV2StubSettings.golden @@ -421,15 +421,6 @@ public class LoggingServiceV2StubSettings extends StubSettings { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -810,15 +801,6 @@ public class PublisherStubSettings extends StubSettings { return detachSubscriptionSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public PublisherStubSettings build() throws IOException { return new PublisherStubSettings(this); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden index 6b8181e8a0..fefa7643ba 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoStubSettings.golden @@ -301,15 +301,6 @@ public class EchoStubSettings extends StubSettings { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -694,15 +685,6 @@ public class EchoStubSettings extends StubSettings { return updateCaseSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public EchoStubSettings build() throws IOException { return new EchoStubSettings(this); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/WickedStubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/WickedStubSettings.golden index 216cf65dc3..9a376f484a 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/WickedStubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/WickedStubSettings.golden @@ -99,15 +99,6 @@ public class WickedStubSettings extends StubSettings { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -284,15 +275,6 @@ public class WickedStubSettings extends StubSettings { return persuadeEvilPlanSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public WickedStubSettings build() throws IOException { return new WickedStubSettings(this); diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/ComplianceStubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/ComplianceStubSettings.golden index 9efb8395a1..21420a6a2e 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/ComplianceStubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/ComplianceStubSettings.golden @@ -131,15 +131,6 @@ public class ComplianceStubSettings extends StubSettings "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -417,15 +408,6 @@ public class ComplianceStubSettings extends StubSettings return verifyEnumSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public ComplianceStubSettings build() throws IOException { return new ComplianceStubSettings(this); diff --git a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java index 886beda4ec..3de00ec671 100644 --- a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java +++ b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java @@ -140,7 +140,7 @@ private GrpcCallContext( ApiCallContextOptions options, @Nullable RetrySettings retrySettings, @Nullable Set retryableCodes, - EndpointContext endpointContext) { + @Nullable EndpointContext endpointContext) { this.channel = channel; this.credentials = credentials; this.callOptions = Preconditions.checkNotNull(callOptions); @@ -152,7 +152,14 @@ private GrpcCallContext( this.options = Preconditions.checkNotNull(options); this.retrySettings = retrySettings; this.retryableCodes = retryableCodes == null ? null : ImmutableSet.copyOf(retryableCodes); - this.endpointContext = endpointContext; + // Attempt to create an empty, non-functioning EndpointContext by default. The client will have + // a valid EndpointContext with user configurations after the client has been initialized. + try { + this.endpointContext = + endpointContext == null ? EndpointContext.newBuilder().build() : endpointContext; + } catch (IOException ex) { + throw new RuntimeException(ex); + } } /** diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java index 890c205a61..bb20811058 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java @@ -121,7 +121,7 @@ private HttpJsonCallContext( ApiTracer tracer, RetrySettings defaultRetrySettings, Set defaultRetryableCodes, - EndpointContext endpointContext) { + @Nullable EndpointContext endpointContext) { this.channel = channel; this.callOptions = callOptions; this.timeout = timeout; @@ -133,7 +133,14 @@ private HttpJsonCallContext( this.retrySettings = defaultRetrySettings; this.retryableCodes = defaultRetryableCodes == null ? null : ImmutableSet.copyOf(defaultRetryableCodes); - this.endpointContext = endpointContext; + // Attempt to create an empty, non-functioning EndpointContext by default. The client will have + // a valid EndpointContext with user configurations after the client has been initialized. + try { + this.endpointContext = + endpointContext == null ? EndpointContext.newBuilder().build() : endpointContext; + } catch (IOException ex) { + throw new RuntimeException(ex); + } } /** diff --git a/gax-java/gax/clirr-ignored-differences.xml b/gax-java/gax/clirr-ignored-differences.xml index c8e68444ff..b08615ef13 100644 --- a/gax-java/gax/clirr-ignored-differences.xml +++ b/gax-java/gax/clirr-ignored-differences.xml @@ -42,4 +42,9 @@ com/google/api/gax/rpc/ApiCallContext * validateUniverseDomain() + + 7009 + com/google/api/gax/rpc/StubSettings + * getServiceName() + diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java index 409dbbada1..afe6ab0655 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java @@ -100,10 +100,6 @@ public abstract class ClientContext { @Nonnull public abstract Duration getStreamWatchdogCheckInterval(); - // Package-Private scope for internal use only. Shared between StubSettings and ClientContext - @Nullable - abstract String getServiceName(); - @Nullable public abstract String getUniverseDomain(); @@ -113,6 +109,9 @@ public abstract class ClientContext { @Nullable public abstract String getQuotaProjectId(); + /** Package-Private as this is to be shared to StubSettings */ + abstract EndpointContext getEndpointContext(); + /** Gets the {@link ApiTracerFactory} that will be used to generate traces for operations. */ @BetaApi("The surface for tracing is not stable yet and may change in the future.") @Nonnull @@ -125,18 +124,26 @@ public abstract class ClientContext { @Nullable public abstract String getGdchApiAudience(); + /** Create a new ClientContext with default values */ public static Builder newBuilder() { - return new AutoValue_ClientContext.Builder() - .setBackgroundResources(Collections.emptyList()) - .setExecutor(Executors.newScheduledThreadPool(0)) - .setHeaders(Collections.emptyMap()) - .setInternalHeaders(Collections.emptyMap()) - .setClock(NanoClock.getDefaultClock()) - .setStreamWatchdog(null) - .setStreamWatchdogCheckInterval(Duration.ZERO) - .setTracerFactory(BaseApiTracerFactory.getInstance()) - .setQuotaProjectId(null) - .setGdchApiAudience(null); + try { + return new AutoValue_ClientContext.Builder() + .setBackgroundResources(Collections.emptyList()) + .setExecutor(Executors.newScheduledThreadPool(0)) + .setHeaders(Collections.emptyMap()) + .setInternalHeaders(Collections.emptyMap()) + .setClock(NanoClock.getDefaultClock()) + .setStreamWatchdog(null) + .setStreamWatchdogCheckInterval(Duration.ZERO) + .setTracerFactory(BaseApiTracerFactory.getInstance()) + .setQuotaProjectId(null) + .setGdchApiAudience(null) + // Attempt to create an empty, non-functioning EndpointContext by default. This is + // not exposed to the user via getters/setters. + .setEndpointContext(EndpointContext.newBuilder().build()); + } catch (IOException e) { + throw new RuntimeException(e); + } } public abstract Builder toBuilder(); @@ -159,23 +166,20 @@ public static ClientContext create(StubSettings settings) throws IOException { ExecutorProvider backgroundExecutorProvider = settings.getBackgroundExecutorProvider(); final ScheduledExecutorService backgroundExecutor = backgroundExecutorProvider.getExecutor(); - Credentials credentials = settings.getCredentialsProvider().getCredentials(); - boolean usingGDCH = credentials instanceof GdchCredentials; - EndpointContext endpointContext = - EndpointContext.newBuilder() - .setServiceName(settings.getServiceName()) - .setUniverseDomain(settings.getUniverseDomain()) - .setClientSettingsEndpoint(settings.getUserSetEndpoint()) - .setTransportChannelProviderEndpoint( - settings.getTransportChannelProvider().getEndpoint()) - .setMtlsEndpoint(settings.getMtlsEndpoint()) - .setSwitchToMtlsEndpointAllowed(settings.getSwitchToMtlsEndpointAllowed()) - .setUsingGDCH(usingGDCH) - .build(); + // A valid EndpointContext should have been created in the StubSettings + EndpointContext endpointContext = settings.getEndpointContext(); String endpoint = endpointContext.resolvedEndpoint(); String settingsGdchApiAudience = settings.getGdchApiAudience(); + Credentials credentials = settings.getCredentialsProvider().getCredentials(); + boolean usingGDCH = credentials instanceof GdchCredentials; if (usingGDCH) { + // Can only determine if the GDC-H is being used via the Credentials. The Credentials object + // is resolved in the ClientContext and must be passed to the EndpointContext. Rebuild the + // endpointContext only on GDC-H flows. + endpointContext = endpointContext.withGDCH(); + // Resolve the new endpoint with the GDC-H flow + endpoint = endpointContext.resolvedEndpoint(); // We recompute the GdchCredentials with the audience String audienceString; if (!Strings.isNullOrEmpty(settingsGdchApiAudience)) { @@ -270,13 +274,13 @@ public static ClientContext create(StubSettings settings) throws IOException { .setInternalHeaders(ImmutableMap.copyOf(settings.getInternalHeaderProvider().getHeaders())) .setClock(clock) .setDefaultCallContext(defaultCallContext) - .setServiceName(settings.getServiceName()) .setUniverseDomain(settings.getUniverseDomain()) .setEndpoint(settings.getEndpoint()) .setQuotaProjectId(settings.getQuotaProjectId()) .setStreamWatchdog(watchdog) .setStreamWatchdogCheckInterval(settings.getStreamWatchdogCheckInterval()) .setTracerFactory(settings.getTracerFactory()) + .setEndpointContext(endpointContext) .build(); } @@ -337,9 +341,6 @@ public abstract static class Builder { public abstract Builder setDefaultCallContext(ApiCallContext defaultCallContext); - // Package-Private scope for internal use only. Shared between StubSettings and ClientContext - abstract Builder setServiceName(String serviceName); - public abstract Builder setUniverseDomain(String universeDomain); public abstract Builder setEndpoint(String endpoint); @@ -369,6 +370,9 @@ public abstract static class Builder { */ public abstract Builder setGdchApiAudience(String gdchApiAudience); + /** Package-Private as this is to be shared to StubSettings */ + abstract Builder setEndpointContext(EndpointContext endpointContext); + public abstract ClientContext build(); } } diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java index 5b1f14fdaf..c2f3ad50ab 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java @@ -105,6 +105,11 @@ public static Builder newBuilder() { .setUsingGDCH(false); } + /** Configure the existing EndpointContext to be using GDC-H */ + EndpointContext withGDCH() throws IOException { + return toBuilder().setUsingGDCH(true).build(); + } + /** * Check that the User configured universe domain matches the Credentials' universe domain. The * status code parameter is passed in to this method as it's a limitation of Gax's modules. The diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java index 962443e5d2..0e37c12cad 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java @@ -71,9 +71,6 @@ public abstract class StubSettings> { private final HeaderProvider internalHeaderProvider; private final TransportChannelProvider transportChannelProvider; private final ApiClock clock; - private final String serviceName; - private final String endpoint; - private final String mtlsEndpoint; private final String quotaProjectId; @Nullable private final String gdchApiAudience; @Nullable private final WatchdogProvider streamWatchdogProvider; @@ -81,7 +78,7 @@ public abstract class StubSettings> { @Nonnull private final ApiTracerFactory tracerFactory; // Track if deprecated setExecutorProvider is called private boolean deprecatedExecutorProviderSet; - private final String universeDomain; + @Nonnull private final EndpointContext endpointContext; /** * Indicate when creating transport whether it is allowed to use mTLS endpoint instead of the @@ -99,9 +96,6 @@ protected StubSettings(Builder builder) { this.headerProvider = builder.headerProvider; this.internalHeaderProvider = builder.internalHeaderProvider; this.clock = builder.clock; - this.serviceName = builder.serviceName; - this.endpoint = builder.endpoint; - this.mtlsEndpoint = builder.mtlsEndpoint; this.switchToMtlsEndpointAllowed = builder.switchToMtlsEndpointAllowed; this.quotaProjectId = builder.quotaProjectId; this.streamWatchdogProvider = builder.streamWatchdogProvider; @@ -109,7 +103,28 @@ protected StubSettings(Builder builder) { this.tracerFactory = builder.tracerFactory; this.deprecatedExecutorProviderSet = builder.deprecatedExecutorProviderSet; this.gdchApiAudience = builder.gdchApiAudience; - this.universeDomain = builder.universeDomain; + this.endpointContext = buildEndpointContext(builder); + } + + /** + * Attempt to build the EndpointContext from the Builder based on all the user configurations + * passed in. + * + * @throws RuntimeException if there is an issue building the EndpointContext + */ + private EndpointContext buildEndpointContext(Builder builder) { + try { + return EndpointContext.newBuilder() + .setServiceName(getServiceName()) + .setClientSettingsEndpoint(builder.clientSettingsEndpoint) + .setTransportChannelProviderEndpoint(builder.transportChannelProviderEndpoint) + .setMtlsEndpoint(builder.mtlsEndpoint) + .setSwitchToMtlsEndpointAllowed(builder.switchToMtlsEndpointAllowed) + .setUniverseDomain(builder.universeDomain) + .build(); + } catch (IOException e) { + throw new RuntimeException(e); + } } /** @deprecated Please use {@link #getBackgroundExecutorProvider()}. */ @@ -142,34 +157,36 @@ public final ApiClock getClock() { return clock; } - // Intended for Internal Use and Overriden by generated ServiceStubSettings classes. - // Meant to be shared between StubSettings and ClientContext. + /** + * Marked with Internal Api and meant to overriden by the generated subclasses. This getter is + * used to set the serviceName to the EndpointContext. The value in generated StubSettings + * subclasses comes from the proto files. + * + *

This should be effectively treated as an abstract method. + */ @InternalApi - public String getServiceName() { + protected String getServiceName() { return ""; } + /** @return the fully resolved universe domain used by the client */ public final String getUniverseDomain() { - return universeDomain; + return endpointContext.resolvedUniverseDomain(); } + /** @return the fully resolved endpoint used by the client */ public String getEndpoint() { - return endpoint; + return endpointContext.resolvedEndpoint(); } - /** - * This is an internal api meant to either return the user set endpoint or null. The difference - * between this method and {@link #getEndpoint()}} is that {@link #getEndpoint()} is reimplemented - * by the child class and will return the default service endpoint if the user did not set an - * endpoint (does not return null). - */ + /** @return the newly created EndpointContext */ @InternalApi - String getUserSetEndpoint() { - return endpoint; + final EndpointContext getEndpointContext() { + return endpointContext; } public final String getMtlsEndpoint() { - return mtlsEndpoint; + return endpointContext.mtlsEndpoint(); } /** Limit the visibility to this package only since only this package needs it. */ @@ -216,9 +233,9 @@ public String toString() { .add("headerProvider", headerProvider) .add("internalHeaderProvider", internalHeaderProvider) .add("clock", clock) - .add("universeDomain", universeDomain) - .add("endpoint", endpoint) - .add("mtlsEndpoint", mtlsEndpoint) + .add("universeDomain", endpointContext.resolvedUniverseDomain()) + .add("endpoint", endpointContext.resolvedEndpoint()) + .add("mtlsEndpoint", endpointContext.mtlsEndpoint()) .add("switchToMtlsEndpointAllowed", switchToMtlsEndpointAllowed) .add("quotaProjectId", quotaProjectId) .add("streamWatchdogProvider", streamWatchdogProvider) @@ -239,8 +256,8 @@ public abstract static class Builder< private HeaderProvider internalHeaderProvider; private TransportChannelProvider transportChannelProvider; private ApiClock clock; - private String serviceName; - private String endpoint; + private String clientSettingsEndpoint; + private String transportChannelProviderEndpoint; private String mtlsEndpoint; private String quotaProjectId; @Nullable private String gdchApiAudience; @@ -266,9 +283,6 @@ protected Builder(StubSettings settings) { this.headerProvider = settings.headerProvider; this.internalHeaderProvider = settings.internalHeaderProvider; this.clock = settings.clock; - this.serviceName = settings.serviceName; - this.endpoint = settings.endpoint; - this.mtlsEndpoint = settings.mtlsEndpoint; this.switchToMtlsEndpointAllowed = settings.switchToMtlsEndpointAllowed; this.quotaProjectId = settings.quotaProjectId; this.streamWatchdogProvider = settings.streamWatchdogProvider; @@ -276,7 +290,16 @@ protected Builder(StubSettings settings) { this.tracerFactory = settings.tracerFactory; this.deprecatedExecutorProviderSet = settings.deprecatedExecutorProviderSet; this.gdchApiAudience = settings.gdchApiAudience; - this.universeDomain = settings.universeDomain; + + // The follow settings will be set to the original user configurations as the + // EndpointContext will be rebuilt in the constructor. + this.clientSettingsEndpoint = settings.getEndpointContext().clientSettingsEndpoint(); + this.transportChannelProviderEndpoint = + settings.getEndpointContext().transportChannelProviderEndpoint(); + this.mtlsEndpoint = settings.getEndpointContext().mtlsEndpoint(); + this.switchToMtlsEndpointAllowed = + settings.getEndpointContext().switchToMtlsEndpointAllowed(); + this.universeDomain = settings.getEndpointContext().universeDomain(); } /** Get Quota Project ID from Client Context * */ @@ -304,8 +327,8 @@ protected Builder(ClientContext clientContext) { this.headerProvider = new NoHeaderProvider(); this.internalHeaderProvider = new NoHeaderProvider(); this.clock = NanoClock.getDefaultClock(); - this.serviceName = null; - this.endpoint = null; + this.clientSettingsEndpoint = null; + this.transportChannelProviderEndpoint = null; this.mtlsEndpoint = null; this.quotaProjectId = null; this.streamWatchdogProvider = InstantiatingWatchdogProvider.create(); @@ -326,18 +349,22 @@ protected Builder(ClientContext clientContext) { this.internalHeaderProvider = FixedHeaderProvider.create(clientContext.getInternalHeaders()); this.clock = clientContext.getClock(); - this.serviceName = clientContext.getServiceName(); - this.endpoint = clientContext.getEndpoint(); - if (this.endpoint != null) { - this.mtlsEndpoint = this.endpoint.replace("googleapis.com", "mtls.googleapis.com"); - } this.streamWatchdogProvider = FixedWatchdogProvider.create(clientContext.getStreamWatchdog()); this.streamWatchdogCheckInterval = clientContext.getStreamWatchdogCheckInterval(); this.tracerFactory = clientContext.getTracerFactory(); this.quotaProjectId = getQuotaProjectIdFromClientContext(clientContext); this.gdchApiAudience = clientContext.getGdchApiAudience(); - this.universeDomain = clientContext.getUniverseDomain(); + + // The follow settings will be set to the original user configurations as the + // EndpointContext will be rebuilt in the constructor. + this.clientSettingsEndpoint = clientContext.getEndpointContext().clientSettingsEndpoint(); + this.transportChannelProviderEndpoint = + clientContext.getEndpointContext().transportChannelProviderEndpoint(); + this.mtlsEndpoint = clientContext.getEndpointContext().mtlsEndpoint(); + this.switchToMtlsEndpointAllowed = + clientContext.getEndpointContext().switchToMtlsEndpointAllowed(); + this.universeDomain = clientContext.getEndpointContext().universeDomain(); } } @@ -427,6 +454,7 @@ protected B setInternalHeaderProvider(HeaderProvider internalHeaderProvider) { */ public B setTransportChannelProvider(TransportChannelProvider transportChannelProvider) { this.transportChannelProvider = transportChannelProvider; + this.transportChannelProviderEndpoint = transportChannelProvider.getEndpoint(); return self(); } @@ -456,10 +484,11 @@ public B setUniverseDomain(String universeDomain) { } public B setEndpoint(String endpoint) { - this.endpoint = endpoint; + this.clientSettingsEndpoint = endpoint; this.switchToMtlsEndpointAllowed = false; - if (this.endpoint != null && this.mtlsEndpoint == null) { - this.mtlsEndpoint = this.endpoint.replace("googleapis.com", "mtls.googleapis.com"); + if (this.clientSettingsEndpoint != null && this.mtlsEndpoint == null) { + this.mtlsEndpoint = + this.clientSettingsEndpoint.replace("googleapis.com", "mtls.googleapis.com"); } return self(); } @@ -556,7 +585,7 @@ public ApiClock getClock() { } public String getEndpoint() { - return endpoint; + return clientSettingsEndpoint; } public String getMtlsEndpoint() { @@ -605,7 +634,7 @@ public String toString() { .add("internalHeaderProvider", internalHeaderProvider) .add("clock", clock) .add("universeDomain", universeDomain) - .add("endpoint", endpoint) + .add("endpoint", clientSettingsEndpoint) .add("mtlsEndpoint", mtlsEndpoint) .add("switchToMtlsEndpointAllowed", switchToMtlsEndpointAllowed) .add("quotaProjectId", quotaProjectId) diff --git a/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientContextTest.java b/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientContextTest.java index cad4a7869a..2f82489528 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientContextTest.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientContextTest.java @@ -976,6 +976,7 @@ public void testCreateClientContext_SetEndpointViaClientSettings() throws IOExce @Test public void testCreateClientContext_SetEndpointViaTransportChannelProvider() throws IOException { + String transportChannelProviderEndpoint = "transport.endpoint.com"; TransportChannelProvider transportChannelProvider = new FakeTransportProvider( FakeTransportChannel.create(new FakeChannel()), @@ -983,7 +984,7 @@ public void testCreateClientContext_SetEndpointViaTransportChannelProvider() thr true, null, null, - DEFAULT_ENDPOINT); + transportChannelProviderEndpoint); StubSettings settings = new FakeStubSettings.Builder() .setEndpoint(null) @@ -995,8 +996,7 @@ public void testCreateClientContext_SetEndpointViaTransportChannelProvider() thr FixedCredentialsProvider.create(Mockito.mock(Credentials.class))); ClientSettings clientSettings = clientSettingsBuilder.build(); ClientContext clientContext = ClientContext.create(clientSettings); - // ClientContext.getEndpoint() currently always refers to the ClientSettingsEndpoint value - assertThat(clientContext.getEndpoint()).isEqualTo(null); + assertThat(clientContext.getEndpoint()).isEqualTo(transportChannelProviderEndpoint); assertThat(clientContext.getUniverseDomain()).isEqualTo(DEFAULT_UNIVERSE_DOMAIN); } @@ -1024,8 +1024,10 @@ public void testCreateClientContext_SetEndpointViaClientSettingsAndTransportChan FixedCredentialsProvider.create(Mockito.mock(Credentials.class))); ClientSettings clientSettings = clientSettingsBuilder.build(); ClientContext clientContext = ClientContext.create(clientSettings); - // ClientContext.getEndpoint() currently always refers to the ClientSettingsEndpoint value - assertThat(clientContext.getEndpoint()).isEqualTo(clientSettingsEndpoint); + // ClientContext.getEndpoint() is the resolved endpoint. If both the client settings + // and transport channel provider's endpoints are set, the resolved endpoint will be + // the transport channel provider's endpoint. + assertThat(clientContext.getEndpoint()).isEqualTo(transportChannelProviderEndpoint); assertThat(clientContext.getUniverseDomain()).isEqualTo(DEFAULT_UNIVERSE_DOMAIN); } diff --git a/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientSettingsTest.java b/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientSettingsTest.java index b39d59cbd5..bbbda6f93a 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientSettingsTest.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/rpc/ClientSettingsTest.java @@ -205,7 +205,9 @@ public void testBuilder() throws Exception { public void testBuilderFromClientContext() throws Exception { final String QUOTA_PROJECT_ID_FROM_CONTEXT = "some_quota_project_id_from_context"; ApiClock clock = Mockito.mock(ApiClock.class); - ApiCallContext callContext = FakeCallContext.createDefault(); + EndpointContext endpointContext = Mockito.mock(EndpointContext.class); + ApiCallContext callContext = + FakeCallContext.createDefault().withEndpointContext(endpointContext); Map headers = Collections.singletonMap("spiffykey", "spiffyvalue"); Watchdog watchdog = Watchdog.create( @@ -442,7 +444,9 @@ public Credentials getCredentials() throws IOException { @Test public void testBuilderFromClientContext_QuotaProjectId() { - ApiCallContext callContext = FakeCallContext.createDefault(); + EndpointContext endpointContext = Mockito.mock(EndpointContext.class); + ApiCallContext callContext = + FakeCallContext.createDefault().withEndpointContext(endpointContext); ClientContext clientContextQuotaOnly = ClientContext.newBuilder() diff --git a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java index e7c6c90b1e..77ae3d1fca 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java @@ -44,6 +44,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import java.io.IOException; import java.util.List; import java.util.Map; import java.util.Set; @@ -87,7 +88,12 @@ private FakeCallContext( this.tracer = tracer; this.retrySettings = retrySettings; this.retryableCodes = retryableCodes == null ? null : ImmutableSet.copyOf(retryableCodes); - this.endpointContext = endpointContext; + try { + this.endpointContext = + endpointContext == null ? EndpointContext.newBuilder().build() : endpointContext; + } catch (IOException e) { + throw new RuntimeException(e); + } } public static FakeCallContext createDefault() { diff --git a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/ComplianceStubSettings.java b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/ComplianceStubSettings.java index 4b34015676..70cc559f7e 100644 --- a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/ComplianceStubSettings.java +++ b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/ComplianceStubSettings.java @@ -273,15 +273,6 @@ public ComplianceStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -715,15 +706,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public ComplianceStubSettings build() throws IOException { return new ComplianceStubSettings(this); diff --git a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/EchoStubSettings.java b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/EchoStubSettings.java index 07a8e93d6b..1e659ed8d7 100644 --- a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/EchoStubSettings.java +++ b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/EchoStubSettings.java @@ -432,15 +432,6 @@ public EchoStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -920,15 +911,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public EchoStubSettings build() throws IOException { return new EchoStubSettings(this); diff --git a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/IdentityStubSettings.java b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/IdentityStubSettings.java index 69e1f50e23..dd33ed84fb 100644 --- a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/IdentityStubSettings.java +++ b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/IdentityStubSettings.java @@ -303,15 +303,6 @@ public IdentityStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -672,15 +663,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public IdentityStubSettings build() throws IOException { return new IdentityStubSettings(this); diff --git a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/MessagingStubSettings.java b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/MessagingStubSettings.java index 529e1365af..276255c45e 100644 --- a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/MessagingStubSettings.java +++ b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/MessagingStubSettings.java @@ -445,15 +445,6 @@ public MessagingStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -994,15 +985,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public MessagingStubSettings build() throws IOException { return new MessagingStubSettings(this); diff --git a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/SequenceServiceStubSettings.java b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/SequenceServiceStubSettings.java index f4ced6f389..78f7af2c99 100644 --- a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/SequenceServiceStubSettings.java +++ b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/SequenceServiceStubSettings.java @@ -268,15 +268,6 @@ public SequenceServiceStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -669,15 +660,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public SequenceServiceStubSettings build() throws IOException { return new SequenceServiceStubSettings(this); diff --git a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/TestingStubSettings.java b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/TestingStubSettings.java index 5239263cfd..f03f92651c 100644 --- a/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/TestingStubSettings.java +++ b/showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/stub/TestingStubSettings.java @@ -385,15 +385,6 @@ public TestingStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns a builder for the default ExecutorProvider for this service. */ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { return InstantiatingExecutorProvider.newBuilder(); @@ -793,15 +784,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public TestingStubSettings build() throws IOException { return new TestingStubSettings(this); diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java index c7589f8e0d..ad44622471 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java @@ -1,85 +1,429 @@ package com.google.showcase.v1beta1.it; +import static org.junit.Assert.assertThrows; + +import com.google.api.gax.core.CredentialsProvider; import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnauthenticatedException; +import com.google.auth.Credentials; +import com.google.auth.oauth2.GoogleCredentials; import com.google.common.truth.Truth; import com.google.showcase.v1beta1.EchoClient; +import com.google.showcase.v1beta1.EchoRequest; import com.google.showcase.v1beta1.EchoSettings; import com.google.showcase.v1beta1.it.util.TestClientInitializer; +import com.google.showcase.v1beta1.stub.EchoStub; +import com.google.showcase.v1beta1.stub.EchoStubSettings; +import io.grpc.ManagedChannelBuilder; import java.io.IOException; +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; +import org.junit.After; import org.junit.Test; /** * This IT tests the different user configurations allowed and their effects on endpoint and * universe domain resolution. * - *

This test will be enhanced in the future when the settings are able to return the resolved - * endpoint and universe domain values. + *

In these tests, the client is not initialized with the default configuration: + * `EchoClient.create()`. For showcase tests run in CI, the client must be supplied explicitly + * supplied with a Credentials value. The tests use a wrapped Credentials and Credentials Provider + * (UniverseDomainCredentials and UniverseDomainCredentialsProvider) which allow for testing this. + * + *

Endpoint resolution has the same behavior for both gRPC and HttpJson. The showcase tests below + * only use the gRPC transport for testing. HttpJson functionality exists inside the wrapper + * classes, but is not being used. */ public class ITEndpointContext { - public static final String SHOWCASE_DEFAULT_ENDPOINT = "localhost:7469"; + /** + * Inside the test cases below, we must explicitly configure serviceName. Normally this should not + * be configured at all, but showcase clients do not have a serviceName. The ExtendStubSettings + * wrapper return the serviceName by overriding the `getServiceName()` result. + */ + private static class ExtendedEchoStubSettings extends EchoStubSettings { - // Default (no configuration) - // This test is very similar to `endpointResolution_userConfiguration`. This test is kept - // as future enhancements could allow this test to not have to explicitly set the endpoint. - @Test - public void endpointResolution_default() throws InterruptedException, IOException { - EchoClient echoClient = null; - try { - // This is not how a client is created by default: - // 1. The default usage is EchoClient.create(), but for showcase tests run in CI, the - // client must be supplied with Credentials. - // 2. The default configuration does not set an endpoint. Showcase clients do not have - // a serviceName (and this cannot be configured by the user). Set the endpoint - // to simulate the endpointContext creating it with a proper serviceName. - EchoSettings echoSettings = - EchoSettings.newBuilder() - .setCredentialsProvider(NoCredentialsProvider.create()) - .setEndpoint(SHOWCASE_DEFAULT_ENDPOINT) - .build(); - echoClient = EchoClient.create(echoSettings); - Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo(SHOWCASE_DEFAULT_ENDPOINT); - } finally { - if (echoClient != null) { - echoClient.close(); - echoClient.awaitTermination( - TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS); + private static final String DUMMY_MTLS_ENDPOINT = "mtls.googleapis.com:443"; + + protected ExtendedEchoStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + @Override + public String getServiceName() { + return "test"; + } + + public static ExtendedEchoStubSettings.Builder newBuilder() { + return ExtendedEchoStubSettings.Builder.createDefault(); + } + + public static ExtendedEchoStubSettings.Builder newHttpJsonBuilder() { + return ExtendedEchoStubSettings.Builder.createHttpJsonDefault(); + } + + public static class Builder extends EchoStubSettings.Builder { + + protected Builder(ClientContext clientContext) { + super(clientContext); + } + + private static ExtendedEchoStubSettings.Builder createDefault() { + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setMtlsEndpoint(DUMMY_MTLS_ENDPOINT); + builder.setSwitchToMtlsEndpointAllowed(true); + return builder; + } + + private static ExtendedEchoStubSettings.Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setMtlsEndpoint(DUMMY_MTLS_ENDPOINT); + builder.setSwitchToMtlsEndpointAllowed(true); + return builder; + } + + @Override + public ExtendedEchoStubSettings build() throws IOException { + return new ExtendedEchoStubSettings(this); } } } + /** + * Without this ClientSettings wrapper, we must expose a serviceName setter to + * (Client|Stub)Settings and pass the StubSettings to the client. However, this will result in a + * null ClientSettings (See {@link EchoClient#create(EchoStub)}). Passing the stub to the Client + * will result in a NPE when doing `Client.getSettings().get(Endpoint|UniverseDomain)` as the + * ClientSettings is stored as null. + */ + private static class ExtendedEchoSettings extends EchoSettings { + + protected ExtendedEchoSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + public static EchoSettings.Builder newBuilder() { + return ExtendedEchoSettings.Builder.createDefault(); + } + + public static EchoSettings.Builder newHttpJsonBuilder() { + return ExtendedEchoSettings.Builder.createHttpJsonDefault(); + } + + public static class Builder extends EchoSettings.Builder { + protected Builder() throws IOException {} + + private static ExtendedEchoSettings.Builder createDefault() { + return new ExtendedEchoSettings.Builder(ExtendedEchoStubSettings.newBuilder()); + } + + private static ExtendedEchoSettings.Builder createHttpJsonDefault() { + return new ExtendedEchoSettings.Builder(ExtendedEchoStubSettings.newHttpJsonBuilder()); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + } + + protected Builder(EchoSettings settings) { + super(settings); + } + + protected Builder(ExtendedEchoStubSettings.Builder stubSettings) { + super(stubSettings); + } + } + } + + /** + * Credentials Wrapper for showcase testing which is used to override the Universe Domain value. + * + *

For the tests below, it will act as a valid Credentials and is used to test the flows where + * the user passes in a Credentials (i.e. ServiceAccount, AccessToken, Oauth, etc.) + */ + private static class UniverseDomainCredentials extends Credentials { + + private final String universeDomain; + + private UniverseDomainCredentials(String universeDomain) { + this.universeDomain = universeDomain; + } + + @Override + public String getAuthenticationType() { + return null; + } + + @Override + public Map> getRequestMetadata(URI uri) { + return new HashMap<>(); + } + + @Override + public boolean hasRequestMetadata() { + return false; + } + + @Override + public boolean hasRequestMetadataOnly() { + return false; + } + + @Override + public void refresh() { + // no-op + } + + @Override + public String getUniverseDomain() { + return universeDomain; + } + } + + /** + * CredentialsProvider wrapper to return the wrapped Universe Domain Credentials. This will return + * the custom Universe Domain value. + */ + private static class UniverseDomainCredentialsProvider implements CredentialsProvider { + + private final String universeDomain; + + public UniverseDomainCredentialsProvider(String universeDomain) { + this.universeDomain = universeDomain; + } + + public static UniverseDomainCredentialsProvider create() { + return new UniverseDomainCredentialsProvider(GoogleCredentials.GOOGLE_DEFAULT_UNIVERSE); + } + + public static UniverseDomainCredentialsProvider create(String universeDomain) { + return new UniverseDomainCredentialsProvider(universeDomain); + } + + @Override + public Credentials getCredentials() { + return new UniverseDomainCredentials(universeDomain); + } + } + + private static final String DEFAULT_ENDPOINT = "test.googleapis.com:443"; + private static final EchoRequest DEFAULT_REQUEST = + EchoRequest.newBuilder().setContent("echo").build(); + + private EchoClient echoClient; + + @After + public void cleanup() throws InterruptedException { + if (echoClient != null) { + echoClient.close(); + echoClient.awaitTermination( + TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS); + } + } + + // Default (no configuration) + @Test + public void endpointResolution_default() throws IOException { + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create()) + .build(); + echoClient = EchoClient.create(echoSettings); + Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo(DEFAULT_ENDPOINT); + Truth.assertThat(echoClient.getSettings().getUniverseDomain()) + .isEqualTo(GoogleCredentials.GOOGLE_DEFAULT_UNIVERSE); + } + // User configuration @Test - public void endpointResolution_userConfiguration() throws InterruptedException, IOException { + public void endpointResolution_userSetEndpoint() throws IOException { String customEndpoint = "test.com:123"; - EchoClient echoClient = null; - try { - EchoSettings echoSettings = - EchoSettings.newBuilder() - .setCredentialsProvider(NoCredentialsProvider.create()) - .setEndpoint(customEndpoint) - .build(); - echoClient = EchoClient.create(echoSettings); - Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo(customEndpoint); - } finally { - if (echoClient != null) { - echoClient.close(); - echoClient.awaitTermination( - TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS); - } - } + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create()) + .setEndpoint(customEndpoint) + .build(); + echoClient = EchoClient.create(echoSettings); + Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo(customEndpoint); + Truth.assertThat(echoClient.getSettings().getUniverseDomain()) + .isEqualTo(GoogleCredentials.GOOGLE_DEFAULT_UNIVERSE); + } + + @Test + public void endpointResolution_userSetUniverseDomainAndNoUserSetEndpoint() throws IOException { + String customUniverseDomain = "random.com"; + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create()) + .setUniverseDomain(customUniverseDomain) + .build(); + echoClient = EchoClient.create(echoSettings); + // If user configured the universe domain, the endpoint is constructed from it + Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo("test.random.com:443"); + Truth.assertThat(echoClient.getSettings().getUniverseDomain()).isEqualTo(customUniverseDomain); + } + + @Test + public void endpointResolution_userSetEndpointAndUniverseDomain() throws IOException { + String customEndpoint = "custom.endpoint.com:443"; + String customUniverseDomain = "random.com"; + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create()) + .setEndpoint(customEndpoint) + .setUniverseDomain(customUniverseDomain) + .build(); + echoClient = EchoClient.create(echoSettings); + // Custom Endpoint sets the endpoint for the client to use + Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo(customEndpoint); + // The universe domain doesn't match the endpoint. The call will fail validation when RPC is + // called. + Truth.assertThat(echoClient.getSettings().getUniverseDomain()).isEqualTo(customUniverseDomain); + } + + @Test + public void universeDomainValidation_credentialsGDU_noUserConfiguration() throws IOException { + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create()) + .setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .build(); + echoClient = EchoClient.create(echoSettings); + + // Does not throw an error + echoClient.echo(DEFAULT_REQUEST); + } + + @Test + public void universeDomainValidation_credentialsNonGDU_noUserConfiguration() throws IOException { + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create("random.com")) + .setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .build(); + echoClient = EchoClient.create(echoSettings); + + UnauthenticatedException exception = + assertThrows(UnauthenticatedException.class, () -> echoClient.echo(DEFAULT_REQUEST)); + Truth.assertThat(exception.getMessage()) + .contains( + "The configured universe domain (googleapis.com) does not match the universe domain found in the credentials (random.com)."); + } + + @Test + public void universeDomainValidation_credentialsNonGDUMatchesUserConfiguration() + throws IOException { + String universeDomain = "random.com"; + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create(universeDomain)) + .setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT) + .setUniverseDomain(universeDomain) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .build(); + echoClient = EchoClient.create(echoSettings); + + // Does not throw an error + echoClient.echo(DEFAULT_REQUEST); + } + + @Test + public void universeDomainValidation_credentialsNonGDUDoesNotMatchUserConfiguration() + throws IOException { + String universeDomain = "random.com"; + String userConfigurationUniverseDomain = "test.com"; + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(UniverseDomainCredentialsProvider.create(universeDomain)) + .setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT) + .setUniverseDomain(userConfigurationUniverseDomain) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .build(); + echoClient = EchoClient.create(echoSettings); + + UnauthenticatedException exception = + assertThrows(UnauthenticatedException.class, () -> echoClient.echo(DEFAULT_REQUEST)); + Truth.assertThat(exception.getMessage()) + .contains( + "The configured universe domain (test.com) does not match the universe domain found in the credentials (random.com)."); + } + + // This test uses NoCredentialsProvider (will default to GDU) + @Test + public void universeDomainValidation_noCredentials_noUserSetUniverseDomain() throws IOException { + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .build(); + echoClient = EchoClient.create(echoSettings); + + // Does not throw an error + echoClient.echo(DEFAULT_REQUEST); + } + + // This test uses NoCredentialsProvider (will default to GDU) + @Test + public void universeDomainValidation_noCredentials_userSetUniverseDomain() throws IOException { + String universeDomain = "random.com"; + EchoSettings echoSettings = + ExtendedEchoSettings.newBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setEndpoint(TestClientInitializer.DEFAULT_GRPC_ENDPOINT) + .setUniverseDomain(universeDomain) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .build(); + echoClient = EchoClient.create(echoSettings); + + UnauthenticatedException exception = + assertThrows(UnauthenticatedException.class, () -> echoClient.echo(DEFAULT_REQUEST)); + Truth.assertThat(exception.getMessage()) + .contains( + "The configured universe domain (random.com) does not match the universe domain found in the credentials (googleapis.com)."); } // Default in Builder (no configuration) @Test - public void endpointResolution_defaultBuilder() { + public void endpointResolution_defaultViaBuilder() { EchoSettings.Builder echoSettingsBuilder = EchoSettings.newBuilder(); - Truth.assertThat(echoSettingsBuilder.getEndpoint()).isEqualTo(SHOWCASE_DEFAULT_ENDPOINT); + // The getter in the builder returns the user set value. No configuration + // means the getter will return null + Truth.assertThat(echoSettingsBuilder.getEndpoint()).isEqualTo(null); } // User configuration in Builder @Test - public void endpointResolution_userConfigurationBuilder() { + public void endpointResolution_userConfigurationViaBuilder() { String customEndpoint = "test.com:123"; EchoSettings.Builder echoSettingsBuilder = EchoSettings.newBuilder().setEndpoint(customEndpoint); diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java index f396a0fc6f..f8912fdefa 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java @@ -44,6 +44,12 @@ public class TestClientInitializer { public static final int AWAIT_TERMINATION_SECONDS = 10; + // gRPC's endpoint must follow the format of {host}:{port} + public static final String DEFAULT_GRPC_ENDPOINT = "localhost:7469"; + // httpjson's endpoint uses `https://` by default if the scheme is not specified + // local test requires `http://` as not SSL/TLS has been set up for showcase + public static final String DEFAULT_HTTPJSON_ENDPOINT = "http://localhost:7469"; + public static EchoClient createGrpcEchoClient() throws Exception { return createGrpcEchoClient(ImmutableList.of()); } @@ -58,7 +64,7 @@ public static EchoClient createGrpcEchoClient(List intercepto .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) .setInterceptorProvider(() -> interceptorList) .build()) - .setEndpoint("localhost:7469") + .setEndpoint(DEFAULT_GRPC_ENDPOINT) .build(); return EchoClient.create(grpcEchoSettings); } @@ -83,7 +89,7 @@ public static EchoClient createGrpcEchoClientWithRetrySettings( .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) .setInterceptorProvider(() -> interceptorList) .build()) - .setEndpoint("localhost:7469") + .setEndpoint(DEFAULT_GRPC_ENDPOINT) .build(); return EchoClient.create(grpcEchoSettings); } @@ -101,7 +107,7 @@ public static EchoClient createHttpJsonEchoClient(List interceptorList) .build()) .build(); @@ -128,7 +134,7 @@ public static EchoClient createHttpJsonEchoClientWithRetrySettings( .setHttpTransport( new NetHttpTransport.Builder().doNotValidateCertificate().build()) .setInterceptorProvider(() -> interceptorList) - .setEndpoint("http://localhost:7469") + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) .build()) .build(); return EchoClient.create(httpJsonEchoSettings); @@ -150,7 +156,7 @@ public static EchoClient createGrpcEchoClientCustomBlockSettings( EchoSettings.defaultGrpcTransportProviderBuilder() .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) .build()) - .setEndpoint("localhost:7469") + .setEndpoint(DEFAULT_GRPC_ENDPOINT) .build(); return EchoClient.create(grpcEchoSettings); } @@ -171,7 +177,7 @@ public static EchoClient createHttpJsonEchoClientCustomBlockSettings( EchoSettings.defaultHttpJsonTransportProviderBuilder() .setHttpTransport( new NetHttpTransport.Builder().doNotValidateCertificate().build()) - .setEndpoint("http://localhost:7469") + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) .build()) .build(); return EchoClient.create(httpJsonEchoSettings); @@ -197,7 +203,7 @@ public static EchoClient createGrpcEchoClientCustomWaitSettings( EchoSettings.defaultGrpcTransportProviderBuilder() .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) .build()) - .setEndpoint("localhost:7469") + .setEndpoint(DEFAULT_GRPC_ENDPOINT) .build(); return EchoClient.create(grpcEchoSettings); } @@ -222,7 +228,7 @@ public static EchoClient createHttpJsonEchoClientCustomWaitSettings( EchoSettings.defaultHttpJsonTransportProviderBuilder() .setHttpTransport( new NetHttpTransport.Builder().doNotValidateCertificate().build()) - .setEndpoint("http://localhost:7469") + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) .build()) .build(); return EchoClient.create(httpJsonEchoSettings); @@ -236,7 +242,7 @@ public static IdentityClient createGrpcIdentityClient() throws Exception { IdentitySettings.defaultGrpcTransportProviderBuilder() .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) .build()) - .setEndpoint("localhost:7469") + .setEndpoint(DEFAULT_GRPC_ENDPOINT) .build(); return IdentityClient.create(grpcIdentitySettings); } @@ -249,7 +255,7 @@ public static IdentityClient createHttpJsonIdentityClient() throws Exception { EchoSettings.defaultHttpJsonTransportProviderBuilder() .setHttpTransport( new NetHttpTransport.Builder().doNotValidateCertificate().build()) - .setEndpoint("http://localhost:7469") + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) .build()) .build(); return IdentityClient.create(httpjsonIdentitySettings); @@ -266,7 +272,7 @@ public static ComplianceClient createGrpcComplianceClient(List interceptorList) .build()) - .setEndpoint("localhost:7469") + .setEndpoint(DEFAULT_GRPC_ENDPOINT) .build(); return ComplianceClient.create(grpcComplianceSettings); } @@ -280,7 +286,7 @@ public static ComplianceClient createHttpJsonComplianceClient( EchoSettings.defaultHttpJsonTransportProviderBuilder() .setHttpTransport( new NetHttpTransport.Builder().doNotValidateCertificate().build()) - .setEndpoint("http://localhost:7469") + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) .setInterceptorProvider(() -> interceptorList) .build()) .build(); @@ -297,7 +303,7 @@ public static EchoClient createGrpcEchoClientOpentelemetry(ApiTracerFactory metr EchoSettings.defaultGrpcTransportProviderBuilder() .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) .build()) - .setEndpoint("localhost:7469") + .setEndpoint(DEFAULT_GRPC_ENDPOINT) .build(); EchoStubSettings echoStubSettings = @@ -322,7 +328,7 @@ public static EchoClient createHttpJsonEchoClientOpentelemetry( EchoSettings.defaultHttpJsonTransportProviderBuilder() .setHttpTransport( new NetHttpTransport.Builder().doNotValidateCertificate().build()) - .setEndpoint("http://localhost:7469") + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) .build()) .build(); diff --git a/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/ConnectionServiceStubSettings.java b/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/ConnectionServiceStubSettings.java index c0c4b6f1d2..413e4a74e3 100644 --- a/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/ConnectionServiceStubSettings.java +++ b/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/ConnectionServiceStubSettings.java @@ -182,15 +182,6 @@ public ConnectionServiceStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -405,15 +396,6 @@ public Builder applyToAllUnaryMethods( return listConnectionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public ConnectionServiceStubSettings build() throws IOException { return new ConnectionServiceStubSettings(this); diff --git a/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/TetherStubSettings.java b/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/TetherStubSettings.java index 37975bc147..f12b23a81d 100644 --- a/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/TetherStubSettings.java +++ b/test/integration/goldens/apigeeconnect/src/com/google/cloud/apigeeconnect/v1/stub/TetherStubSettings.java @@ -101,15 +101,6 @@ public TetherStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -266,15 +257,6 @@ public StreamingCallSettings.Builder egressSettin return egressSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public TetherStubSettings build() throws IOException { return new TetherStubSettings(this); diff --git a/test/integration/goldens/asset/src/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java b/test/integration/goldens/asset/src/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java index 576f6ec1a2..1133cadb5c 100644 --- a/test/integration/goldens/asset/src/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java +++ b/test/integration/goldens/asset/src/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java @@ -571,15 +571,6 @@ public AssetServiceStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -1292,15 +1283,6 @@ public UnaryCallSettings.Builder deleteSavedQuer return batchGetEffectiveIamPoliciesSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public AssetServiceStubSettings build() throws IOException { return new AssetServiceStubSettings(this); diff --git a/test/integration/goldens/bigtable/src/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java b/test/integration/goldens/bigtable/src/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java index c0957a1c5d..410c6637d6 100644 --- a/test/integration/goldens/bigtable/src/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java +++ b/test/integration/goldens/bigtable/src/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java @@ -165,15 +165,6 @@ public BigtableStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -493,15 +484,6 @@ public UnaryCallSettings.Builder mutateRowS return readModifyWriteRowSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public BigtableStubSettings build() throws IOException { return new BigtableStubSettings(this); diff --git a/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/AddressesStubSettings.java b/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/AddressesStubSettings.java index 51eff66198..fdc5e7201d 100644 --- a/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/AddressesStubSettings.java +++ b/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/AddressesStubSettings.java @@ -288,15 +288,6 @@ public AddressesStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -600,15 +591,6 @@ public UnaryCallSettings.Builder insertSettings return listSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public AddressesStubSettings build() throws IOException { return new AddressesStubSettings(this); diff --git a/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/RegionOperationsStubSettings.java b/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/RegionOperationsStubSettings.java index 77fb5672b3..3d8580ad27 100644 --- a/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/RegionOperationsStubSettings.java +++ b/test/integration/goldens/compute/src/com/google/cloud/compute/v1small/stub/RegionOperationsStubSettings.java @@ -113,15 +113,6 @@ public RegionOperationsStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -320,15 +311,6 @@ public UnaryCallSettings.Builder waitSett return waitSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public RegionOperationsStubSettings build() throws IOException { return new RegionOperationsStubSettings(this); diff --git a/test/integration/goldens/credentials/src/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java b/test/integration/goldens/credentials/src/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java index a29f5a33e5..d8b9ff9466 100644 --- a/test/integration/goldens/credentials/src/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java +++ b/test/integration/goldens/credentials/src/com/google/cloud/iam/credentials/v1/stub/IamCredentialsStubSettings.java @@ -140,15 +140,6 @@ public IamCredentialsStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -413,15 +404,6 @@ public UnaryCallSettings.Builder signJwtSetting return signJwtSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public IamCredentialsStubSettings build() throws IOException { return new IamCredentialsStubSettings(this); diff --git a/test/integration/goldens/iam/src/com/google/iam/v1/stub/IAMPolicyStubSettings.java b/test/integration/goldens/iam/src/com/google/iam/v1/stub/IAMPolicyStubSettings.java index 7cd4b77680..f44ac7c363 100644 --- a/test/integration/goldens/iam/src/com/google/iam/v1/stub/IAMPolicyStubSettings.java +++ b/test/integration/goldens/iam/src/com/google/iam/v1/stub/IAMPolicyStubSettings.java @@ -118,15 +118,6 @@ public IAMPolicyStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -329,15 +320,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public IAMPolicyStubSettings build() throws IOException { return new IAMPolicyStubSettings(this); diff --git a/test/integration/goldens/kms/src/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java b/test/integration/goldens/kms/src/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java index cffe8d0f1b..2dc17089fc 100644 --- a/test/integration/goldens/kms/src/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java +++ b/test/integration/goldens/kms/src/com/google/cloud/kms/v1/stub/KeyManagementServiceStubSettings.java @@ -638,15 +638,6 @@ public KeyManagementServiceStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -1302,15 +1293,6 @@ public UnaryCallSettings.Builder getLocationSettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public KeyManagementServiceStubSettings build() throws IOException { return new KeyManagementServiceStubSettings(this); diff --git a/test/integration/goldens/library/src/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java b/test/integration/goldens/library/src/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java index 1a9e248aac..eca61c2fb1 100644 --- a/test/integration/goldens/library/src/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java +++ b/test/integration/goldens/library/src/com/google/cloud/example/library/v1/stub/LibraryServiceStubSettings.java @@ -306,15 +306,6 @@ public LibraryServiceStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -707,15 +698,6 @@ public UnaryCallSettings.Builder moveBookSettings() { return moveBookSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public LibraryServiceStubSettings build() throws IOException { return new LibraryServiceStubSettings(this); diff --git a/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java b/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java index 2d27a6965d..c4f2a621a4 100644 --- a/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java +++ b/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/ConfigServiceV2StubSettings.java @@ -546,15 +546,6 @@ public ConfigServiceV2Stub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -1205,15 +1196,6 @@ public UnaryCallSettings.Builder copyLogEntrie return copyLogEntriesOperationSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public ConfigServiceV2StubSettings build() throws IOException { return new ConfigServiceV2StubSettings(this); diff --git a/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java b/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java index 7f8e5453d8..f994abe376 100644 --- a/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java +++ b/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/LoggingServiceV2StubSettings.java @@ -437,15 +437,6 @@ public LoggingServiceV2Stub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -754,15 +745,6 @@ public UnaryCallSettings.Builder deleteLogSettings() { return tailLogEntriesSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public LoggingServiceV2StubSettings build() throws IOException { return new LoggingServiceV2StubSettings(this); diff --git a/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java b/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java index 8b15688099..f8df3e6015 100644 --- a/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java +++ b/test/integration/goldens/logging/src/com/google/cloud/logging/v2/stub/MetricsServiceV2StubSettings.java @@ -205,15 +205,6 @@ public MetricsServiceV2Stub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -471,15 +462,6 @@ public UnaryCallSettings.Builder deleteLogMetricS return deleteLogMetricSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public MetricsServiceV2StubSettings build() throws IOException { return new MetricsServiceV2StubSettings(this); diff --git a/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java b/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java index 2906f095e2..11baddd298 100644 --- a/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java +++ b/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java @@ -471,15 +471,6 @@ public PublisherStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -901,15 +892,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public PublisherStubSettings build() throws IOException { return new PublisherStubSettings(this); diff --git a/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java b/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java index b94de2050a..95a895f419 100644 --- a/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java +++ b/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java @@ -330,15 +330,6 @@ public SchemaServiceStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -714,15 +705,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public SchemaServiceStubSettings build() throws IOException { return new SchemaServiceStubSettings(this); diff --git a/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java b/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java index 8de5f77641..18e54d37b1 100644 --- a/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java +++ b/test/integration/goldens/pubsub/src/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java @@ -376,15 +376,6 @@ public SubscriberStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -895,15 +886,6 @@ public UnaryCallSettings.Builder getIamPolicySettin return testIamPermissionsSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public SubscriberStubSettings build() throws IOException { return new SubscriberStubSettings(this); diff --git a/test/integration/goldens/redis/src/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java b/test/integration/goldens/redis/src/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java index 3b256b283c..1d5130e20b 100644 --- a/test/integration/goldens/redis/src/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java +++ b/test/integration/goldens/redis/src/com/google/cloud/redis/v1beta1/stub/CloudRedisStubSettings.java @@ -323,15 +323,6 @@ public CloudRedisStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -991,15 +982,6 @@ public UnaryCallSettings.Builder deleteInstanc return rescheduleMaintenanceOperationSettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public CloudRedisStubSettings build() throws IOException { return new CloudRedisStubSettings(this); diff --git a/test/integration/goldens/storage/src/com/google/storage/v2/stub/StorageStubSettings.java b/test/integration/goldens/storage/src/com/google/storage/v2/stub/StorageStubSettings.java index 253690acea..11482952a2 100644 --- a/test/integration/goldens/storage/src/com/google/storage/v2/stub/StorageStubSettings.java +++ b/test/integration/goldens/storage/src/com/google/storage/v2/stub/StorageStubSettings.java @@ -588,15 +588,6 @@ public StorageStub createStub() throws IOException { "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - /** Returns the default service name. */ @Override public String getServiceName() { @@ -1271,15 +1262,6 @@ public UnaryCallSettings.Builder getHmacKeyS return updateHmacKeySettings; } - /** Returns the endpoint set by the user or the the service's default endpoint. */ - @Override - public String getEndpoint() { - if (super.getEndpoint() != null) { - return super.getEndpoint(); - } - return getDefaultEndpoint(); - } - @Override public StorageStubSettings build() throws IOException { return new StorageStubSettings(this);