This module allows you to connect to the Google Discovery API Service and query it.
GoogleDiscoveryApiHook(api_service_name: str, api_version: str, gcp_conn_id: str = 'google_cloud_default', delegate_to: Optional[str] = None, impersonation_chain: Optional[Union[str, Sequence[str]]] = None)¶
A hook to use the Google API Discovery Service.
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 (str) -- 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 (Union[str, Sequence[str]]) -- 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.
Creates an authenticated api client for the given api service name and credentials.
the authenticated api service.
- Return type
query(self, endpoint: str, data: dict, paginate: bool = False, num_retries: int = 0)¶
Creates a dynamic API call to any Google API registered in Google's API Client Library and queries it.
endpoint (str) --
The client libraries path to the api call's executing method. For example: 'analyticsreporting.reports.batchGet'
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.
the API response from the passed endpoint.
- Return type