From e46648f112a149f967783539d30b4c44474b39fe Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Fri, 12 Jul 2024 20:28:40 +0000 Subject: [PATCH] feat: Mark `getDefaultEndpoint()` with @ObsoleteApi (#2347) Client libraries no longer always use the default endpoint. The resolved endpoint will be determined by the EndpointContext and used by the client. --- .../common/AbstractServiceStubSettingsClassComposer.java | 8 ++++++++ .../grpc/goldens/ApiVersionTestingStubSettings.golden | 2 ++ .../grpc/goldens/DeprecatedServiceStubSettings.golden | 2 ++ .../gapic/composer/grpc/goldens/EchoStubSettings.golden | 2 ++ .../grpc/goldens/LoggingServiceV2StubSettings.golden | 2 ++ .../composer/grpc/goldens/PublisherStubSettings.golden | 2 ++ .../composer/grpcrest/goldens/EchoStubSettings.golden | 2 ++ .../composer/grpcrest/goldens/WickedStubSettings.golden | 2 ++ .../composer/rest/goldens/ComplianceStubSettings.golden | 2 ++ .../goldens/HttpJsonApiVersionTestingStubSettings.golden | 2 ++ .../showcase/v1beta1/stub/ComplianceStubSettings.java | 2 ++ .../google/showcase/v1beta1/stub/EchoStubSettings.java | 2 ++ .../showcase/v1beta1/stub/IdentityStubSettings.java | 2 ++ .../showcase/v1beta1/stub/MessagingStubSettings.java | 2 ++ .../v1beta1/stub/SequenceServiceStubSettings.java | 2 ++ .../google/showcase/v1beta1/stub/TestingStubSettings.java | 2 ++ .../v1/stub/ConnectionServiceStubSettings.java | 2 ++ .../cloud/apigeeconnect/v1/stub/TetherStubSettings.java | 2 ++ .../cloud/asset/v1/stub/AssetServiceStubSettings.java | 2 ++ .../cloud/bigtable/data/v2/stub/BigtableStubSettings.java | 2 ++ .../cloud/compute/v1small/stub/AddressesStubSettings.java | 2 ++ .../v1small/stub/RegionOperationsStubSettings.java | 2 ++ .../credentials/v1/stub/IamCredentialsStubSettings.java | 2 ++ .../src/com/google/iam/v1/stub/IAMPolicyStubSettings.java | 2 ++ .../kms/v1/stub/KeyManagementServiceStubSettings.java | 2 ++ .../library/v1/stub/LibraryServiceStubSettings.java | 2 ++ .../logging/v2/stub/ConfigServiceV2StubSettings.java | 2 ++ .../logging/v2/stub/LoggingServiceV2StubSettings.java | 2 ++ .../logging/v2/stub/MetricsServiceV2StubSettings.java | 2 ++ .../cloud/pubsub/v1/stub/PublisherStubSettings.java | 2 ++ .../cloud/pubsub/v1/stub/SchemaServiceStubSettings.java | 2 ++ .../cloud/pubsub/v1/stub/SubscriberStubSettings.java | 2 ++ .../cloud/redis/v1beta1/stub/CloudRedisStubSettings.java | 2 ++ .../com/google/storage/v2/stub/StorageStubSettings.java | 2 ++ 34 files changed, 74 insertions(+) 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 c13bc5f3f1..557b94663c 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 @@ -18,6 +18,7 @@ import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.batching.BatchingSettings; import com.google.api.gax.batching.FlowControlSettings; import com.google.api.gax.batching.FlowController.LimitExceededBehavior; @@ -1190,6 +1191,12 @@ private List createDefaultHelperAndGetterMethods( .setReturnType(returnType) .setName("getDefaultEndpoint") .setReturnExpr(ValueExpr.withValue(StringObjectValue.withValue(service.defaultHost()))) + .setAnnotations( + ImmutableList.of( + AnnotationNode.builder() + .setType(FIXED_TYPESTORE.get(ObsoleteApi.class.getSimpleName())) + .setDescription("Use getEndpoint() instead") + .build())) .build()); // Create the getDefaultMtlsEndpoint method. @@ -2068,6 +2075,7 @@ private static TypeStore createStaticTypes() { List.class, Lists.class, MonitoredResourceDescriptor.class, + ObsoleteApi.class, Operation.class, OperationCallSettings.class, OperationSnapshot.class, diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionTestingStubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionTestingStubSettings.golden index c67187cf5e..0920230bd1 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionTestingStubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/ApiVersionTestingStubSettings.golden @@ -1,6 +1,7 @@ package com.google.api.version.test.stub; import com.google.api.core.ApiFunction; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; @@ -91,6 +92,7 @@ public class EchoWithVersionStubSettings extends StubSettings { } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "localhost:7469"; } 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 264f6da6ff..39984fb5a7 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 @@ -7,6 +7,7 @@ import static com.google.logging.v2.LoggingServiceV2Client.ListMonitoredResource import com.google.api.MonitoredResourceDescriptor; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.batching.BatchingSettings; import com.google.api.gax.batching.FlowControlSettings; import com.google.api.gax.batching.FlowController; @@ -433,6 +434,7 @@ public class LoggingServiceV2StubSettings extends StubSettings { } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "pubsub.googleapis.com:443"; } 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 565f38a483..afb4998b5b 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 @@ -6,6 +6,7 @@ import static com.google.showcase.grpcrest.v1beta1.EchoClient.SimplePagedExpandP import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; @@ -307,6 +308,7 @@ public class EchoStubSettings extends StubSettings { } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "localhost:7469"; } 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 9a376f484a..5a555d7001 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 @@ -2,6 +2,7 @@ package com.google.showcase.v1beta1.stub; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; @@ -105,6 +106,7 @@ public class WickedStubSettings extends StubSettings { } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "localhost:7469"; } 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 21420a6a2e..0c6ab1cc1c 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 @@ -2,6 +2,7 @@ package com.google.showcase.v1beta1.stub; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; @@ -137,6 +138,7 @@ public class ComplianceStubSettings extends StubSettings } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "localhost:7469"; } diff --git a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonApiVersionTestingStubSettings.golden b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonApiVersionTestingStubSettings.golden index 219800efd4..08b311156c 100644 --- a/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonApiVersionTestingStubSettings.golden +++ b/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/rest/goldens/HttpJsonApiVersionTestingStubSettings.golden @@ -1,6 +1,7 @@ package com.google.api.version.test.stub; import com.google.api.core.ApiFunction; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; @@ -91,6 +92,7 @@ public class EchoWithVersionStubSettings extends StubSettings