Skip to content

Commit 8da478b

Browse files
authored
switch from v19 to v23 (#37620)
1 parent 9a60847 commit 8da478b

6 files changed

Lines changed: 60 additions & 60 deletions

File tree

sdks/java/io/google-ads/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ dependencies {
3333
implementation library.java.google_auth_library_oauth2_http
3434
implementation library.java.protobuf_java
3535
implementation library.java.protobuf_java_util
36-
implementation "com.google.api-ads:google-ads:36.0.0"
37-
implementation "com.google.api-ads:google-ads-stubs-v19:36.0.0"
36+
implementation "com.google.api-ads:google-ads:42.0.0"
37+
implementation "com.google.api-ads:google-ads-stubs-v23:42.0.0"
3838
implementation library.java.joda_time
3939
implementation library.java.vendored_guava_32_1_2_jre
4040
testImplementation project(path: ":sdks:java:core", configuration: "shadowTest")

sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsIO.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* href="https://developers.google.com/google-ads/api/docs/start">Google Ads API</a> over supported
2929
* versions of the Google Ads client libraries.
3030
*
31-
* @see GoogleAdsV19
31+
* @see GoogleAdsV23
3232
*/
3333
public abstract class GoogleAdsIO<GoogleAdsRowT, SearchGoogleAdsStreamRequestT> {
3434

@@ -45,8 +45,8 @@ public abstract class GoogleAdsIO<GoogleAdsRowT, SearchGoogleAdsStreamRequestT>
4545
PTransform<PCollection<SearchGoogleAdsStreamRequestT>, PCollection<GoogleAdsRowT>>>
4646
T readAll();
4747

48-
public static GoogleAdsV19 current() {
49-
return GoogleAdsV19.INSTANCE;
48+
public static GoogleAdsV23 current() {
49+
return GoogleAdsV23.INSTANCE;
5050
}
5151

5252
/**

sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV19.java renamed to sdks/java/io/google-ads/src/main/java/org/apache/beam/sdk/io/googleads/GoogleAdsV23.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument;
2323

2424
import com.google.ads.googleads.lib.GoogleAdsClient;
25-
import com.google.ads.googleads.v19.errors.GoogleAdsError;
26-
import com.google.ads.googleads.v19.errors.GoogleAdsException;
27-
import com.google.ads.googleads.v19.errors.GoogleAdsFailure;
28-
import com.google.ads.googleads.v19.errors.InternalErrorEnum;
29-
import com.google.ads.googleads.v19.errors.QuotaErrorEnum;
30-
import com.google.ads.googleads.v19.services.GoogleAdsRow;
31-
import com.google.ads.googleads.v19.services.GoogleAdsServiceClient;
32-
import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest;
33-
import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamResponse;
25+
import com.google.ads.googleads.v23.errors.GoogleAdsError;
26+
import com.google.ads.googleads.v23.errors.GoogleAdsException;
27+
import com.google.ads.googleads.v23.errors.GoogleAdsFailure;
28+
import com.google.ads.googleads.v23.errors.InternalErrorEnum;
29+
import com.google.ads.googleads.v23.errors.QuotaErrorEnum;
30+
import com.google.ads.googleads.v23.services.GoogleAdsRow;
31+
import com.google.ads.googleads.v23.services.GoogleAdsServiceClient;
32+
import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamRequest;
33+
import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamResponse;
3434
import com.google.auto.value.AutoValue;
3535
import com.google.protobuf.Message;
3636
import com.google.protobuf.util.Durations;
@@ -57,7 +57,7 @@
5757
import org.joda.time.Duration;
5858

5959
/**
60-
* {@link GoogleAdsV19} provides an API to read Google Ads API v19 reports.
60+
* {@link GoogleAdsV23} provides an API to read Google Ads API v23 reports.
6161
*
6262
* <p>No backward compatibility guaranteed. Do not use directly. Use {@link GoogleAdsIO#current()}
6363
* to access GoogleAdsIO instead.
@@ -79,15 +79,15 @@
7979
* --googleAdsDeveloperToken=your-developer-token
8080
* </pre>
8181
*
82-
* <p>Use {@link GoogleAdsV19#read()} to read either a bounded or unbounded {@link PCollection} of
82+
* <p>Use {@link GoogleAdsV23#read()} to read either a bounded or unbounded {@link PCollection} of
8383
* {@link GoogleAdsRow} from a single <a
8484
* href="https://developers.google.com/google-ads/api/docs/query/overview">Google Ads Query
8585
* Language</a> query using {@link Read#withQuery(String)} and a {@link PCollection} of customer
86-
* IDs. Alternatively, use {@link GoogleAdsV19#readAll()} to read either a bounded or unbounded
86+
* IDs. Alternatively, use {@link GoogleAdsV23#readAll()} to read either a bounded or unbounded
8787
* {@link PCollection} of {@link GoogleAdsRow} from a {@link PCollection} of {@link
8888
* SearchGoogleAdsStreamRequest} potentially containing many different queries.
8989
*
90-
* <p>For example, using {@link GoogleAdsV19#read()}:
90+
* <p>For example, using {@link GoogleAdsV23#read()}:
9191
*
9292
* <pre>{@code
9393
* Pipeline p = Pipeline.create();
@@ -107,7 +107,7 @@
107107
* p.run();
108108
* }</pre>
109109
*
110-
* <p>Alternatively, using {@link GoogleAdsV19#readAll()} to execute requests from a {@link
110+
* <p>Alternatively, using {@link GoogleAdsV23#readAll()} to execute requests from a {@link
111111
* PCollection} of {@link SearchGoogleAdsStreamRequest}:
112112
*
113113
* <pre>{@code
@@ -132,7 +132,7 @@
132132
*
133133
* <h2>Client-side rate limiting</h2>
134134
*
135-
* On construction of a {@link GoogleAdsV19#read()} or {@link GoogleAdsV19#readAll()} transform a
135+
* On construction of a {@link GoogleAdsV23#read()} or {@link GoogleAdsV23#readAll()} transform a
136136
* rate limiting policy must be specified to stay well under the assigned quota for the Google Ads
137137
* API. The Google Ads API enforces global rate limits from the developer token down to the customer
138138
* ID and depending on the access level of the developer token a limit on the total number of
@@ -161,21 +161,21 @@
161161
* @see <a href="https://developers.google.com/google-ads/api/docs/best-practices/overview">Best
162162
* Practices in the Google Ads documentation</a>
163163
*/
164-
public class GoogleAdsV19 extends GoogleAdsIO<GoogleAdsRow, SearchGoogleAdsStreamRequest> {
165-
static final GoogleAdsV19 INSTANCE = new GoogleAdsV19();
164+
public class GoogleAdsV23 extends GoogleAdsIO<GoogleAdsRow, SearchGoogleAdsStreamRequest> {
165+
static final GoogleAdsV23 INSTANCE = new GoogleAdsV23();
166166

167-
private GoogleAdsV19() {}
167+
private GoogleAdsV23() {}
168168

169169
@Override
170170
public Read read() {
171-
return new AutoValue_GoogleAdsV19_Read.Builder()
171+
return new AutoValue_GoogleAdsV23_Read.Builder()
172172
.setGoogleAdsClientFactory(DefaultGoogleAdsClientFactory.getInstance())
173173
.build();
174174
}
175175

176176
@Override
177177
public ReadAll readAll() {
178-
return new AutoValue_GoogleAdsV19_ReadAll.Builder()
178+
return new AutoValue_GoogleAdsV23_ReadAll.Builder()
179179
.setGoogleAdsClientFactory(DefaultGoogleAdsClientFactory.getInstance())
180180
.build();
181181
}
@@ -450,13 +450,13 @@ static class ReadAllFn extends DoFn<SearchGoogleAdsStreamRequest, GoogleAdsRow>
450450

451451
@VisibleForTesting static Sleeper sleeper = Sleeper.DEFAULT;
452452

453-
private final GoogleAdsV19.ReadAll spec;
453+
private final GoogleAdsV23.ReadAll spec;
454454

455455
private transient @Nullable GoogleAdsClient googleAdsClient;
456456
private transient @Nullable GoogleAdsServiceClient googleAdsServiceClient;
457457
private transient @Nullable RateLimitPolicy<GoogleAdsError> rateLimitPolicy;
458458

459-
ReadAllFn(GoogleAdsV19.ReadAll spec) {
459+
ReadAllFn(GoogleAdsV23.ReadAll spec) {
460460
this.spec = spec;
461461
}
462462

@@ -470,7 +470,7 @@ public void setup(PipelineOptions options) {
470470
.newGoogleAdsClient(
471471
adsOptions, spec.getDeveloperToken(), null, spec.getLoginCustomerId());
472472
final GoogleAdsServiceClient googleAdsServiceClient =
473-
googleAdsClient.getVersion19().createGoogleAdsServiceClient();
473+
googleAdsClient.getVersion23().createGoogleAdsServiceClient();
474474
final RateLimitPolicy<GoogleAdsError> rateLimitPolicy =
475475
checkStateNotNull(spec.getRateLimitPolicyFactory()).getRateLimitPolicy();
476476

@@ -578,17 +578,17 @@ private Optional<GoogleAdsError> findFirstRetryableError(GoogleAdsFailure e) {
578578
* global (per pipeline or otherwise) rate limit to requests and should not be used in deployments
579579
* where the Google Ads API quota is shared between multiple applications.
580580
*
581-
* <p>This policy can be used to limit requests across all {@link GoogleAdsV19.Read} or {@link
582-
* GoogleAdsV19.ReadAll} transforms by defining and using a {@link
583-
* GoogleAdsV19.RateLimitPolicyFactory} which holds a shared static {@link
584-
* GoogleAdsV19.SimpleRateLimitPolicy}. Note that the desired rate must be divided by the expected
581+
* <p>This policy can be used to limit requests across all {@link GoogleAdsV23.Read} or {@link
582+
* GoogleAdsV23.ReadAll} transforms by defining and using a {@link
583+
* GoogleAdsV23.RateLimitPolicyFactory} which holds a shared static {@link
584+
* GoogleAdsV23.SimpleRateLimitPolicy}. Note that the desired rate must be divided by the expected
585585
* maximum number of workers for the pipeline, otherwise the pipeline may exceed the desired rate
586586
* after an upscaling event.
587587
*
588588
* <pre>{@code
589589
* public class SimpleRateLimitPolicyFactory implements GoogleAdsIO.RateLimitPolicyFactory {
590590
* private static final GoogleAdsIO.RateLimitPolicy POLICY =
591-
* new GoogleAdsV19.SimpleRateLimitPolicy(1.0 / 1000.0);
591+
* new GoogleAdsV23.SimpleRateLimitPolicy(1.0 / 1000.0);
592592
*
593593
* @Override
594594
* public GoogleAdsIO.RateLimitPolicy getRateLimitPolicy() {

sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/DummyRateLimitPolicy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
*/
1818
package org.apache.beam.sdk.io.googleads;
1919

20-
import com.google.ads.googleads.v19.errors.GoogleAdsError;
20+
import com.google.ads.googleads.v23.errors.GoogleAdsError;
2121
import com.google.protobuf.Message;
2222
import org.checkerframework.checker.nullness.qual.Nullable;
2323

24-
public class DummyRateLimitPolicy implements GoogleAdsV19.RateLimitPolicy<GoogleAdsError> {
24+
public class DummyRateLimitPolicy implements GoogleAdsV23.RateLimitPolicy<GoogleAdsError> {
2525
@Override
2626
public void onBeforeRequest(@Nullable String developerToken, String customerId, Message request)
2727
throws InterruptedException {}

sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/GoogleAdsIOTest.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
import static org.mockito.Mockito.any;
2121
import static org.mockito.Mockito.when;
2222

23-
import com.google.ads.googleads.v19.errors.AuthenticationErrorEnum.AuthenticationError;
24-
import com.google.ads.googleads.v19.errors.ErrorCode;
25-
import com.google.ads.googleads.v19.errors.ErrorDetails;
26-
import com.google.ads.googleads.v19.errors.GoogleAdsError;
27-
import com.google.ads.googleads.v19.errors.GoogleAdsException;
28-
import com.google.ads.googleads.v19.errors.GoogleAdsFailure;
29-
import com.google.ads.googleads.v19.errors.InternalErrorEnum.InternalError;
30-
import com.google.ads.googleads.v19.errors.QuotaErrorDetails;
31-
import com.google.ads.googleads.v19.errors.QuotaErrorEnum.QuotaError;
32-
import com.google.ads.googleads.v19.services.GoogleAdsRow;
33-
import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest;
34-
import com.google.ads.googleads.v19.services.SearchGoogleAdsStreamResponse;
23+
import com.google.ads.googleads.v23.errors.AuthenticationErrorEnum.AuthenticationError;
24+
import com.google.ads.googleads.v23.errors.ErrorCode;
25+
import com.google.ads.googleads.v23.errors.ErrorDetails;
26+
import com.google.ads.googleads.v23.errors.GoogleAdsError;
27+
import com.google.ads.googleads.v23.errors.GoogleAdsException;
28+
import com.google.ads.googleads.v23.errors.GoogleAdsFailure;
29+
import com.google.ads.googleads.v23.errors.InternalErrorEnum.InternalError;
30+
import com.google.ads.googleads.v23.errors.QuotaErrorDetails;
31+
import com.google.ads.googleads.v23.errors.QuotaErrorEnum.QuotaError;
32+
import com.google.ads.googleads.v23.services.GoogleAdsRow;
33+
import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamRequest;
34+
import com.google.ads.googleads.v23.services.SearchGoogleAdsStreamResponse;
3535
import com.google.api.gax.grpc.GrpcStatusCode;
3636
import com.google.api.gax.rpc.ApiException;
3737
import com.google.protobuf.Duration;
@@ -294,15 +294,15 @@ public static class ExecutionTests {
294294
public void init() {
295295
GoogleAdsOptions options = pipeline.getOptions().as(GoogleAdsOptions.class);
296296
options.setGoogleAdsCredentialFactoryClass(NoopCredentialFactory.class);
297-
synchronized (GoogleAdsV19.ReadAll.ReadAllFn.class) {
298-
GoogleAdsV19.ReadAll.ReadAllFn.sleeper = (long millis) -> {};
297+
synchronized (GoogleAdsV23.ReadAll.ReadAllFn.class) {
298+
GoogleAdsV23.ReadAll.ReadAllFn.sleeper = (long millis) -> {};
299299
}
300300
}
301301

302302
@Test
303303
@Category(NeedsRunner.class)
304304
public void testRead() {
305-
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
305+
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
306306
.searchStreamCallable()
307307
.call(any(SearchGoogleAdsStreamRequest.class))
308308
.iterator())
@@ -331,7 +331,7 @@ public void testRead() {
331331
@Test
332332
@Category(NeedsRunner.class)
333333
public void testReadWithFailureFromMaxRetriesExceeded() throws Exception {
334-
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
334+
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
335335
.searchStreamCallable()
336336
.call(any(SearchGoogleAdsStreamRequest.class)))
337337
.thenThrow(
@@ -370,7 +370,7 @@ public void testReadWithFailureFromMaxRetriesExceeded() throws Exception {
370370
@Test
371371
@Category(NeedsRunner.class)
372372
public void testReadWithFailureFromNonRetryableError() throws Exception {
373-
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
373+
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
374374
.searchStreamCallable()
375375
.call(any(SearchGoogleAdsStreamRequest.class)))
376376
.thenThrow(
@@ -403,7 +403,7 @@ public void testReadWithFailureFromNonRetryableError() throws Exception {
403403
pipeline::run);
404404
Assert.assertEquals(IOException.class, exception.getCause().getClass());
405405
Assert.assertEquals(
406-
"com.google.ads.googleads.v19.errors.GoogleAdsException: errors {\n"
406+
"com.google.ads.googleads.v23.errors.GoogleAdsException: errors {\n"
407407
+ " error_code {\n"
408408
+ " authentication_error: OAUTH_TOKEN_REVOKED\n"
409409
+ " }\n"
@@ -414,7 +414,7 @@ public void testReadWithFailureFromNonRetryableError() throws Exception {
414414
@Test
415415
@Category(NeedsRunner.class)
416416
public void testReadWithRecoveryFromInternalError() throws Exception {
417-
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
417+
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
418418
.searchStreamCallable()
419419
.call(any(SearchGoogleAdsStreamRequest.class))
420420
.iterator())
@@ -465,7 +465,7 @@ public void testReadWithRecoveryFromInternalError() throws Exception {
465465
@Test
466466
@Category(NeedsRunner.class)
467467
public void testReadWithRecoveryFromQuotaErrorWithRetryDelay() throws Exception {
468-
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V19
468+
when(MockGoogleAdsClientFactory.GOOGLE_ADS_SERVICE_STUB_V23
469469
.searchStreamCallable()
470470
.call(any(SearchGoogleAdsStreamRequest.class))
471471
.iterator())

sdks/java/io/google-ads/src/test/java/org/apache/beam/sdk/io/googleads/MockGoogleAdsClientFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
import static org.mockito.Mockito.withSettings;
2424

2525
import com.google.ads.googleads.lib.GoogleAdsClient;
26-
import com.google.ads.googleads.v19.services.GoogleAdsServiceClient;
27-
import com.google.ads.googleads.v19.services.stub.GoogleAdsServiceStub;
26+
import com.google.ads.googleads.v23.services.GoogleAdsServiceClient;
27+
import com.google.ads.googleads.v23.services.stub.GoogleAdsServiceStub;
2828
import org.checkerframework.checker.nullness.qual.Nullable;
2929

3030
class MockGoogleAdsClientFactory implements GoogleAdsClientFactory {
31-
static final GoogleAdsServiceStub GOOGLE_ADS_SERVICE_STUB_V19 =
31+
static final GoogleAdsServiceStub GOOGLE_ADS_SERVICE_STUB_V23 =
3232
mock(GoogleAdsServiceStub.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
3333

3434
@Override
@@ -39,8 +39,8 @@ public GoogleAdsClient newGoogleAdsClient(
3939
@Nullable Long loginCustomerId) {
4040
GoogleAdsClient mockGoogleAdsClient =
4141
mock(GoogleAdsClient.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
42-
when(mockGoogleAdsClient.getVersion19().createGoogleAdsServiceClient())
43-
.thenReturn(GoogleAdsServiceClient.create(GOOGLE_ADS_SERVICE_STUB_V19));
42+
when(mockGoogleAdsClient.getVersion23().createGoogleAdsServiceClient())
43+
.thenReturn(GoogleAdsServiceClient.create(GOOGLE_ADS_SERVICE_STUB_V23));
4444
return mockGoogleAdsClient;
4545
}
4646
}

0 commit comments

Comments
 (0)