Skip to content

Commit fc51192

Browse files
chore(ads): restructure package
1 parent d7e1799 commit fc51192

File tree

15 files changed

+94
-53
lines changed

15 files changed

+94
-53
lines changed

libs/community/google/ads/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
```
2020
import os
2121
22-
from garf_io import writer
23-
from garf_google_ads import GoogleAdsApiReportFetcher
22+
from garf.io import writer
23+
from garf.community.google.ads import GoogleAdsApiReportFetcher
2424
2525
query = """
2626
SELECT
@@ -54,9 +54,9 @@ garf <PATH_TO_QUERIES> --source google-ads \
5454

5555
where:
5656

57-
* `<PATH_TO_QUERIES>` - local or remove files containing queries
58-
* `<OUTPUT_TYPE>` - output supported by [`garf-io` library](../garf_io/README.md).
59-
* `<SOURCE_PARAMETER=VALUE` - key-value pairs to refine fetching, check [available source parameters](#available-source-parameters).
57+
* `PATH_TO_QUERIES` - local or remove files containing queries
58+
* `output` - output supported by [`garf-io` library](https://google.github.io/garf/usage/writers/).
59+
* `SOURCE_PARAMETER=VALUE` - key-value pairs to refine fetching, check [available source parameters](#available-source-parameters).
6060

6161
### Available source parameters
6262

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Library for getting reports from Google Ads API."""
16+
17+
from garf.community.google.ads.api_clients import GoogleAdsApiClient
18+
from garf.community.google.ads.report_fetcher import GoogleAdsApiReportFetcher
19+
20+
__all__ = [
21+
'GoogleAdsApiClient',
22+
'GoogleAdsApiReportFetcher',
23+
]
24+
25+
__version__ = '0.0.5'

libs/community/google/ads/garf_google_ads/api_clients.py renamed to libs/community/google/ads/garf/community/google/ads/api_clients.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@
2929
import smart_open
3030
import tenacity
3131
import yaml
32-
from garf_core import api_clients
32+
from garf.community.google.ads import exceptions, query_editor
33+
from garf.core import api_clients
3334
from google import protobuf
3435
from google.ads.googleads import client as googleads_client
3536
from google.api_core import exceptions as google_exceptions
3637
from typing_extensions import override
3738

38-
from garf_google_ads import exceptions, query_editor
39-
4039
GOOGLE_ADS_API_VERSION: Final = googleads_client._DEFAULT_VERSION
4140
google_ads_service = importlib.import_module(
4241
f'google.ads.googleads.{GOOGLE_ADS_API_VERSION}.'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
from garf.community.google.ads.builtins import ocid_mapping
15+
16+
BUILTIN_QUERIES = {
17+
'ocid_mapping': ocid_mapping.get_ocid_mapping,
18+
}

libs/community/google/ads/garf_google_ads/builtins/ocid_mapping.py renamed to libs/community/google/ads/garf/community/google/ads/builtins/ocid_mapping.py

File renamed without changes.

libs/community/google/ads/garf_google_ads/exceptions.py renamed to libs/community/google/ads/garf/community/google/ads/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from garf_core import exceptions
15+
from garf.core import exceptions
1616

1717

1818
class GoogleAdsApiError(exceptions.GarfError):

libs/community/google/ads/garf_google_ads/parsers.py renamed to libs/community/google/ads/garf/community/google/ads/parsers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
from typing import Union, get_args
2424

2525
import proto # type: ignore
26-
from garf_core import parsers
26+
from garf.community.google.ads import api_clients, query_editor
27+
from garf.core import parsers
2728
from google import protobuf
2829
from proto.marshal.collections import repeated
2930
from typing_extensions import Self, TypeAlias
3031

31-
from garf_google_ads import api_clients, query_editor
32-
3332
google_ads_service = importlib.import_module(
3433
f'google.ads.googleads.{api_clients.GOOGLE_ADS_API_VERSION}.'
3534
'services.types.google_ads_service'

libs/community/google/ads/garf_google_ads/query_editor.py renamed to libs/community/google/ads/garf/community/google/ads/query_editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import re
1717

18-
from garf_core import query_editor
18+
from garf.core import query_editor
1919

2020

2121
class GoogleAdsApiQuery(query_editor.QuerySpecification):

libs/community/google/ads/garf_google_ads/report_fetcher.py renamed to libs/community/google/ads/garf/community/google/ads/report_fetcher.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
import operator
2020
import warnings
2121

22-
import garf_core
23-
24-
from garf_google_ads import (
22+
import garf.core
23+
from garf.community.google.ads import (
2524
GoogleAdsApiClient,
2625
builtins,
2726
exceptions,
@@ -34,13 +33,13 @@ class GoogleAdsApiReportFetcherError(exceptions.GoogleAdsApiError):
3433
"""Report fetcher specific error."""
3534

3635

37-
class GoogleAdsApiReportFetcher(garf_core.ApiReportFetcher):
36+
class GoogleAdsApiReportFetcher(garf.core.ApiReportFetcher):
3837
"""Defines report fetcher."""
3938

4039
def __init__(
4140
self,
4241
api_client: GoogleAdsApiClient | None = None,
43-
parser: garf_core.parsers.ProtoParser = parsers.GoogleAdsRowParser,
42+
parser: garf.core.parsers.ProtoParser = parsers.GoogleAdsRowParser,
4443
query_spec: query_editor.GoogleAdsApiQuery = (
4544
query_editor.GoogleAdsApiQuery
4645
),
@@ -64,12 +63,12 @@ def __init__(
6463
def fetch(
6564
self,
6665
query_specification: str | query_editor.GoogleAdsApiQuery,
67-
args: garf_core.query_editor.GarfQueryParameters | None = None,
66+
args: garf.core.query_editor.GarfQueryParameters | None = None,
6867
account: str | list[str] | None = None,
6968
expand_mcc: bool = False,
7069
customer_ids_query: str | None = None,
7170
**kwargs: str,
72-
) -> garf_core.GarfReport:
71+
) -> garf.core.GarfReport:
7372
"""Fetches data from Google Ads API.
7473
7574
Args:
@@ -196,7 +195,7 @@ def _get_customer_ids(
196195
account=[str(a) for a in child_customer_ids],
197196
)
198197
child_customer_ids = [
199-
row[0] if isinstance(row, garf_core.report.GarfRow) else row
198+
row[0] if isinstance(row, garf.core.report.GarfRow) else row
200199
for row in child_customer_ids
201200
]
202201

libs/community/google/ads/garf_google_ads/simulator.py renamed to libs/community/google/ads/garf/community/google/ads/simulator.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
import logging
2020
from typing import Any
2121

22-
import garf_core
23-
from garf_core import simulator
24-
25-
from garf_google_ads import parsers, query_editor
26-
from garf_google_ads.api_clients import GoogleAdsApiClient
22+
import garf.core
23+
from garf.community.google.ads import parsers, query_editor
24+
from garf.community.google.ads.api_clients import GoogleAdsApiClient
25+
from garf.core import simulator
2726

2827
logger = logging.getLogger(__name__)
2928

@@ -36,7 +35,7 @@ class GoogleAdsApiReportSimulator(simulator.ApiReportSimulator):
3635
def __init__(
3736
self,
3837
api_client: GoogleAdsApiClient | None = None,
39-
parser: garf_core.parsers.ProtoParser = parsers.GoogleAdsRowParser,
38+
parser: garf.core.parsers.ProtoParser = parsers.GoogleAdsRowParser,
4039
query_spec: query_editor.GoogleAdsApiQuery = (
4140
query_editor.GoogleAdsApiQuery
4241
),

0 commit comments

Comments
 (0)