Skip to content

Commit

Permalink
source-google-ads: upgrade to v17
Browse files Browse the repository at this point in the history
  • Loading branch information
Luishfs committed Oct 2, 2024
1 parent 75c2d46 commit f3fea97
Show file tree
Hide file tree
Showing 11 changed files with 850 additions and 782 deletions.
20 changes: 5 additions & 15 deletions source-google-ads/acmeCo/ad_group_ad_report.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ properties:
- "null"
- string
segments.ad_network_type:
type:
- "null"
- string
type: string
ad_group_ad.ad_strength:
type:
- "null"
Expand Down Expand Up @@ -149,9 +147,7 @@ properties:
- "null"
- string
campaign.id:
type:
- "null"
- integer
type: integer
campaign.name:
type:
- "null"
Expand Down Expand Up @@ -229,9 +225,7 @@ properties:
- "null"
- number
segments.date:
type:
- "null"
- string
type: string
format: date
segments.day_of_week:
type:
Expand Down Expand Up @@ -294,9 +288,7 @@ properties:
- "null"
- string
customer.id:
type:
- "null"
- integer
type: integer
ad_group_ad.ad.legacy_responsive_display_ad.format_setting:
type:
- "null"
Expand Down Expand Up @@ -326,9 +318,7 @@ properties:
- "null"
- string
ad_group_ad.ad.id:
type:
- "null"
- integer
type: integer
ad_group_ad.ad.image_ad.image_url:
type:
- "null"
Expand Down
1,582 changes: 831 additions & 751 deletions source-google-ads/poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion source-google-ads/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ authors = ["Jonathan Wihl <jonathan@estuary.dev>"]
airbyte-cdk = "^0.52"
estuary-cdk = {path="../estuary-cdk", develop = true}
freezegun = "^1.4.0"
google-ads = "^23.1.0"
google-ads = "^25.0.0"
pydantic = "==1.10.14"
python = ">=3.11,<3.13"
types-requests = "^2.31"

Expand Down
5 changes: 2 additions & 3 deletions source-google-ads/source_google_ads/google_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from airbyte_cdk.models import FailureType
from airbyte_cdk.utils import AirbyteTracedException
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.v15.services.types.google_ads_service import GoogleAdsRow, SearchGoogleAdsResponse
from google.ads.googleads.v17.services.types.google_ads_service import GoogleAdsRow, SearchGoogleAdsResponse
from google.api_core.exceptions import ServerError, TooManyRequests
from google.auth import exceptions
from proto.marshal.collections import Repeated, RepeatedComposite
Expand All @@ -36,7 +36,7 @@
"geographic_report": "geographic_view",
"keyword_report": "keyword_view",
}
API_VERSION = "v15"
API_VERSION = "v17"
logger = logging.getLogger("airbyte")


Expand Down Expand Up @@ -70,7 +70,6 @@ def send_request(self, query: str, customer_id: str) -> Iterator[SearchGoogleAds
client = self.client
search_request = client.get_type("SearchGoogleAdsRequest")
search_request.query = query
search_request.page_size = self.DEFAULT_PAGE_SIZE
search_request.customer_id = customer_id
return [self.ga_service.search(search_request)]

Expand Down
4 changes: 2 additions & 2 deletions source-google-ads/source_google_ads/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.utils import AirbyteTracedException
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v15.errors.types.authorization_error import AuthorizationErrorEnum
from google.ads.googleads.v17.errors.types.authorization_error import AuthorizationErrorEnum
from pendulum import parse, today

from .custom_query_stream import CustomQuery, IncrementalCustomQuery
Expand Down Expand Up @@ -51,7 +51,7 @@ def _validate_and_transform(config: Mapping[str, Any]):
try:
query["query"] = GAQL.parse(query["query"])
except ValueError:
message = f"The custom GAQL query {query['table_name']} failed. Validate your GAQL query with the Google Ads query validator. https://developers.google.com/google-ads/api/fields/v15/query_validator"
message = f"The custom GAQL query {query['table_name']} failed. Validate your GAQL query with the Google Ads query validator. https://developers.google.com/google-ads/api/fields/v17/query_validator"
raise AirbyteTracedException(message=message, failure_type=FailureType.config_error)
return config

Expand Down
6 changes: 3 additions & 3 deletions source-google-ads/source_google_ads/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from airbyte_cdk.sources.streams import IncrementalMixin, Stream
from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v15.errors.types.authorization_error import AuthorizationErrorEnum
from google.ads.googleads.v15.errors.types.request_error import RequestErrorEnum
from google.ads.googleads.v15.services.services.google_ads_service.pagers import SearchPager
from google.ads.googleads.v17.errors.types.authorization_error import AuthorizationErrorEnum
from google.ads.googleads.v17.errors.types.request_error import RequestErrorEnum
from google.ads.googleads.v17.services.services.google_ads_service.pagers import SearchPager

from .google_ads import GoogleAds
from .models import Customer
Expand Down
2 changes: 1 addition & 1 deletion source-google-ads/tests/common.py
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.v15 import GoogleAdsFailure
from google.ads.googleads.v17 import GoogleAdsFailure


class MockSearchRequest:
Expand Down
2 changes: 0 additions & 2 deletions source-google-ads/tests/test_google_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ def test_send_request(mocker, customers):
mocker.patch("source_google_ads.google_ads.GoogleAdsClient.get_service", return_value=MockGoogleAdsService())
google_ads_client = GoogleAds(**SAMPLE_CONFIG)
query = "Query"
page_size = 1000
customer_id = next(iter(customers)).id
response = list(google_ads_client.send_request(query, customer_id=customer_id))

assert response[0].customer_id == customer_id
assert response[0].query == query
assert response[0].page_size == page_size


def test_get_fields_from_schema():
Expand Down
2 changes: 1 addition & 1 deletion source-google-ads/tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from airbyte_cdk import AirbyteLogger
from freezegun import freeze_time
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v15.errors.types.authorization_error import AuthorizationErrorEnum
from google.ads.googleads.v17.errors.types.authorization_error import AuthorizationErrorEnum
from pendulum import today
from source_google_ads.custom_query_stream import IncrementalCustomQuery
from source_google_ads.google_ads import GoogleAds
Expand Down
4 changes: 2 additions & 2 deletions source-google-ads/tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import pytest
from airbyte_cdk.models import SyncMode
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v15.errors.types.errors import ErrorCode, GoogleAdsError, GoogleAdsFailure
from google.ads.googleads.v15.errors.types.request_error import RequestErrorEnum
from google.ads.googleads.v17.errors.types.errors import ErrorCode, GoogleAdsError, GoogleAdsFailure
from google.ads.googleads.v17.errors.types.request_error import RequestErrorEnum
from google.api_core.exceptions import DataLoss, InternalServerError, ResourceExhausted, TooManyRequests
from grpc import RpcError
from source_google_ads.google_ads import GoogleAds
Expand Down
2 changes: 1 addition & 1 deletion source-google-ads/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_parse_GAQL_ok():
def test_parse_GAQL_fail(config):
with pytest.raises(AirbyteTracedException) as e:
SourceGoogleAds._validate_and_transform(config)
expected_message = "The custom GAQL query test_table failed. Validate your GAQL query with the Google Ads query validator. https://developers.google.com/google-ads/api/fields/v15/query_validator"
expected_message = "The custom GAQL query test_table failed. Validate your GAQL query with the Google Ads query validator. https://developers.google.com/google-ads/api/fields/v17/query_validator"
assert e.value.message == expected_message


Expand Down

0 comments on commit f3fea97

Please sign in to comment.