michalslowikowski00 commented on a change in pull request #7748: [AIRFLOW-6752]
Add GoogleAnalyticsRetrieveAdsLinksListOperator
URL: https://github.com/apache/airflow/pull/7748#discussion_r394939034
##########
File path: airflow/providers/google/marketing_platform/hooks/analytics.py
##########
@@ -66,10 +66,43 @@ def list_accounts(self) -> List[Dict[str, Any]]:
# start index has value 1
request = accounts.list(start_index=len(result) + 1)
response = request.execute(num_retries=self.num_retries)
- result.extend(response.get('items', []))
+ result.extend(response.get("items", []))
# result is the number of fetched accounts from Analytics
# when all accounts will be add to the result
# the loop will be break
if response["totalResults"] <= len(result):
break
return result
+
+ def list_ad_words_links(
+ self, account_id: str, web_property_id: str
+ ) -> List[Dict[str, Any]]:
+ """
+ Lists webProperty-Google Ads links for a given web property.
+
+ # :param account_id: ID of the account which the given web property
belongs to.
+ # :type account_id: str
+ # :param web_property_id: Web property ID to retrieve the Google Ads
links for.
+ # :type web_property_id: str
+
+ """
+
+ self.log.info("Retrieving ad words list...")
+ result = [] # type: List[Dict]
+ conn = self.get_conn()
+ ads_links = conn.management().webPropertyAdWordsLinks() # pylint:
disable=no-member
+ while True:
+ # start index has value 1
+ request = ads_links.list(
+ accountId=account_id,
+ webPropertyId=web_property_id,
+ start_index=len(result) + 1,
+ )
+ response = request.execute(num_retries=self.num_retries)
+ result.extend(response.get("items", []))
+ # result is the number of fetched links from Analytics
+ # when all links will be add to the result
+ # the loop will be break
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services