Skip to content

Commit 8e3d050

Browse files
committed
add campaign label stream
1 parent 5d79044 commit 8e3d050

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"ad_group_ads": "ad_group_ad",
1717
"ad_groups": "ad_group",
1818
"campaigns": "campaign",
19+
"campaign_labels": "campaign_label",
1920
"account_performance_report": "customer",
2021
"ad_group_ad_report": "ad_group_ad",
2122
"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+
"campaign.id": {
6+
"type": ["null", "integer"]
7+
},
8+
"label.id": {
9+
"type": ["null", "integer"]
10+
},
11+
"label.name": {
12+
"type": ["null", "integer"]
13+
},
14+
"campaign_label.resource_name": {
15+
"type": ["null", "string"]
16+
}
17+
}
18+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
AdGroupAdReport,
2222
AdGroupAds,
2323
AdGroups,
24+
CampaignLabels,
2425
Campaigns,
2526
ClickView,
2627
DisplayKeywordPerformanceReport,
@@ -115,6 +116,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
115116
AdGroups(**incremental_stream_config),
116117
Accounts(**incremental_stream_config),
117118
Campaigns(**incremental_stream_config),
119+
CampaignLabels(google_api),
118120
ClickView(**incremental_stream_config),
119121
]
120122

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

Lines changed: 15 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,17 @@ 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+
def __init__(self, api):
242+
super().__init__(api)
243+
244+
primary_key = ["campaign_label.resource_name"]
245+
246+
234247
class AdGroups(IncrementalGoogleAdsStream):
235248
"""
236249
AdGroups stream: https://developers.google.com/google-ads/api/fields/v8/ad_group

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 = 17
5555
assert len(streams) == expected_streams_number
5656

5757

0 commit comments

Comments
 (0)