Skip to content

Commit d61af1b

Browse files
authored
🎉 Source Google Ads: add *_label streams (#11221)
1 parent 98ee6f5 commit d61af1b

File tree

11 files changed

+103
-6
lines changed

11 files changed

+103
-6
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
- name: Google Ads
267267
sourceDefinitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
268268
dockerRepository: airbyte/source-google-ads
269-
dockerImageTag: 0.1.29
269+
dockerImageTag: 0.1.30
270270
documentationUrl: https://docs.airbyte.io/integrations/sources/google-ads
271271
icon: google-adwords.svg
272272
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@
25302530
supportsNormalization: false
25312531
supportsDBT: false
25322532
supported_destination_sync_modes: []
2533-
- dockerImage: "airbyte/source-google-ads:0.1.29"
2533+
- dockerImage: "airbyte/source-google-ads:0.1.30"
25342534
spec:
25352535
documentationUrl: "https://docs.airbyte.com/integrations/sources/google-ads"
25362536
connectionSpecification:

airbyte-integrations/connectors/source-google-ads/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ RUN pip install .
1313

1414
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1515

16-
LABEL io.airbyte.version=0.1.29
16+
LABEL io.airbyte.version=0.1.30
1717
LABEL io.airbyte.name=airbyte/source-google-ads

airbyte-integrations/connectors/source-google-ads/source_google_ads/google_ads.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
REPORT_MAPPING = {
1515
"accounts": "customer",
1616
"ad_group_ads": "ad_group_ad",
17+
"ad_group_ad_labels": "ad_group_ad_label",
1718
"ad_groups": "ad_group",
19+
"ad_group_labels": "ad_group_label",
1820
"campaigns": "campaign",
21+
"campaign_labels": "campaign_label",
1922
"account_performance_report": "customer",
2023
"ad_group_ad_report": "ad_group_ad",
2124
"display_keyword_performance_report": "display_keyword_view",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"ad_group_ad.ad.resource_name": {
6+
"type": ["null", "integer"]
7+
},
8+
"ad_group_ad_label.resource_name": {
9+
"type": ["null", "string"]
10+
},
11+
"label.name": {
12+
"type": ["null", "integer"]
13+
},
14+
"label.resource_name": {
15+
"type": ["null", "integer"]
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"ad_group.resource_name": {
6+
"type": ["null", "integer"]
7+
},
8+
"ad_group_label.resource_name": {
9+
"type": ["null", "string"]
10+
},
11+
"label.name": {
12+
"type": ["null", "integer"]
13+
},
14+
"label.resource_name": {
15+
"type": ["null", "integer"]
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"campaign.resource_name": {
6+
"type": ["null", "string"]
7+
},
8+
"campaign_label.resource_name": {
9+
"type": ["null", "string"]
10+
},
11+
"label.name": {
12+
"type": ["null", "integer"]
13+
},
14+
"label.resource_name": {
15+
"type": ["null", "integer"]
16+
}
17+
}
18+
}

airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
from .streams import (
1919
AccountPerformanceReport,
2020
Accounts,
21+
AdGroupAdLabels,
2122
AdGroupAdReport,
2223
AdGroupAds,
24+
AdGroupLabels,
2325
AdGroups,
26+
CampaignLabels,
2427
Campaigns,
2528
ClickView,
2629
DisplayKeywordPerformanceReport,
@@ -112,9 +115,12 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
112115

113116
streams = [
114117
AdGroupAds(**incremental_stream_config),
118+
AdGroupAdLabels(google_api),
115119
AdGroups(**incremental_stream_config),
120+
AdGroupLabels(google_api),
116121
Accounts(**incremental_stream_config),
117122
Campaigns(**incremental_stream_config),
123+
CampaignLabels(google_api),
118124
ClickView(**incremental_stream_config),
119125
]
120126

airbyte-integrations/connectors/source-google-ads/source_google_ads/streams.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
from abc import ABC
6-
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple
6+
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Union
77

88
import pendulum
99
from airbyte_cdk.models import SyncMode
@@ -111,7 +111,9 @@ class IncrementalGoogleAdsStream(GoogleAdsStream, ABC):
111111
primary_key = None
112112
range_days = 15 # date range is set to 15 days, because for conversion_window_days default value is 14. Range less than 15 days will break the integration tests.
113113

114-
def __init__(self, start_date: str, conversion_window_days: int, time_zone: [pendulum.timezone, str], end_date: str = None, **kwargs):
114+
def __init__(
115+
self, start_date: str, conversion_window_days: int, time_zone: Union[pendulum.timezone, str], end_date: str = None, **kwargs
116+
):
115117
self.conversion_window_days = conversion_window_days
116118
self._start_date = start_date
117119
self.time_zone = time_zone
@@ -231,6 +233,15 @@ class Campaigns(IncrementalGoogleAdsStream):
231233
primary_key = ["campaign.id", "segments.date"]
232234

233235

236+
class CampaignLabels(GoogleAdsStream):
237+
"""
238+
Campaign labels stream: https://developers.google.com/google-ads/api/fields/v8/campaign_label
239+
"""
240+
241+
# Note that this is a string type. Google doesn't return a more convenient identifier.
242+
primary_key = ["campaign_label.resource_name"]
243+
244+
234245
class AdGroups(IncrementalGoogleAdsStream):
235246
"""
236247
AdGroups stream: https://developers.google.com/google-ads/api/fields/v8/ad_group
@@ -239,6 +250,15 @@ class AdGroups(IncrementalGoogleAdsStream):
239250
primary_key = ["ad_group.id", "segments.date"]
240251

241252

253+
class AdGroupLabels(GoogleAdsStream):
254+
"""
255+
Ad Group Labels stream: https://developers.google.com/google-ads/api/fields/v8/ad_group_label
256+
"""
257+
258+
# Note that this is a string type. Google doesn't return a more convenient identifier.
259+
primary_key = ["ad_group_label.resource_name"]
260+
261+
242262
class AdGroupAds(IncrementalGoogleAdsStream):
243263
"""
244264
AdGroups stream: https://developers.google.com/google-ads/api/fields/v8/ad_group_ad
@@ -247,6 +267,15 @@ class AdGroupAds(IncrementalGoogleAdsStream):
247267
primary_key = ["ad_group_ad.ad.id", "segments.date"]
248268

249269

270+
class AdGroupAdLabels(GoogleAdsStream):
271+
"""
272+
Ad Group Ad Labels stream: https://developers.google.com/google-ads/api/fields/v8/ad_group_ad_label
273+
"""
274+
275+
# Note that this is a string type. Google doesn't return a more convenient identifier.
276+
primary_key = ["ad_group_ad_label.resource_name"]
277+
278+
250279
class AccountPerformanceReport(IncrementalGoogleAdsStream):
251280
"""
252281
AccountPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v8/customer

airbyte-integrations/connectors/source-google-ads/unit_tests/test_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_chunk_date_range():
5151
def test_streams_count(config):
5252
source = SourceGoogleAds()
5353
streams = source.streams(config)
54-
expected_streams_number = 16
54+
expected_streams_number = 19
5555
assert len(streams) == expected_streams_number
5656

5757

0 commit comments

Comments
 (0)