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();
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 RateLimitPolicy
and RateLimitPolicyFactory
to interact with a shared rate limiting service (e.g. gubernator) for any production workloads.
Modifier and Type | Class and Description |
---|---|
static class |
GoogleAdsV19.Read
A
PTransform that reads the results of a Google Ads query as GoogleAdsRow
objects. |
static class |
GoogleAdsV19.ReadAll
A
PTransform that reads the results of many SearchGoogleAdsStreamRequest
objects as GoogleAdsRow objects. |
static class |
GoogleAdsV19.SimpleRateLimitPolicy
This rate limit policy wraps a
RateLimiter and can be used in low volume and
development use cases as a client-side rate limiting policy. |
GoogleAdsIO.RateLimitPolicy<GoogleAdsErrorT>, GoogleAdsIO.RateLimitPolicyFactory<GoogleAdsErrorT>
Modifier and Type | Method and Description |
---|---|
GoogleAdsV19.Read |
read() |
GoogleAdsV19.ReadAll |
readAll() |
current
public GoogleAdsV19.Read read()
read
in class GoogleAdsIO<com.google.ads.googleads.v19.services.GoogleAdsRow,com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest>
public GoogleAdsV19.ReadAll readAll()
readAll
in class GoogleAdsIO<com.google.ads.googleads.v19.services.GoogleAdsRow,com.google.ads.googleads.v19.services.SearchGoogleAdsStreamRequest>