Skip to content

Commit

Permalink
🎉Source Google Ads: Updated API version from v9 to v11 (#14614)
Browse files Browse the repository at this point in the history
* Updated API version from v9 to v11

* Updated PR number

* Updated after review

* auto-bump connector version

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
  • Loading branch information
lazebnyi and octavia-squidington-iii authored Jul 13, 2022
1 parent 2285c2e commit 612ade9
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
- name: Google Ads
sourceDefinitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
dockerRepository: airbyte/source-google-ads
dockerImageTag: 0.1.42
dockerImageTag: 0.1.43
documentationUrl: https://docs.airbyte.io/integrations/sources/google-ads
icon: google-adwords.svg
sourceType: api
Expand Down
4 changes: 2 additions & 2 deletions airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-google-ads:0.1.42"
- dockerImage: "airbyte/source-google-ads:0.1.43"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/google-ads"
connectionSpecification:
Expand Down Expand Up @@ -2890,7 +2890,7 @@
title: "Custom Query"
description: "A custom defined GAQL query for building the report.\
\ Should not contain segments.date expression because it is used\
\ by incremental streams. See Google's <a href=\"https://developers.google.com/google-ads/api/fields/v9/overview_query_builder\"\
\ by incremental streams. See Google's <a href=\"https://developers.google.com/google-ads/api/fields/v11/overview_query_builder\"\
>query builder</a> for more information."
examples:
- "SELECT segments.ad_destination_type, campaign.advertising_channel_sub_type\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ COPY main.py ./

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

LABEL io.airbyte.version=0.1.42
LABEL io.airbyte.version=0.1.43
LABEL io.airbyte.name=airbyte/source-google-ads
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integrat
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named.
First install test dependencies into your virtual environment:
```
pip install .[tests]
pip install -e ".[tests]"
```
### Unit Tests
To run unit tests locally, from the connector directory run:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-google-ads/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# pin protobuf==3.20.0 as other versions may cause problems on different architectures
# (see https://github.com/airbytehq/airbyte/issues/13580)
MAIN_REQUIREMENTS = ["airbyte-cdk~=0.1", "google-ads==15.1.1", "protobuf==3.20.0", "pendulum"]
MAIN_REQUIREMENTS = ["airbyte-cdk~=0.1", "google-ads==17.0.0", "protobuf==3.20.0", "pendulum"]

TEST_REQUIREMENTS = ["pytest~=6.1", "pytest-mock", "freezegun", "requests-mock"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_json_schema(self) -> Dict[str, Any]:
# Represents protobuf message and could be anything, set custom
# attribute "protobuf_message" to convert it to a string (or
# array of strings) later.
# https://developers.google.com/google-ads/api/reference/rpc/v9/GoogleAdsFieldDataTypeEnum.GoogleAdsFieldDataType?hl=en#message
# https://developers.google.com/google-ads/api/reference/rpc/v11/GoogleAdsFieldDataTypeEnum.GoogleAdsFieldDataType?hl=en#message
if node.is_repeated:
output_type = ["array", "null"]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pendulum
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.v9.services.types.google_ads_service import GoogleAdsRow, SearchGoogleAdsResponse
from google.ads.googleads.v11.services.types.google_ads_service import GoogleAdsRow, SearchGoogleAdsResponse
from proto.marshal.collections import Repeated, RepeatedComposite

REPORT_MAPPING = {
Expand All @@ -30,7 +30,7 @@
"geographic_report": "geographic_view",
"keyword_report": "keyword_view",
}
API_VERSION = "v9"
API_VERSION = "v11"


class GoogleAds:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,13 @@
"type": "string"
}
},
"ad_group_ad.ad.video_ad.discovery.description1": {
"ad_group_ad.ad.video_ad.in_feed.description1": {
"type": ["null", "string"]
},
"ad_group_ad.ad.video_ad.discovery.description2": {
"ad_group_ad.ad.video_ad.in_feed.description2": {
"type": ["null", "string"]
},
"ad_group_ad.ad.video_ad.discovery.headline": {
"ad_group_ad.ad.video_ad.in_feed.headline": {
"type": ["null", "string"]
},
"ad_group_ad.ad.video_ad.in_stream.action_button_label": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"campaign.maximize_conversion_value.target_roas": {
"type": ["null", "number"]
},
"campaign.maximize_conversions.target_cpa": {
"campaign.maximize_conversions.target_cpa_micros": {
"type": ["null", "integer"]
},
"campaign.name": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"query": {
"type": "string",
"title": "Custom Query",
"description": "A custom defined GAQL query for building the report. Should not contain segments.date expression because it is used by incremental streams. See Google's <a href=\"https://developers.google.com/google-ads/api/fields/v9/overview_query_builder\">query builder</a> for more information.",
"description": "A custom defined GAQL query for building the report. Should not contain segments.date expression because it is used by incremental streams. See Google's <a href=\"https://developers.google.com/google-ads/api/fields/v11/overview_query_builder\">query builder</a> for more information.",
"examples": [
"SELECT segments.ad_destination_type, campaign.advertising_channel_sub_type FROM campaign WHERE campaign.status = 'PAUSED'"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources.streams import IncrementalMixin, Stream
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v9.errors.types.authorization_error import AuthorizationErrorEnum
from google.ads.googleads.v9.errors.types.request_error import RequestErrorEnum
from google.ads.googleads.v9.services.services.google_ads_service.pagers import SearchPager
from google.ads.googleads.v11.errors.types.authorization_error import AuthorizationErrorEnum
from google.ads.googleads.v11.errors.types.request_error import RequestErrorEnum
from google.ads.googleads.v11.services.services.google_ads_service.pagers import SearchPager

from .google_ads import GoogleAds
from .models import Customer
Expand Down Expand Up @@ -236,7 +236,7 @@ def get_query(self, stream_slice: Mapping[str, Any] = None) -> str:

class Accounts(IncrementalGoogleAdsStream):
"""
Accounts stream: https://developers.google.com/google-ads/api/fields/v9/customer
Accounts stream: https://developers.google.com/google-ads/api/fields/v11/customer
"""

primary_key = ["customer.id", "segments.date"]
Expand All @@ -253,15 +253,15 @@ class ServiceAccounts(GoogleAdsStream):

class Campaigns(IncrementalGoogleAdsStream):
"""
Campaigns stream: https://developers.google.com/google-ads/api/fields/v9/campaign
Campaigns stream: https://developers.google.com/google-ads/api/fields/v11/campaign
"""

primary_key = ["campaign.id", "segments.date"]


class CampaignLabels(GoogleAdsStream):
"""
Campaign labels stream: https://developers.google.com/google-ads/api/fields/v9/campaign_label
Campaign labels stream: https://developers.google.com/google-ads/api/fields/v11/campaign_label
"""

# Note that this is a string type. Google doesn't return a more convenient identifier.
Expand All @@ -270,15 +270,15 @@ class CampaignLabels(GoogleAdsStream):

class AdGroups(IncrementalGoogleAdsStream):
"""
AdGroups stream: https://developers.google.com/google-ads/api/fields/v9/ad_group
AdGroups stream: https://developers.google.com/google-ads/api/fields/v11/ad_group
"""

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


class AdGroupLabels(GoogleAdsStream):
"""
Ad Group Labels stream: https://developers.google.com/google-ads/api/fields/v9/ad_group_label
Ad Group Labels stream: https://developers.google.com/google-ads/api/fields/v11/ad_group_label
"""

# Note that this is a string type. Google doesn't return a more convenient identifier.
Expand All @@ -287,15 +287,15 @@ class AdGroupLabels(GoogleAdsStream):

class AdGroupAds(IncrementalGoogleAdsStream):
"""
AdGroups stream: https://developers.google.com/google-ads/api/fields/v9/ad_group_ad
AdGroups stream: https://developers.google.com/google-ads/api/fields/v11/ad_group_ad
"""

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


class AdGroupAdLabels(GoogleAdsStream):
"""
Ad Group Ad Labels stream: https://developers.google.com/google-ads/api/fields/v9/ad_group_ad_label
Ad Group Ad Labels stream: https://developers.google.com/google-ads/api/fields/v11/ad_group_ad_label
"""

# Note that this is a string type. Google doesn't return a more convenient identifier.
Expand All @@ -304,61 +304,61 @@ class AdGroupAdLabels(GoogleAdsStream):

class AccountPerformanceReport(IncrementalGoogleAdsStream):
"""
AccountPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v9/customer
AccountPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v11/customer
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#account_performance
"""


class AdGroupAdReport(IncrementalGoogleAdsStream):
"""
AdGroupAdReport stream: https://developers.google.com/google-ads/api/fields/v9/ad_group_ad
AdGroupAdReport stream: https://developers.google.com/google-ads/api/fields/v11/ad_group_ad
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#ad_performance
"""


class DisplayKeywordPerformanceReport(IncrementalGoogleAdsStream):
"""
DisplayKeywordPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v9/display_keyword_view
DisplayKeywordPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v11/display_keyword_view
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#display_keyword_performance
"""


class DisplayTopicsPerformanceReport(IncrementalGoogleAdsStream):
"""
DisplayTopicsPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v9/topic_view
DisplayTopicsPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v11/topic_view
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#display_topics_performance
"""


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


class UserLocationReport(IncrementalGoogleAdsStream):
"""
UserLocationReport stream: https://developers.google.com/google-ads/api/fields/v9/user_location_view
UserLocationReport stream: https://developers.google.com/google-ads/api/fields/v11/user_location_view
Google Ads API field mapping: https://developers.google.com/google-ads/api/docs/migration/mapping#geo_performance
"""


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


class KeywordReport(IncrementalGoogleAdsStream):
"""
UserLocationReport stream: https://developers.google.com/google-ads/api/fields/v9/keyword_view
UserLocationReport stream: https://developers.google.com/google-ads/api/fields/v11/keyword_view
"""


class ClickView(IncrementalGoogleAdsStream):
"""
ClickView stream: https://developers.google.com/google-ads/api/reference/rpc/v9/ClickView
ClickView stream: https://developers.google.com/google-ads/api/reference/rpc/v11/ClickView
"""

primary_key = ["click_view.gclid", "segments.date", "segments.ad_network_type"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json

from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v9 import GoogleAdsFailure
from google.ads.googleads.v11 import GoogleAdsFailure


class MockSearchRequest:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from airbyte_cdk import AirbyteLogger
from freezegun import freeze_time
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v9.errors.types.authorization_error import AuthorizationErrorEnum
from google.ads.googleads.v11.errors.types.authorization_error import AuthorizationErrorEnum
from pendulum import today
from source_google_ads.custom_query_stream import CustomQuery
from source_google_ads.google_ads import GoogleAds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import pytest
from airbyte_cdk.models import SyncMode
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v9.errors.types.errors import ErrorCode, GoogleAdsError, GoogleAdsFailure
from google.ads.googleads.v9.errors.types.request_error import RequestErrorEnum
from google.ads.googleads.v11.errors.types.errors import ErrorCode, GoogleAdsError, GoogleAdsFailure
from google.ads.googleads.v11.errors.types.request_error import RequestErrorEnum
from grpc import RpcError
from source_google_ads.google_ads import GoogleAds
from source_google_ads.streams import ClickView
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/google-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ This source is constrained by whatever API limits are set for the Google Ads tha

| Version | Date | Pull Request | Subject |
|:---------|:-----------|:---------------------------------------------------------|:---------------------------------------------------------------------------------------------|
| `0.1.43` | 2022-07-12 | [14614](https://github.com/airbytehq/airbyte/pull/14614) | Update API version to `v11`, update `google-ads` to 17.0.0 |
| `0.1.42` | 2022-06-08 | [13624](https://github.com/airbytehq/airbyte/pull/13624) | Update `google-ads` to 15.1.1, pin `protobuf==3.20.0` to work on MacOS M1 machines (AMD) |
| `0.1.41` | 2022-06-08 | [13618](https://github.com/airbytehq/airbyte/pull/13618) | Add missing dependency |
| `0.1.40` | 2022-06-02 | [13423](https://github.com/airbytehq/airbyte/pull/13423) | Fix the missing data [issue](https://github.com/airbytehq/airbyte/issues/12999) |
Expand Down

0 comments on commit 612ade9

Please sign in to comment.