Class GoogleAdsV19

java.lang.Object
org.apache.beam.sdk.io.googleads.GoogleAdsIO<com.google.ads.googleads.v19.services.GoogleAdsRow,com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest>
org.apache.beam.sdk.io.googleads.GoogleAdsV19

public class GoogleAdsV19 extends GoogleAdsIO<com.google.ads.googleads.v19.services.GoogleAdsRow,com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest>
GoogleAdsV19 provides an API to read Google Ads API v19 reports.

No backward compatibility guaranteed. Do not use directly. Use GoogleAdsIO.current() to access GoogleAdsIO instead.

The Google Ads API does not use service account credentials in the same way as Google Cloud Platform APIs do. Service account credentials are typically only used to delegate (using domain-wide delegation) access through end user accounts. Providing credentials using the OAuth2 desktop flow may be preferable over domain wide delegation. Please refer to the Google Ads API documentation for more information on OAuth2 in the Google Ads API.

Defaults for OAuth 2.0 credentials, refresh token and developer token can be provided using the following flags:

   --googleAdsClientId=your-client-id
   --googleAdsClientSecret=your-client-secret
   --googleAdsRefreshToken=your-refresh-token
   --googleAdsDeveloperToken=your-developer-token
 

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

For example, using read():


 Pipeline p = Pipeline.create();
 PCollection<String> customerIds =
     p.apply(Create.of(Long.toString(1234567890L)));
 PCollection<GoogleAdsRow> rows =
     customerIds.apply(
         GoogleAdsIO.current()
             .read()
             .withRateLimitPolicy(MY_RATE_LIMIT_POLICY)
             .withQuery(
                 "SELECT"
                     + "campaign.id,"
                     + "campaign.name,"
                     + "campaign.status"
                     + "FROM campaign"));
 p.run();
 

Alternatively, using readAll() to execute requests from a PCollection of SearchGoogleAdsStreamRequest:


 Pipeline p = Pipeline.create();
 PCollection<SearchGoogleAdsStreamRequest> requests =
     p.apply(
         Create.of(
             ImmutableList.of(
                 SearchGoogleAdsStreamRequest.newBuilder()
                     .setCustomerId(Long.toString(1234567890L))
                     .setQuery(
                         "SELECT"
                             + "campaign.id,"
                             + "campaign.name,"
                             + "campaign.status"
                             + "FROM campaign")
                     .build())));
 PCollection<GoogleAdsRow> rows =
     requests.apply(GoogleAdsIO.current().readAll().withRateLimitPolicy(MY_RATE_LIMIT_POLICY));
 p.run();
 

Client-side rate limiting

On construction of a read() or 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 executed operations per day. See Rate Limits and API Limits and Quotas in the Google Ads documentation for more details.

It is recommended to host a shared rate limiting service to coordinate traffic to the Google Ads API across all applications using the same developer token. Users of these transforms are strongly advised to implement their own GoogleAdsIO.RateLimitPolicy and GoogleAdsIO.RateLimitPolicyFactory to interact with a shared rate limiting service (e.g. gubernator) for any production workloads.

Required Minimum Functionality

Pipelines built using these transforms may still be subject to the Required Minimum Functionality policy. Please review the policy carefully and have your tool reviewed by the Google Ads API Review Team. See Required Minimum Functionality and Rate sheet invalid input: '&' non-compliance fees in the Google Ads API documentation for more details.
See Also:
  • Method Details

    • read

      public GoogleAdsV19.Read read()
      Specified by:
      read in class GoogleAdsIO<com.google.ads.googleads.v19.services.GoogleAdsRow,com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest>
    • readAll

      public GoogleAdsV19.ReadAll readAll()
      Specified by:
      readAll in class GoogleAdsIO<com.google.ads.googleads.v19.services.GoogleAdsRow,com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest>