Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions airflow/providers/google/ads/hooks/ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def list_accessible_customers(self) -> list[str]:

@cached_property
def _get_service(self) -> GoogleAdsServiceClient:
"""Connects and authenticates with the Google Ads API using a service account"""
"""Connects and authenticates with the Google Ads API using a service account."""
client = self._get_client
return client.get_service("GoogleAdsService", version=self.api_version)

Expand All @@ -170,7 +170,7 @@ def _get_client(self) -> GoogleAdsClient:

@cached_property
def _get_customer_service(self) -> CustomerServiceClient:
"""Connects and authenticates with the Google Ads API using a service account"""
"""Connects and authenticates with the Google Ads API using a service account."""
with NamedTemporaryFile("w", suffix=".json") as secrets_temp:
self._get_config()
self._update_config_with_secret(secrets_temp)
Expand All @@ -184,7 +184,7 @@ def _get_customer_service(self) -> CustomerServiceClient:
def _get_config(self) -> None:
"""
Gets google ads connection from meta db and sets google_ads_config attribute with returned config
file
file.
"""
conn = self.get_connection(self.google_ads_conn_id)
if "google_ads_client" not in conn.extra_dejson:
Expand All @@ -196,7 +196,7 @@ def _update_config_with_secret(self, secrets_temp: IO[str]) -> None:
"""
Gets Google Cloud secret from connection and saves the contents to the temp file
Updates google ads config with file path of the temp file containing the secret
Note, the secret must be passed as a file path for Google Ads API
Note, the secret must be passed as a file path for Google Ads API.
"""
extras = self.get_connection(self.gcp_conn_id).extra_dejson
secret = get_field(extras, "keyfile_dict")
Expand All @@ -211,7 +211,7 @@ def _search(
self, client_ids: list[str], query: str, page_size: int = 10000, **kwargs
) -> list[GoogleAdsRow]:
"""
Pulls data from the Google Ads API
Pulls data from the Google Ads API.

:param client_ids: Google Ads client ID(s) to query the API for.
:param query: Google Ads Query Language query.
Expand All @@ -232,7 +232,7 @@ def _search(

def _extract_rows(self, iterators: list[GRPCIterator]) -> list[GoogleAdsRow]:
"""
Convert Google Page Iterator (GRPCIterator) objects to Google Ads Rows
Convert Google Page Iterator (GRPCIterator) objects to Google Ads Rows.

:param iterators: List of Google Page Iterator (GRPCIterator) objects

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/ads/transfers/ads_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GoogleAdsToGcsOperator(BaseOperator):
"""
Fetches the daily results from the Google Ads API for 1-n clients
Converts and saves the data as a temporary CSV file
Uploads the CSV to Google Cloud Storage
Uploads the CSV to Google Cloud Storage.

.. seealso::
For more information on the Google Ads API, take a look at the API docs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _SecretManagerClient(LoggingMixin):
"""
Retrieves Secrets object from Google Cloud Secrets Manager. This is a common class reused between
SecretsManager and Secrets Hook that provides the shared authentication and verification mechanisms.
This class should not be used directly, use SecretsManager or SecretsHook instead
This class should not be used directly, use SecretsManager or SecretsHook instead.


:param credentials: Credentials used to authenticate to GCP
Expand All @@ -50,14 +50,15 @@ def __init__(
def is_valid_secret_name(secret_name: str) -> bool:
"""
Returns true if the secret name is valid.

:param secret_name: name of the secret
:return:
"""
return bool(re.match(SECRET_ID_PATTERN, secret_name))

@cached_property
def client(self) -> SecretManagerServiceClient:
"""Create an authenticated KMS client"""
"""Create an authenticated KMS client."""
_client = SecretManagerServiceClient(credentials=self.credentials, client_info=CLIENT_INFO)
return _client

Expand Down
Loading