airflow.providers.google.common.hooks.discovery_api

This module allows you to connect to the Google Discovery API Service and query it.

Module Contents

Classes

GoogleDiscoveryApiHook

A hook to use the Google API Discovery Service.

class airflow.providers.google.common.hooks.discovery_api.GoogleDiscoveryApiHook(api_service_name, api_version, gcp_conn_id='google_cloud_default', impersonation_chain=None)[source]

Bases: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

A hook to use the Google API Discovery Service.

Parameters
  • api_service_name (str) – The name of the api service that is needed to get the data for example ‘youtube’.

  • api_version (str) – The version of the api that will be requested for example ‘v3’.

  • gcp_conn_id (str) – The connection ID to use when fetching connection info.

  • delegate_to – The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have domain-wide delegation enabled.

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account.

get_conn()[source]

Creates an authenticated api client for the given api service name and credentials.

Returns

the authenticated api service.

Return type

googleapiclient.discovery.Resource

query(endpoint, data, paginate=False, num_retries=0)[source]

Creates a dynamic API call to any Google API registered in Google’s API Client Library and queries it.

Parameters
  • endpoint (str) –

    The client libraries path to the api call’s executing method. For example: ‘analyticsreporting.reports.batchGet’

    See also

    https://developers.google.com/apis-explorer for more information on what methods are available.

  • data (dict) – The data (endpoint params) needed for the specific request to given endpoint.

  • paginate (bool) – If set to True, it will collect all pages of data.

  • num_retries (int) – Define the number of retries for the requests being made if it fails.

Returns

the API response from the passed endpoint.

Return type

dict

Was this entry helpful?