airflow.providers.google.ads.hooks.ads
¶
This module contains Google Ad hook.
Module Contents¶
Classes¶
Interact with Google Ads API. |
- class airflow.providers.google.ads.hooks.ads.GoogleAdsHook(api_version=None, gcp_conn_id='google_cloud_default', google_ads_conn_id='google_ads_default', **kwargs)[source]¶
Bases:
airflow.hooks.base.BaseHook
Interact with Google Ads API.
This hook offers two flows of authentication.
OAuth Service Account Flow (requires two connections)
gcp_conn_id - provides service account details (like any other GCP connection)
- google_ads_conn_id - which contains information from Google Ads config.yaml file
in the
extras
. Example of theextras
:{ "google_ads_client": { "developer_token": "{{ INSERT_TOKEN }}", "json_key_file_path": null, "impersonated_email": "{{ INSERT_IMPERSONATED_EMAIL }}" } }
The
json_key_file_path
is resolved by the hook using credentials from gcp_conn_id. https://developers.google.com/google-ads/api/docs/client-libs/python/oauth-service
See also
For more information on how Google Ads authentication flow works take a look at: https://developers.google.com/google-ads/api/docs/client-libs/python/oauth-service
See also
For more information on the Google Ads API, take a look at the API docs: https://developers.google.com/google-ads/api/docs/start
Developer token from API center flow (only requires google_ads_conn_id)
- google_ads_conn_id - which contains developer token, refresh token, client_id and client_secret
in the
extras
. Example of theextras
:{ "google_ads_client": { "developer_token": "{{ INSERT_DEVELOPER_TOKEN }}", "refresh_token": "{{ INSERT_REFRESH_TOKEN }}", "client_id": "{{ INSERT_CLIENT_ID }}", "client_secret": "{{ INSERT_CLIENT_SECRET }}", "use_proto_plus": "{{ True or False }}", } }
See also
For more information on how to obtain a developer token look at: https://developers.google.com/google-ads/api/docs/get-started/dev-token
See also
For more information about use_proto_plus option see the Protobuf Messages guide: https://developers.google.com/google-ads/api/docs/client-libs/python/protobuf-messages
- Parameters
- search(client_ids, query, page_size=10000, **kwargs)[source]¶
Pull data from the Google Ads API.
Native protobuf message instances are returned (those seen in versions prior to 10.0.0 of the google-ads library).
This method is for backwards compatibility with older versions of the google_ads_hook.
Check out the search_proto_plus method to get API results in the new default format of the google-ads library since v10.0.0 that behave more like conventional python object (using proto-plus-python).
- Parameters
- Returns
Google Ads API response, converted to Google Ads Row objects.
- Return type
list[google.ads.googleads.v18.services.types.google_ads_service.GoogleAdsRow]
- search_proto_plus(client_ids, query, page_size=10000, **kwargs)[source]¶
Pull data from the Google Ads API.
Instances of proto-plus-python message are returned, which behave more like conventional Python objects.
- Parameters
- Returns
Google Ads API response, converted to Google Ads Row objects
- Return type
list[google.ads.googleads.v18.services.types.google_ads_service.GoogleAdsRow]
- list_accessible_customers()[source]¶
List resource names of customers.
The resulting list of customers is based on your OAuth credentials. The request returns a list of all accounts that you are able to act upon directly given your current credentials. This will not necessarily include all accounts within the account hierarchy; rather, it will only include accounts where your authenticated user has been added with admin or other rights in the account.