public class GoogleAdsV17
extends java.lang.Object
GoogleAdsV17
provides an API to read Google Ads API v17 reports.
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 GoogleAdsV17.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.v17()
.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.v17().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 GoogleAdsV17.RateLimitPolicy
and GoogleAdsV17.RateLimitPolicyFactory
to interact with a shared rate limiting service (e.g. gubernator) for any production workloads.
Modifier and Type | Class and Description |
---|---|
static interface |
GoogleAdsV17.RateLimitPolicy
This interface can be used to implement custom client-side rate limiting policies.
|
static interface |
GoogleAdsV17.RateLimitPolicyFactory
Implement this interface to create a
GoogleAdsV17.RateLimitPolicy . |
static class |
GoogleAdsV17.Read
A
PTransform that reads the results of a Google Ads query as GoogleAdsRow
objects. |
static class |
GoogleAdsV17.ReadAll
A
PTransform that reads the results of many SearchGoogleAdsStreamRequest
objects as GoogleAdsRow objects. |
static class |
GoogleAdsV17.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. |
Modifier and Type | Method and Description |
---|---|
GoogleAdsV17.Read |
read() |
GoogleAdsV17.ReadAll |
readAll() |
public GoogleAdsV17.Read read()
public GoogleAdsV17.ReadAll readAll()