Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] source-google-ads: rename streams to 1.0.0's schema #34813

Closed
wants to merge 5 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@
from .models import CustomerModel
from .streams import (
AccountPerformanceReport,
AdGroup,
AdGroupAd,
AdGroupAdLabel,
AdGroupAdLegacy,
AdGroupBiddingStrategy,
AdGroupCriterion,
AdGroupCriterionLabel,
AdGroupLabel,
AdListingGroupCriterion,
AdGroups,
AdGroupAds,
AdGroupAdLabels,
AdGroupAdReport,
AdGroupBiddingStrategies,
AdGroupCriterions,
AdGroupCriterionLabels,
AdGroupLabels,
AdListingGroupCriterions,
Audience,
Campaign,
CampaignBiddingStrategy,
Campaigns,
CampaignBiddingStrategies,
CampaignBudget,
CampaignCriterion,
CampaignLabel,
CampaignLabels,
ClickView,
Customer,
Accounts,
CustomerClient,
CustomerLabel,
DisplayKeywordView,
GeographicView,
KeywordView,
Label,
AccountLabels,
DisplayKeywordPerformanceReport,
GeographicReport,
KeywordReport,
Labels,
ServiceAccounts,
ShoppingPerformanceView,
TopicView,
ShoppingPerformanceReport,
TopicPerformanceReport,
UserInterest,
UserLocationView,
UserLocationReport,
)
from .utils import GAQL

