From 59da24304c162b55fa20c448d44c2fdc33ae46a4 Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Tue, 17 Feb 2026 14:40:26 +0000 Subject: [PATCH] switch from v19 to v23 --- sdks/java/io/google-ads/build.gradle | 4 +- .../beam/sdk/io/googleads/GoogleAdsIO.java | 6 +- .../{GoogleAdsV19.java => GoogleAdsV23.java} | 56 +++++++++---------- .../io/googleads/DummyRateLimitPolicy.java | 4 +- .../sdk/io/googleads/GoogleAdsIOTest.java | 40 ++++++------- .../googleads/MockGoogleAdsClientFactory.java | 10 ++-- 6 files changed, 60 insertions(+), 60 deletions(-) rename sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/{GoogleAdsV19.java => GoogleAdsV23.java} (93%) diff --git a/sdks/java/io/google-ads/build.gradle b/sdks/java/io/google-ads/build.gradle index 0796c412a65f..84388d5b7a1f 100644 --- a/sdks/java/io/google-ads/build.gradle +++ b/sdks/java/io/google-ads/build.gradle @@ -33,8 +33,8 @@ dependencies { implementation library.java.google_auth_library_oauth2_http implementation library.java.protobuf_java implementation library.java.protobuf_java_util - implementation "com.google.api-ads:google-ads:36.0.0" - implementation "com.google.api-ads:google-ads-stubs-v19:36.0.0" + implementation "com.google.api-ads:google-ads:42.0.0" + implementation "com.google.api-ads:google-ads-stubs-v23:42.0.0" implementation library.java.joda_time implementation library.java.vendored_guava_32_1_2_jre testImplementation project(path: ":sdks:java:core", configuration: "shadowTest") diff --git a/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsIO.java b/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsIO.java index d90c7751e6b7..04d6155a4283 100644 --- a/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsIO.java +++ b/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsIO.java @@ -28,7 +28,7 @@ * href="https://developers.google.com/google-ads/api/docs/start">Google Ads API over supported * versions of the Google Ads client libraries. * - * @see GoogleAdsV19 + * @see GoogleAdsV23 */ public abstract class GoogleAdsIO { @@ -45,8 +45,8 @@ public abstract class GoogleAdsIO PTransform, PCollection>> T readAll(); - public static GoogleAdsV19 current() { - return GoogleAdsV19.INSTANCE; + public static GoogleAdsV23 current() { + return GoogleAdsV23.INSTANCE; } /** diff --git a/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV19.java b/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV23.java similarity index 93% rename from sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV19.java rename to sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV23.java index 11f11ea5f8c7..f8f26d8965d3 100644 --- a/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV19.java +++ b/sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV23.java @@ -22,15 +22,15 @@ import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument; import com.google.ads.googleads.lib.GoogleAdsClient; -import com.google.ads.googleads.v19.errors.GoogleAdsError; -import com.google.ads.googleads.v19.errors.GoogleAdsException; -import com.google.ads.googleads.v19.errors.GoogleAdsFailure; -import com.google.ads.googleads.v19.errors.InternalErrorEnum; -import com.google.ads.googleads.v19.errors.QuotaErrorEnum; -import com.google.ads.googleads.v19.services.GoogleAdsRow; -import com.google.ads.googleads.v19.services.GoogleAdsServiceClient; -import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest; -import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamResponse; +import com.google.ads.googleads.v23.errors.GoogleAdsError; +import com.google.ads.googleads.v23.errors.GoogleAdsException; +import com.google.ads.googleads.v23.errors.GoogleAdsFailure; +import com.google.ads.googleads.v23.errors.InternalErrorEnum; +import com.google.ads.googleads.v23.errors.QuotaErrorEnum; +import com.google.ads.googleads.v23.services.GoogleAdsRow; +import com.google.ads.googleads.v23.services.GoogleAdsServiceClient; +import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamRequest; +import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamResponse; import com.google.auto.value.AutoValue; import com.google.protobuf.Message; import com.google.protobuf.util.Durations; @@ -57,7 +57,7 @@ import org.joda.time.Duration; /** - * {@link GoogleAdsV19} provides an API to read Google Ads API v19 reports. + * {@link GoogleAdsV23} provides an API to read Google Ads API v23 reports. * *

No backward compatibility guaranteed. Do not use directly. Use {@link GoogleAdsIO#current()} * to access GoogleAdsIO instead. @@ -79,15 +79,15 @@ * --googleAdsDeveloperToken=your-developer-token * * - *

Use {@link GoogleAdsV19#read()} to read either a bounded or unbounded {@link PCollection} of + *

Use {@link GoogleAdsV23#read()} to read either a bounded or unbounded {@link PCollection} of * {@link GoogleAdsRow} from a single Google Ads Query * Language query using {@link Read#withQuery(String)} and a {@link PCollection} of customer - * IDs. Alternatively, use {@link GoogleAdsV19#readAll()} to read either a bounded or unbounded + * IDs. Alternatively, use {@link GoogleAdsV23#readAll()} to read either a bounded or unbounded * {@link PCollection} of {@link GoogleAdsRow} from a {@link PCollection} of {@link * SearchGoogleAdsStreamRequest} potentially containing many different queries. * - *

For example, using {@link GoogleAdsV19#read()}: + *

For example, using {@link GoogleAdsV23#read()}: * *

{@code
  * Pipeline p = Pipeline.create();
@@ -107,7 +107,7 @@
  * p.run();
  * }
* - *

Alternatively, using {@link GoogleAdsV19#readAll()} to execute requests from a {@link + *

Alternatively, using {@link GoogleAdsV23#readAll()} to execute requests from a {@link * PCollection} of {@link SearchGoogleAdsStreamRequest}: * *

{@code
@@ -132,7 +132,7 @@
  *
  * 

Client-side rate limiting

* - * On construction of a {@link GoogleAdsV19#read()} or {@link GoogleAdsV19#readAll()} transform a + * On construction of a {@link GoogleAdsV23#read()} or {@link GoogleAdsV23#readAll()} transform a * rate limiting policy must be specified to stay well under the assigned quota for the Google Ads * API. The Google Ads API enforces global rate limits from the developer token down to the customer * ID and depending on the access level of the developer token a limit on the total number of @@ -161,21 +161,21 @@ * @see Best * Practices in the Google Ads documentation */ -public class GoogleAdsV19 extends GoogleAdsIO { - static final GoogleAdsV19 INSTANCE = new GoogleAdsV19(); +public class GoogleAdsV23 extends GoogleAdsIO { + static final GoogleAdsV23 INSTANCE = new GoogleAdsV23(); - private GoogleAdsV19() {} + private GoogleAdsV23() {} @Override public Read read() { - return new AutoValue_GoogleAdsV19_Read.Builder() + return new AutoValue_GoogleAdsV23_Read.Builder() .setGoogleAdsClientFactory(DefaultGoogleAdsClientFactory.getInstance()) .build(); } @Override public ReadAll readAll() { - return new AutoValue_GoogleAdsV19_ReadAll.Builder() + return new AutoValue_GoogleAdsV23_ReadAll.Builder() .setGoogleAdsClientFactory(DefaultGoogleAdsClientFactory.getInstance()) .build(); } @@ -450,13 +450,13 @@ static class ReadAllFn extends DoFn @VisibleForTesting static Sleeper sleeper = Sleeper.DEFAULT; - private final GoogleAdsV19.ReadAll spec; + private final GoogleAdsV23.ReadAll spec; private transient @Nullable GoogleAdsClient googleAdsClient; private transient @Nullable GoogleAdsServiceClient googleAdsServiceClient; private transient @Nullable RateLimitPolicy rateLimitPolicy; - ReadAllFn(GoogleAdsV19.ReadAll spec) { + ReadAllFn(GoogleAdsV23.ReadAll spec) { this.spec = spec; } @@ -470,7 +470,7 @@ public void setup(PipelineOptions options) { .newGoogleAdsClient( adsOptions, spec.getDeveloperToken(), null, spec.getLoginCustomerId()); final GoogleAdsServiceClient googleAdsServiceClient = - googleAdsClient.getVersion19().createGoogleAdsServiceClient(); + googleAdsClient.getVersion23().createGoogleAdsServiceClient(); final RateLimitPolicy rateLimitPolicy = checkStateNotNull(spec.getRateLimitPolicyFactory()).getRateLimitPolicy(); @@ -578,17 +578,17 @@ private Optional findFirstRetryableError(GoogleAdsFailure e) { * global (per pipeline or otherwise) rate limit to requests and should not be used in deployments * where the Google Ads API quota is shared between multiple applications. * - *

This policy can be used to limit requests across all {@link GoogleAdsV19.Read} or {@link - * GoogleAdsV19.ReadAll} transforms by defining and using a {@link - * GoogleAdsV19.RateLimitPolicyFactory} which holds a shared static {@link - * GoogleAdsV19.SimpleRateLimitPolicy}. Note that the desired rate must be divided by the expected + *

This policy can be used to limit requests across all {@link GoogleAdsV23.Read} or {@link + * GoogleAdsV23.ReadAll} transforms by defining and using a {@link + * GoogleAdsV23.RateLimitPolicyFactory} which holds a shared static {@link + * GoogleAdsV23.SimpleRateLimitPolicy}. Note that the desired rate must be divided by the expected * maximum number of workers for the pipeline, otherwise the pipeline may exceed the desired rate * after an upscaling event. * *

{@code
    * public class SimpleRateLimitPolicyFactory implements GoogleAdsIO.RateLimitPolicyFactory {
    *   private static final GoogleAdsIO.RateLimitPolicy POLICY =
-   *       new GoogleAdsV19.SimpleRateLimitPolicy(1.0 / 1000.0);
+   *       new GoogleAdsV23.SimpleRateLimitPolicy(1.0 / 1000.0);
    *
    *   @Override
    *   public GoogleAdsIO.RateLimitPolicy getRateLimitPolicy() {
diff --git a/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/DummyRateLimitPolicy.java b/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/DummyRateLimitPolicy.java
index 56ca204db4f4..205cba38c11d 100644
--- a/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/DummyRateLimitPolicy.java
+++ b/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/DummyRateLimitPolicy.java
@@ -17,11 +17,11 @@
  */
 package org.apache.beam.sdk.io.googleads;
 
-import com.google.ads.googleads.v19.errors.GoogleAdsError;
+import com.google.ads.googleads.v23.errors.GoogleAdsError;
 import com.google.protobuf.Message;
 import org.checkerframework.checker.nullness.qual.Nullable;
 
-public class DummyRateLimitPolicy implements GoogleAdsV19.RateLimitPolicy {
+public class DummyRateLimitPolicy implements GoogleAdsV23.RateLimitPolicy {
   @Override
   public void onBeforeRequest(@Nullable String developerToken, String customerId, Message request)
       throws InterruptedException {}
diff --git a/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/GoogleAdsIOTest.java b/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/GoogleAdsIOTest.java
index 29ac09951801..f2725600b72f 100644
--- a/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/GoogleAdsIOTest.java
+++ b/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/GoogleAdsIOTest.java
@@ -20,18 +20,18 @@
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.when;
 
-import com.google.ads.googleads.v19.errors.AuthenticationErrorEnum.AuthenticationError;
-import com.google.ads.googleads.v19.errors.ErrorCode;
-import com.google.ads.googleads.v19.errors.ErrorDetails;
-import com.google.ads.googleads.v19.errors.GoogleAdsError;
-import com.google.ads.googleads.v19.errors.GoogleAdsException;
-import com.google.ads.googleads.v19.errors.GoogleAdsFailure;
-import com.google.ads.googleads.v19.errors.InternalErrorEnum.InternalError;
-import com.google.ads.googleads.v19.errors.QuotaErrorDetails;
-import com.google.ads.googleads.v19.errors.QuotaErrorEnum.QuotaError;
-import com.google.ads.googleads.v19.services.GoogleAdsRow;
-import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest;
-import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamResponse;
+import com.google.ads.googleads.v23.errors.AuthenticationErrorEnum.AuthenticationError;
+import com.google.ads.googleads.v23.errors.ErrorCode;
+import com.google.ads.googleads.v23.errors.ErrorDetails;
+import com.google.ads.googleads.v23.errors.GoogleAdsError;
+import com.google.ads.googleads.v23.errors.GoogleAdsException;
+import com.google.ads.googleads.v23.errors.GoogleAdsFailure;
+import com.google.ads.googleads.v23.errors.InternalErrorEnum.InternalError;
+import com.google.ads.googleads.v23.errors.QuotaErrorDetails;
+import com.google.ads.googleads.v23.errors.QuotaErrorEnum.QuotaError;
+import com.google.ads.googleads.v23.services.GoogleAdsRow;
+import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamRequest;
+import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamResponse;
 import com.google.api.gax.grpc.GrpcStatusCode;
 import com.google.api.gax.rpc.ApiException;
 import com.google.protobuf.Duration;
@@ -294,15 +294,15 @@ public static class ExecutionTests {
     public void init() {
       GoogleAdsOptions options = pipeline.getOptions().as(GoogleAdsOptions.class);
       options.setGoogleAdsCredentialFactoryClass(NoopCredentialFactory.class);
-      synchronized (GoogleAdsV19.ReadAll.ReadAllFn.class) {
-        GoogleAdsV19.ReadAll.ReadAllFn.sleeper = (long millis) -> {};
+      synchronized (GoogleAdsV23.ReadAll.ReadAllFn.class) {
+        GoogleAdsV23.ReadAll.ReadAllFn.sleeper = (long millis) -> {};
       }
     }
 
     @Test
     @Category(NeedsRunner.class)
     public void testRead() {
-      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
+      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
               .searchStreamCallable()
               .call(any(SearchGoogleAdsStreamRequest.class))
               .iterator())
@@ -331,7 +331,7 @@ public void testRead() {
     @Test
     @Category(NeedsRunner.class)
     public void testReadWithFailureFromMaxRetriesExceeded() throws Exception {
-      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
+      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
               .searchStreamCallable()
               .call(any(SearchGoogleAdsStreamRequest.class)))
           .thenThrow(
@@ -370,7 +370,7 @@ public void testReadWithFailureFromMaxRetriesExceeded() throws Exception {
     @Test
     @Category(NeedsRunner.class)
     public void testReadWithFailureFromNonRetryableError() throws Exception {
-      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
+      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
               .searchStreamCallable()
               .call(any(SearchGoogleAdsStreamRequest.class)))
           .thenThrow(
@@ -403,7 +403,7 @@ public void testReadWithFailureFromNonRetryableError() throws Exception {
               pipeline::run);
       Assert.assertEquals(IOException.class, exception.getCause().getClass());
       Assert.assertEquals(
-          "com.google.ads.googleads.v19.errors.GoogleAdsException: errors {\n"
+          "com.google.ads.googleads.v23.errors.GoogleAdsException: errors {\n"
               + "  error_code {\n"
               + "    authentication_error: OAUTH_TOKEN_REVOKED\n"
               + "  }\n"
@@ -414,7 +414,7 @@ public void testReadWithFailureFromNonRetryableError() throws Exception {
     @Test
     @Category(NeedsRunner.class)
     public void testReadWithRecoveryFromInternalError() throws Exception {
-      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
+      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
               .searchStreamCallable()
               .call(any(SearchGoogleAdsStreamRequest.class))
               .iterator())
@@ -465,7 +465,7 @@ public void testReadWithRecoveryFromInternalError() throws Exception {
     @Test
     @Category(NeedsRunner.class)
     public void testReadWithRecoveryFromQuotaErrorWithRetryDelay() throws Exception {
-      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
+      when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
               .searchStreamCallable()
               .call(any(SearchGoogleAdsStreamRequest.class))
               .iterator())
diff --git a/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/MockGoogleAdsClientFactory.java b/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/MockGoogleAdsClientFactory.java
index 6ff6ef92e9e0..e92cff8808a7 100644
--- a/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/MockGoogleAdsClientFactory.java
+++ b/sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/MockGoogleAdsClientFactory.java
@@ -23,12 +23,12 @@
 import static org.mockito.Mockito.withSettings;
 
 import com.google.ads.googleads.lib.GoogleAdsClient;
-import com.google.ads.googleads.v19.services.GoogleAdsServiceClient;
-import com.google.ads.googleads.v19.services.stub.GoogleAdsServiceStub;
+import com.google.ads.googleads.v23.services.GoogleAdsServiceClient;
+import com.google.ads.googleads.v23.services.stub.GoogleAdsServiceStub;
 import org.checkerframework.checker.nullness.qual.Nullable;
 
 class MockGoogleAdsClientFactory implements GoogleAdsClientFactory {
-  static final GoogleAdsServiceStub GOOGLE_ADS_SERVICE_STUB_V19 =
+  static final GoogleAdsServiceStub GOOGLE_ADS_SERVICE_STUB_V23 =
       mock(GoogleAdsServiceStub.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
 
   @Override
@@ -39,8 +39,8 @@ public GoogleAdsClient newGoogleAdsClient(
       @Nullable Long loginCustomerId) {
     GoogleAdsClient mockGoogleAdsClient =
         mock(GoogleAdsClient.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
-    when(mockGoogleAdsClient.getVersion19().createGoogleAdsServiceClient())
-        .thenReturn(GoogleAdsServiceClient.create(GOOGLE_ADS_SERVICE_STUB_V19));
+    when(mockGoogleAdsClient.getVersion23().createGoogleAdsServiceClient())
+        .thenReturn(GoogleAdsServiceClient.create(GOOGLE_ADS_SERVICE_STUB_V23));
     return mockGoogleAdsClient;
   }
 }