Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
## I/Os

* Support for X source added (Java/Python) ([#X](https://github.com/apache/beam/issues/X)).
* Upgraded GoogleAdsAPI to v19 for GoogleAdsIO (Java) ([#34497](https://github.com/apache/beam/pull/34497)). Changed PTransform method from version-specified (`v17()`) to `current()` for better backward compatibility in the future.

## New Features / Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,6 @@ class BeamModulePlugin implements Plugin<Project> {
gax_grpc : "com.google.api:gax-grpc", // google_cloud_platform_libraries_bom sets version
gax_grpc_test : "com.google.api:gax-grpc:$gax_version:testlib", // google_cloud_platform_libraries_bom sets version
gax_httpjson : "com.google.api:gax-httpjson", // google_cloud_platform_libraries_bom sets version
google_ads : "com.google.api-ads:google-ads:$google_ads_version",
google_ads_stubs : "com.google.api-ads:google-ads-stubs-v17:$google_ads_version",
google_api_client : "com.google.api-client:google-api-client:$google_clients_version", // for the libraries using $google_clients_version below.
google_api_client_gson : "com.google.api-client:google-api-client-gson:$google_clients_version",
google_api_client_java6 : "com.google.api-client:google-api-client-java6:$google_clients_version",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*sdk.*extensions.*ml.*" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*sdk.*io.*gcp.*" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*sdk.*io.*googleads.*DummyRateLimitPolicy\.java" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*sdk.*io.*googleads.*GoogleAdsV17\.java" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*sdk.*io.*googleads.*GoogleAdsV17Test\.java" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*sdk.*io.*googleads.*GoogleAds.*\.java" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*google.*cloud.*spanner.*FakeBatchTransactionId\.java" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*google.*cloud.*spanner.*FakePartitionFactory\.java" />
<suppress id="ForbidNonVendoredGrpcProtobuf" files=".*extensions.*sql.*datastore.*" />
Expand Down
6 changes: 4 additions & 2 deletions sdks/java/io/google-ads/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ description = "Apache Beam :: SDKs :: Java :: IO :: Google Ads"
ext.summary = "IO to read from Google Ads"

dependencies {
implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom)

implementation project(path: ":sdks:java:core", configuration: "shadow")
implementation project(path: ":sdks:java:extensions:google-cloud-platform-core")
implementation library.java.jackson_annotations
Expand All @@ -31,8 +33,8 @@ dependencies {
implementation library.java.google_auth_library_oauth2_http
implementation library.java.protobuf_java
implementation library.java.protobuf_java_util
implementation library.java.google_ads
implementation library.java.google_ads_stubs
implementation "com.google.api-ads:google-ads:36.0.0"
implementation "com.google.api-ads:google-ads-stubs-v19:36.0.0"
implementation library.java.joda_time
implementation library.java.vendored_guava_32_1_2_jre
testImplementation project(path: ":sdks:java:core", configuration: "shadowTest")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,84 @@
*/
package org.apache.beam.sdk.io.googleads;

import com.google.protobuf.Message;
import java.io.Serializable;
import org.apache.beam.sdk.transforms.PTransform;
import org.apache.beam.sdk.values.PCollection;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
* {@link GoogleAdsIO} provides an API for reading from the <a
* href="https://developers.google.com/google-ads/api/docs/start">Google Ads API</a> over supported
* versions of the Google Ads client libraries.
*
* @see GoogleAdsV17
* @see GoogleAdsV19
*/
public class GoogleAdsIO {
private GoogleAdsIO() {}
public abstract class GoogleAdsIO<GoogleAdsRowT, SearchGoogleAdsStreamRequestT> {

@SuppressWarnings(
"TypeParameterUnusedInFormals") // for source code backward compatible when underlying API
// version changed
public abstract <T extends PTransform<PCollection<String>, PCollection<GoogleAdsRowT>>> T read();

@SuppressWarnings(
"TypeParameterUnusedInFormals") // for source code backward compatible when underlying API
// version changed
public abstract <
T extends
PTransform<PCollection<SearchGoogleAdsStreamRequestT>, PCollection<GoogleAdsRowT>>>
T readAll();

public static GoogleAdsV19 current() {
return GoogleAdsV19.INSTANCE;
}

/**
* Implement this interface to create a {@link RateLimitPolicy}. This should be used to limit all
* traffic sent to the Google Ads API for a pair of developer token and customer ID and any other
* relevant attributes for the specific Google Ads API service being called.
*/
public interface RateLimitPolicyFactory<GoogleAdsErrorT> extends Serializable {
RateLimitPolicy<GoogleAdsErrorT> getRateLimitPolicy();
}

/**
* This interface can be used to implement custom client-side rate limiting policies. Custom
* policies should follow best practices for interacting with the Google Ads API.
*
* @see <a href="https://developers.google.com/google-ads/api/docs/best-practices/overview">Best
* Practices in the Google Ads documentation</a>
*/
public interface RateLimitPolicy<GoogleAdsErrorT> {
/**
* Called before a request is sent.
*
* @param developerToken The developer token used for the request.
* @param customerId The customer ID specified on the request.
* @param request Any Google Ads API request.
* @throws InterruptedException
*/
void onBeforeRequest(@Nullable String developerToken, String customerId, Message request)
throws InterruptedException;

/**
* Called after a request succeeds.
*
* @param developerToken The developer token used for the request.
* @param customerId The customer ID specified on the request.
* @param request Any Google Ads API request.
*/
void onSuccess(@Nullable String developerToken, String customerId, Message request);

public static GoogleAdsV17 v17() {
return GoogleAdsV17.INSTANCE;
/**
* Called after a request fails with a retryable error.
*
* @param developerToken The developer token used for the request.
* @param customerId The customer ID specified on the request.
* @param request Any Google Ads API request.
* @param error A retryable error.
*/
void onError(
@Nullable String developerToken, String customerId, Message request, GoogleAdsErrorT error);
}
}
Loading
Loading