Expand Down Expand Up @@ -224,38 +224,38 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
incremental_config = self.get_incremental_stream_config(google_api, config, customers)
non_manager_incremental_config = self.get_incremental_stream_config(google_api, config, non_manager_accounts)
streams = [
AdGroup(**incremental_config),
AdGroupAd(**incremental_config),
AdGroupAdLabel(**default_config),
AdGroupBiddingStrategy(**incremental_config),
AdGroupCriterion(**default_config),
AdGroupCriterionLabel(**default_config),
AdGroupLabel(**default_config),
AdListingGroupCriterion(**default_config),
AdGroups(**incremental_config),
AdGroupAds(**incremental_config),
AdGroupAdLabels(**default_config),
AdGroupBiddingStrategies(**incremental_config),
AdGroupCriterions(**default_config),
AdGroupCriterionLabels(**default_config),
AdGroupLabels(**default_config),
AdListingGroupCriterions(**default_config),
Audience(**default_config),
CampaignBiddingStrategy(**incremental_config),
CampaignBiddingStrategies(**incremental_config),
CampaignCriterion(**default_config),
CampaignLabel(google_api, customers=customers),
CampaignLabels(google_api, customers=customers),
ClickView(**incremental_config),
Customer(**incremental_config),
CustomerLabel(**default_config),
Label(**default_config),
Accounts(**incremental_config),
AccountLabels(**default_config),
Labels(**default_config),
UserInterest(**default_config),
]
# Metrics streams cannot be requested for a manager account.
if non_manager_accounts:
streams.extend(
[
Campaign(**non_manager_incremental_config),
Campaigns(**non_manager_incremental_config),
CampaignBudget(**non_manager_incremental_config),
UserLocationView(**non_manager_incremental_config),
UserLocationReport(**non_manager_incremental_config),
AccountPerformanceReport(**non_manager_incremental_config),
TopicView(**non_manager_incremental_config),
DisplayKeywordView(**non_manager_incremental_config),
ShoppingPerformanceView(**non_manager_incremental_config),
AdGroupAdLegacy(**non_manager_incremental_config),
GeographicView(**non_manager_incremental_config),
KeywordView(**non_manager_incremental_config),
TopicPerformanceReport(**non_manager_incremental_config),
DisplayKeywordPerformanceReport(**non_manager_incremental_config),
ShoppingPerformanceReport(**non_manager_incremental_config),
AdGroupAdReport(**non_manager_incremental_config),
GeographicReport(**non_manager_incremental_config),
KeywordReport(**non_manager_incremental_config),
]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def get_query(self, stream_slice: Mapping[str, Any] = None) -> str:
return query


class Customer(IncrementalGoogleAdsStream):
class Accounts(IncrementalGoogleAdsStream):
"""
Customer stream: https://developers.google.com/google-ads/api/fields/v15/customer
"""
Expand Down Expand Up @@ -287,7 +287,7 @@ def parse_response(self, response: SearchPager, stream_slice: Optional[Mapping[s
yield record


class CustomerLabel(GoogleAdsStream):
class AccountLabels(GoogleAdsStream):
"""
Customer Label stream: https://developers.google.com/google-ads/api/fields/v15/customer_label
"""
Expand All @@ -304,7 +304,7 @@ class ServiceAccounts(GoogleAdsStream):
primary_key = ["customer.id"]


class Campaign(IncrementalGoogleAdsStream):
class Campaigns(IncrementalGoogleAdsStream):
"""
Campaign stream: https://developers.google.com/google-ads/api/fields/v15/campaign
"""
Expand All @@ -328,7 +328,7 @@ class CampaignBudget(IncrementalGoogleAdsStream):
]


class CampaignBiddingStrategy(IncrementalGoogleAdsStream):
class CampaignBiddingStrategies(IncrementalGoogleAdsStream):
"""
Campaign Bidding Strategy stream: https://developers.google.com/google-ads/api/fields/v15/campaign
"""
Expand All @@ -337,7 +337,7 @@ class CampaignBiddingStrategy(IncrementalGoogleAdsStream):
primary_key = ["campaign.id", "bidding_strategy.id", "segments.date"]


class CampaignLabel(GoogleAdsStream):
class CampaignLabels(GoogleAdsStream):
"""
Campaign labels stream: https://developers.google.com/google-ads/api/fields/v15/campaign_label
"""
Expand All @@ -346,7 +346,7 @@ class CampaignLabel(GoogleAdsStream):
primary_key = ["campaign.id", "label.id"]


class AdGroup(IncrementalGoogleAdsStream):
class AdGroups(IncrementalGoogleAdsStream):
"""
AdGroup stream: https://developers.google.com/google-ads/api/fields/v15/ad_group
"""
Expand All @@ -369,7 +369,7 @@ def get_query(self, stream_slice: Mapping[str, Any] = None) -> str:
return query


class AdGroupLabel(GoogleAdsStream):
class AdGroupLabels(GoogleAdsStream):
"""
Ad Group Labels stream: https://developers.google.com/google-ads/api/fields/v15/ad_group_label
"""
Expand All @@ -378,7 +378,7 @@ class AdGroupLabel(GoogleAdsStream):
primary_key = ["ad_group.id", "label.id"]


class AdGroupBiddingStrategy(IncrementalGoogleAdsStream):
class AdGroupBiddingStrategies(IncrementalGoogleAdsStream):
"""
Ad Group Bidding Strategies stream: https://developers.google.com/google-ads/api/fields/v15/ad_group
"""
Expand All @@ -387,7 +387,7 @@ class AdGroupBiddingStrategy(IncrementalGoogleAdsStream):
primary_key = ["ad_group.id", "bidding_strategy.id", "segments.date"]


class AdGroupCriterionLabel(GoogleAdsStream):
class AdGroupCriterionLabels(GoogleAdsStream):
"""
Ad Group Criterion Label stream: https://developers.google.com/google-ads/api/fields/v15/ad_group_criterion_label
"""
Expand All @@ -396,15 +396,15 @@ class AdGroupCriterionLabel(GoogleAdsStream):
primary_key = ["ad_group_criterion_label.resource_name"]


class AdGroupAd(IncrementalGoogleAdsStream):
class AdGroupAds(IncrementalGoogleAdsStream):
"""
Ad Group Ad stream: https://developers.google.com/google-ads/api/fields/v15/ad_group_ad
"""

primary_key = ["ad_group.id", "ad_group_ad.ad.id", "segments.date"]


class AdGroupAdLabel(GoogleAdsStream):
class AdGroupAdLabels(GoogleAdsStream):
"""
Ad Group Ad Labels stream: https://developers.google.com/google-ads/api/fields/v15/ad_group_ad_label
"""
Expand All @@ -421,7 +421,7 @@ class AccountPerformanceReport(IncrementalGoogleAdsStream):
primary_key = ["customer.id", "segments.date", "segments.ad_network_type", "segments.device"]


class AdGroupAdLegacy(IncrementalGoogleAdsStream):
class AdGroupAdReport(IncrementalGoogleAdsStream):
"""
AdGroupAdReport stream: https://developers.google.com/google-ads/api/fields/v15/ad_group_ad
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#ad_performance
Expand All @@ -430,7 +430,7 @@ class AdGroupAdLegacy(IncrementalGoogleAdsStream):
primary_key = ["ad_group.id", "ad_group_ad.ad.id", "segments.date", "segments.ad_network_type"]


class DisplayKeywordView(IncrementalGoogleAdsStream):
class DisplayKeywordPerformanceReport(IncrementalGoogleAdsStream):
"""
DisplayKeywordView stream: https://developers.google.com/google-ads/api/fields/v15/display_keyword_view
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#display_keyword_performance
Expand All @@ -445,7 +445,7 @@ class DisplayKeywordView(IncrementalGoogleAdsStream):
]


class TopicView(IncrementalGoogleAdsStream):
class TopicPerformanceReport(IncrementalGoogleAdsStream):
"""
DisplayTopicsPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v15/topic_view
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#display_topics_performance
Expand All @@ -460,14 +460,14 @@ class TopicView(IncrementalGoogleAdsStream):
]


class ShoppingPerformanceView(IncrementalGoogleAdsStream):
class ShoppingPerformanceReport(IncrementalGoogleAdsStream):
"""
ShoppingPerformanceView stream: https://developers.google.com/google-ads/api/fields/v15/shopping_performance_view
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#shopping_performance
"""


class UserLocationView(IncrementalGoogleAdsStream):
class UserLocationReport(IncrementalGoogleAdsStream):
"""
UserLocationView stream: https://developers.google.com/google-ads/api/fields/v15/user_location_view
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#geo_performance
Expand All @@ -482,15 +482,15 @@ class UserLocationView(IncrementalGoogleAdsStream):
]


class GeographicView(IncrementalGoogleAdsStream):
class GeographicReport(IncrementalGoogleAdsStream):
"""
UserLocationReport stream: https://developers.google.com/google-ads/api/fields/v15/geographic_view
"""

primary_key = ["customer.id", "geographic_view.country_criterion_id", "geographic_view.location_type", "segments.date"]


class KeywordView(IncrementalGoogleAdsStream):
class KeywordReport(IncrementalGoogleAdsStream):
"""
UserLocationReport stream: https://developers.google.com/google-ads/api/fields/v15/keyword_view
"""
Expand Down Expand Up @@ -526,7 +526,7 @@ class Audience(GoogleAdsStream):
primary_key = ["customer.id", "audience.id"]


class Label(GoogleAdsStream):
class Labels(GoogleAdsStream):
"""
Label stream: https://developers.google.com/google-ads/api/fields/v15/label
"""
Expand Down Expand Up @@ -808,7 +808,7 @@ def get_query(self, stream_slice: Mapping[str, Any] = None) -> str:
return query


class AdGroupCriterion(IncrementalEventsStream):
class AdGroupCriterions(IncrementalEventsStream):
"""
Ad Group Criterion stream: https://developers.google.com/google-ads/api/fields/v15/ad_group_criterion
"""
Expand All @@ -821,7 +821,7 @@ class AdGroupCriterion(IncrementalEventsStream):
cursor_field = "change_status.last_change_date_time"


class AdListingGroupCriterion(AdGroupCriterion):
class AdListingGroupCriterions(AdGroupCriterions):
"""
Ad Listing Group Criterion stream: https://developers.google.com/google-ads/api/fields/v15/ad_group_criterion
While this stream utilizes the same resource as the AdGroupCriterions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,34 @@ def get_resource_name(stream_name: str) -> str:
"campaign_real_time_bidding_settings": "campaign",
"campaign_bidding_strategy": "campaign",
"service_accounts": "customer",
"accounts": "customer",
"account_labels": "customer_label",
"ad_group_ads": "ad_group_ad",
"ad_group_ad_labels": "ad_group_ad_label",
"ad_group_ad_report": "ad_group_ad",
"ad_groups": "ad_group",
"ad_group_bidding_strategies": "ad_group",
"ad_group_criterions": "ad_group_criterion",
"ad_group_criterion_labels": "ad_group_criterion_label",
"ad_group_labels": "ad_group_label",
"ad_listing_group_criterions": "ad_group_criterion",
"audience": "audience",
"campaigns": "campaign",
"campaign_criterion": "campaign_criterion",
"campaign_bidding_strategies": "campaign",
"campaign_budget": "campaign_budget",
"campaign_labels": "campaign_label",
"change_status": "change_status",
"click_view": "click_view",
"display_keyword_performance_report": "display_keyword_view",
"display_topics_performance_report": "topic_view",
"geographic_report": "geographic_view",
"keyword_report": "keyword_view",
"labels": "label",
"shopping_performance_report": "shopping_performance_view",
"user_interest": "user_interest",
"user_location_report": "user_location_view",
"topic_performance_report": "topic_view",
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from source_google_ads.google_ads import GoogleAds
from source_google_ads.models import CustomerModel
from source_google_ads.source import SourceGoogleAds
from source_google_ads.streams import AdGroupLabel, Label, ServiceAccounts
from source_google_ads.streams import AdGroupLabels, Labels, ServiceAccounts

from .common import MockGoogleAdsClient, mock_google_ads_request_failure

Expand Down Expand Up @@ -65,8 +65,8 @@ def test_expected_errors(mocker, config, exception, error_message):
@pytest.mark.parametrize(
("cls", "raise_expected"),
(
(AdGroupLabel, False),
(Label, False),
(AdGroupLabels, False),
(Labels, False),
(ServiceAccounts, True),
),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
{
"credentials": {
"developer_token": "developer_token",
"client_id": "client_id",
"client_secret": "client_secret",
"refresh_token": "refresh_token"
},
"customer_id": "1234567890",
"start_date": "2023-09-04",
"conversion_window_days": 14,
"custom_queries": [
{
"query": "SELECT campaign.name, metrics.clicks FROM campaign",
"primary_key": null,
"table_name": "test_query"
}
]
}
{"credentials": {"developer_token": "developer_token", "client_id": "client_id", "client_secret": "client_secret", "refresh_token": "refresh_token"}, "customer_id": "1234567890", "start_date": "2023-09-04", "conversion_window_days": 14, "custom_queries": [{"query": "SELECT campaign.name, metrics.clicks FROM campaign", "primary_key": null, "table_name": "test_query"}]}
Loading
Loading