Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 32.0.0
- Remove validation checking if developer token is present in configuration.
- Remove `use_cloud_org_for_api_access` configuration option.

* 31.4.0
- Google Ads API v25_1 release.

Expand Down
2 changes: 1 addition & 1 deletion google/ads/googleads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import google.ads.googleads.errors
import google.ads.googleads.util

VERSION = "31.4.0"
VERSION = "32.0.0"

# Checks if the current runtime is Python 3.10.
if sys.version_info.major == 3 and sys.version_info.minor <= 10:
Expand Down
23 changes: 3 additions & 20 deletions google/ads/googleads/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ def _get_client_kwargs(cls, config_data: Dict[str, Any]) -> Dict[str, Any]:
"linked_customer_id": config_data.get("linked_customer_id"),
"http_proxy": config_data.get("http_proxy"),
"use_proto_plus": config_data.get("use_proto_plus"),
"use_cloud_org_for_api_access": config_data.get(
"use_cloud_org_for_api_access"
),
"ads_assistant": config_data.get("ads_assistant"),
}

Expand Down Expand Up @@ -324,22 +321,21 @@ def load_from_storage(
def __init__(
self,
credentials: Dict[str, Any],
developer_token: str,
developer_token: Union[str, None] = None,
endpoint: Union[str, None] = None,
login_customer_id: Union[str, None] = None,
logging_config: Union[Dict[str, Any], None] = None,
linked_customer_id: Union[str, None] = None,
version: Union[str, None] = None,
http_proxy: Union[str, None] = None,
use_proto_plus: bool = False,
use_cloud_org_for_api_access: Union[str, None] = None,
ads_assistant: Union[str, None] = None,
):
"""Initializer for the GoogleAdsClient.

Args:
credentials: a google.oauth2.credentials.Credentials instance.
developer_token: a str developer token.
developer_token: an optional str developer token.
endpoint: a str specifying an optional alternative API endpoint.
login_customer_id: a str specifying a login customer ID.
logging_config: a dict specifying logging config options.
Expand All @@ -348,27 +344,19 @@ def __init__(
http_proxy: a str specifying the proxy URI through which to connect.
use_proto_plus: a bool specifying whether or not to use proto-plus
for protobuf message interfaces.
use_cloud_org_for_api_access: a str specifying whether to use the
Google Cloud Organization of your Google Cloud project instead
of developer token to determine your Google Ads API access
levels. Use this flag only if you are enrolled into a limited
pilot that supports this configuration.
ads_assistant: a str specifying the Google Ads API Assistant version.
"""
if logging_config:
logging.config.dictConfig(logging_config)

self.credentials: Credentials = credentials
self.developer_token: str = developer_token
self.developer_token: Union[str, None] = developer_token
self.endpoint: Union[str, None] = endpoint
self.login_customer_id: Union[str, None] = login_customer_id
self.linked_customer_id: Union[str, None] = linked_customer_id
self.version: Union[str, None] = version
self.http_proxy: Union[str, None] = http_proxy
self.use_proto_plus: bool = use_proto_plus
self.use_cloud_org_for_api_access: Union[str, None] = (
use_cloud_org_for_api_access
)
self.enums: _EnumGetter = _EnumGetter(self)
self._ads_assistant: Union[str, None] = ads_assistant

Expand Down Expand Up @@ -447,14 +435,12 @@ def get_service(
self.developer_token,
self.login_customer_id,
self.linked_customer_id,
self.use_cloud_org_for_api_access,
ads_assistant=self._ads_assistant,
),
AsyncUnaryStreamMetadataInterceptor(
self.developer_token,
self.login_customer_id,
self.linked_customer_id,
self.use_cloud_org_for_api_access,
ads_assistant=self._ads_assistant,
),
AsyncUnaryUnaryLoggingInterceptor(_logger, version, endpoint),
Expand Down Expand Up @@ -487,7 +473,6 @@ def get_service(
developer_token=self.developer_token,
login_customer_id=self.login_customer_id,
linked_customer_id=self.linked_customer_id,
use_cloud_org_for_api_access=self.use_cloud_org_for_api_access,
)

return service_client_class(transport=service_transport)
Expand All @@ -508,7 +493,6 @@ def get_service(
self.developer_token,
self.login_customer_id,
self.linked_customer_id,
self.use_cloud_org_for_api_access,
ads_assistant=self._ads_assistant,
),
LoggingInterceptor(_logger, version, endpoint),
Expand All @@ -530,7 +514,6 @@ def get_service(
developer_token=self.developer_token,
login_customer_id=self.login_customer_id,
linked_customer_id=self.linked_customer_id,
use_cloud_org_for_api_access=self.use_cloud_org_for_api_access,
)

return service_client_class(transport=service_transport)
Expand Down
4 changes: 2 additions & 2 deletions google/ads/googleads/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@


_ENV_PREFIX = "GOOGLE_ADS_"
_REQUIRED_KEYS = ("developer_token", "use_proto_plus")
_REQUIRED_KEYS = ("use_proto_plus",)
_OPTIONAL_KEYS = (
"developer_token",
"login_customer_id",
"endpoint",
"logging",
"linked_customer_id",
"http_proxy",
"use_cloud_org_for_api_access",
"use_application_default_credentials",
"ads_assistant",
)
Expand Down
24 changes: 5 additions & 19 deletions google/ads/googleads/interceptors/metadata_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ class MetadataInterceptor(

def __init__(
self,
developer_token: str,
developer_token: Optional[str] = None,
login_customer_id: Optional[str] = None,
linked_customer_id: Optional[str] = None,
use_cloud_org_for_api_access: Optional[bool] = None,
ads_assistant: Optional[str] = None,
):
"""Initialization method for this class.
Expand All @@ -72,16 +71,10 @@ def __init__(
developer_token: a str developer token.
login_customer_id: a str specifying a login customer ID.
linked_customer_id: a str specifying a linked customer ID.
use_cloud_org_for_api_access: a str specifying whether to use the
Google Cloud Organization of your Google Cloud project instead
of developer token to determine your Google Ads API access
levels. Use this flag only if you are enrolled into a limited
pilot that supports this configuration
ads_assistant: a str specifying the Google Ads API Assistant version.
"""
self.developer_token_meta: Tuple[str, str] = (
"developer-token",
developer_token,
self.developer_token_meta: Optional[Tuple[str, str]] = (
("developer-token", developer_token) if developer_token else None
)
self.login_customer_id_meta: Optional[Tuple[str, str]] = (
("login-customer-id", login_customer_id)
Expand All @@ -94,9 +87,6 @@ def __init__(
else None
)
self.ads_assistant: Optional[str] = ads_assistant
self.use_cloud_org_for_api_access: Optional[bool] = (
use_cloud_org_for_api_access
)

def _update_client_call_details_metadata(
self,
Expand Down Expand Up @@ -148,9 +138,7 @@ def _intercept(
else:
metadata: MetadataType = list(client_call_details.metadata)

# If self.use_cloud_org_for_api_access is not True, add the developer
# token to the request's metadata
if not self.use_cloud_org_for_api_access:
if self.developer_token_meta:
metadata.append(self.developer_token_meta)

if self.login_customer_id_meta:
Expand Down Expand Up @@ -266,9 +254,7 @@ async def _intercept(
else:
metadata: MetadataType = list(client_call_details.metadata)

# If self.use_cloud_org_for_api_access is not True, add the developer
# token to the request's metadata
if not self.use_cloud_org_for_api_access:
if self.developer_token_meta:
metadata.append(self.developer_token_meta)

if self.login_customer_id_meta:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "google-ads"
version = "31.4.0"
version = "32.0.0"
description = "Client library for the Google Ads API"
readme = "./README.rst"
requires-python = ">=3.9, <3.15"
Expand Down
22 changes: 0 additions & 22 deletions tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def test_get_client_kwargs_login_customer_id(self):
"logging_config": None,
"linked_customer_id": self.linked_customer_id,
"http_proxy": None,
"use_cloud_org_for_api_access": None,
"ads_assistant": None,
},
)
Expand Down Expand Up @@ -147,7 +146,6 @@ def test_get_client_kwargs_login_customer_id_as_None(self):
"logging_config": None,
"linked_customer_id": None,
"http_proxy": None,
"use_cloud_org_for_api_access": None,
"ads_assistant": None,
},
)
Expand Down Expand Up @@ -181,7 +179,6 @@ def test_get_client_kwargs_linked_customer_id(self):
"logging_config": None,
"linked_customer_id": self.linked_customer_id,
"http_proxy": None,
"use_cloud_org_for_api_access": None,
"ads_assistant": None,
},
)
Expand Down Expand Up @@ -215,7 +212,6 @@ def test_get_client_kwargs_linked_customer_id_as_none(self):
"logging_config": None,
"login_customer_id": None,
"http_proxy": None,
"use_cloud_org_for_api_access": None,
"ads_assistant": None,
},
)
Expand Down Expand Up @@ -249,7 +245,6 @@ def test_get_client_kwargs(self):
"logging_config": None,
"linked_customer_id": None,
"http_proxy": self.http_proxy,
"use_cloud_org_for_api_access": None,
"ads_assistant": None,
},
)
Expand Down Expand Up @@ -284,7 +279,6 @@ def test_get_client_kwargs_custom_endpoint(self):
"logging_config": None,
"linked_customer_id": None,
"http_proxy": None,
"use_cloud_org_for_api_access": None,
"ads_assistant": None,
},
)
Expand Down Expand Up @@ -323,7 +317,6 @@ def test_load_from_env(self):
linked_customer_id=None,
version=None,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -361,7 +354,6 @@ def test_load_from_env_versioned(self):
linked_customer_id=None,
version="v4",
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -398,7 +390,6 @@ def test_load_from_dict(self):
linked_customer_id=None,
version=None,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -435,7 +426,6 @@ def test_load_from_dict_versioned(self):
linked_customer_id=None,
version="v4",
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -479,7 +469,6 @@ def test_load_from_dict_login_customer_id_explicit_none(self):
linked_customer_id=None,
version=None,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -516,7 +505,6 @@ def test_load_from_string(self):
linked_customer_id=None,
version=None,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -555,7 +543,6 @@ def test_load_from_string_versioned(self):
linked_customer_id=None,
version="v4",
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -963,7 +950,6 @@ def test_load_http_proxy_from_env(self):
linked_customer_id=None,
version=None,
http_proxy=self.http_proxy,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1001,7 +987,6 @@ def test_load_http_proxy_from_dict(self):
linked_customer_id=None,
version=None,
http_proxy=self.http_proxy,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1039,7 +1024,6 @@ def test_load_http_proxy_from_string(self):
linked_customer_id=None,
version=None,
http_proxy=self.http_proxy,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1114,7 +1098,6 @@ def test_load_http_proxy_from_storage(self):
linked_customer_id=None,
version=None,
http_proxy=self.http_proxy,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1159,7 +1142,6 @@ def test_load_from_storage(self):
linked_customer_id=None,
version=None,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1204,7 +1186,6 @@ def test_load_from_storage_versioned(self):
linked_customer_id=None,
version="v4",
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1251,7 +1232,6 @@ def test_load_from_storage_login_cid_int(self):
linked_customer_id=None,
version=None,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1290,7 +1270,6 @@ def test_load_from_storage_custom_path(self):
linked_customer_id=None,
version=None,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)

Expand Down Expand Up @@ -1356,6 +1335,5 @@ def test_load_from_storage_service_account_config(self):
linked_customer_id=None,
version=latest_version,
http_proxy=None,
use_cloud_org_for_api_access=None,
ads_assistant=None,
)
Loading