Skip to content

Commit 8e72aca

Browse files
committed
feat: update image to us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209
1 parent a0abb35 commit 8e72aca

File tree

2,602 files changed

+284298
-109103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,602 files changed

+284298
-109103
lines changed

packages/google-ads-admanager/google/ads/admanager_v1/__init__.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,20 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
import sys
17+
18+
import google.api_core as api_core
19+
1620
from google.ads.admanager_v1 import gapic_version as package_version
1721

1822
__version__ = package_version.__version__
1923

24+
if sys.version_info >= (3, 8): # pragma: NO COVER
25+
from importlib import metadata
26+
else: # pragma: NO COVER
27+
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
28+
# this code path once we drop support for Python 3.7
29+
import importlib_metadata as metadata
2030

2131
from .services.ad_break_service import AdBreakServiceClient
2232
from .services.ad_review_center_ad_service import AdReviewCenterAdServiceClient
@@ -484,6 +494,100 @@
484494
from .types.video_position_enum import VideoPositionEnum
485495
from .types.web_property import WebProperty
486496

497+
if hasattr(api_core, "check_python_version") and hasattr(
498+
api_core, "check_dependency_versions"
499+
): # pragma: NO COVER
500+
api_core.check_python_version("google.ads.admanager_v1") # type: ignore
501+
api_core.check_dependency_versions("google.ads.admanager_v1") # type: ignore
502+
else: # pragma: NO COVER
503+
# An older version of api_core is installed which does not define the
504+
# functions above. We do equivalent checks manually.
505+
try:
506+
import sys
507+
import warnings
508+
509+
_py_version_str = sys.version.split()[0]
510+
_package_label = "google.ads.admanager_v1"
511+
if sys.version_info < (3, 9):
512+
warnings.warn(
513+
"You are using a non-supported Python version "
514+
+ f"({_py_version_str}). Google will not post any further "
515+
+ f"updates to {_package_label} supporting this Python version. "
516+
+ "Please upgrade to the latest Python version, or at "
517+
+ f"least to Python 3.9, and then update {_package_label}.",
518+
FutureWarning,
519+
)
520+
if sys.version_info[:2] == (3, 9):
521+
warnings.warn(
522+
f"You are using a Python version ({_py_version_str}) "
523+
+ f"which Google will stop supporting in {_package_label} in "
524+
+ "January 2026. Please "
525+
+ "upgrade to the latest Python version, or at "
526+
+ "least to Python 3.10, before then, and "
527+
+ f"then update {_package_label}.",
528+
FutureWarning,
529+
)
530+
531+
def parse_version_to_tuple(version_string: str):
532+
"""Safely converts a semantic version string to a comparable tuple of integers.
533+
Example: "4.25.8" -> (4, 25, 8)
534+
Ignores non-numeric parts and handles common version formats.
535+
Args:
536+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
537+
Returns:
538+
Tuple of integers for the parsed version string.
539+
"""
540+
parts = []
541+
for part in version_string.split("."):
542+
try:
543+
parts.append(int(part))
544+
except ValueError:
545+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
546+
# This is a simplification compared to 'packaging.parse_version', but sufficient
547+
# for comparing strictly numeric semantic versions.
548+
break
549+
return tuple(parts)
550+
551+
def _get_version(dependency_name):
552+
try:
553+
version_string: str = metadata.version(dependency_name)
554+
parsed_version = parse_version_to_tuple(version_string)
555+
return (parsed_version, version_string)
556+
except Exception:
557+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
558+
# or errors during parse_version_to_tuple
559+
return (None, "--")
560+
561+
_dependency_package = "google.protobuf"
562+
_next_supported_version = "4.25.8"
563+
_next_supported_version_tuple = (4, 25, 8)
564+
_recommendation = " (we recommend 6.x)"
565+
(_version_used, _version_used_string) = _get_version(_dependency_package)
566+
if _version_used and _version_used < _next_supported_version_tuple:
567+
warnings.warn(
568+
f"Package {_package_label} depends on "
569+
+ f"{_dependency_package}, currently installed at version "
570+
+ f"{_version_used_string}. Future updates to "
571+
+ f"{_package_label} will require {_dependency_package} at "
572+
+ f"version {_next_supported_version} or higher{_recommendation}."
573+
+ " Please ensure "
574+
+ "that either (a) your Python environment doesn't pin the "
575+
+ f"version of {_dependency_package}, so that updates to "
576+
+ f"{_package_label} can require the higher version, or "
577+
+ "(b) you manually update your Python environment to use at "
578+
+ f"least version {_next_supported_version} of "
579+
+ f"{_dependency_package}.",
580+
FutureWarning,
581+
)
582+
except Exception:
583+
warnings.warn(
584+
"Could not determine the version of Python "
585+
+ "currently being used. To continue receiving "
586+
+ "updates for {_package_label}, ensure you are "
587+
+ "using a supported version of Python; see "
588+
+ "https://devguide.python.org/versions/"
589+
)
590+
487591
__all__ = (
488592
"AdBreak",
489593
"AdBreakServiceClient",

packages/google-ads-admanager/google/ads/admanager_v1/services/ad_break_service/client.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,34 @@ def _get_default_mtls_endpoint(api_endpoint):
154154
_DEFAULT_ENDPOINT_TEMPLATE = "admanager.{UNIVERSE_DOMAIN}"
155155
_DEFAULT_UNIVERSE = "googleapis.com"
156156

157+
@staticmethod
158+
def _use_client_cert_effective():
159+
"""Returns whether client certificate should be used for mTLS if the
160+
google-auth version supports should_use_client_cert automatic mTLS enablement.
161+
162+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
163+
164+
Returns:
165+
bool: whether client certificate should be used for mTLS
166+
Raises:
167+
ValueError: (If using a version of google-auth without should_use_client_cert and
168+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
169+
"""
170+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
171+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
172+
return mtls.should_use_client_cert()
173+
else: # pragma: NO COVER
174+
# if unsupported, fallback to reading from env var
175+
use_client_cert_str = os.getenv(
176+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
177+
).lower()
178+
if use_client_cert_str not in ("true", "false"):
179+
raise ValueError(
180+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
181+
" either `true` or `false`"
182+
)
183+
return use_client_cert_str == "true"
184+
157185
@classmethod
158186
def from_service_account_info(cls, info: dict, *args, **kwargs):
159187
"""Creates an instance of this client using the provided credentials
@@ -361,20 +389,16 @@ def get_mtls_endpoint_and_cert_source(
361389
)
362390
if client_options is None:
363391
client_options = client_options_lib.ClientOptions()
364-
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
392+
use_client_cert = AdBreakServiceClient._use_client_cert_effective()
365393
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
366-
if use_client_cert not in ("true", "false"):
367-
raise ValueError(
368-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
369-
)
370394
if use_mtls_endpoint not in ("auto", "never", "always"):
371395
raise MutualTLSChannelError(
372396
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
373397
)
374398

375399
# Figure out the client cert source to use.
376400
client_cert_source = None
377-
if use_client_cert == "true":
401+
if use_client_cert:
378402
if client_options.client_cert_source:
379403
client_cert_source = client_options.client_cert_source
380404
elif mtls.has_default_client_cert_source():
@@ -406,20 +430,14 @@ def _read_environment_variables():
406430
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
407431
is not any of ["auto", "never", "always"].
408432
"""
409-
use_client_cert = os.getenv(
410-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
411-
).lower()
433+
use_client_cert = AdBreakServiceClient._use_client_cert_effective()
412434
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
413435
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
414-
if use_client_cert not in ("true", "false"):
415-
raise ValueError(
416-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
417-
)
418436
if use_mtls_endpoint not in ("auto", "never", "always"):
419437
raise MutualTLSChannelError(
420438
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
421439
)
422-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
440+
return use_client_cert, use_mtls_endpoint, universe_domain_env
423441

424442
@staticmethod
425443
def _get_client_cert_source(provided_cert_source, use_cert_flag):

packages/google-ads-admanager/google/ads/admanager_v1/services/ad_review_center_ad_service/client.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,34 @@ def _get_default_mtls_endpoint(api_endpoint):
152152
_DEFAULT_ENDPOINT_TEMPLATE = "admanager.{UNIVERSE_DOMAIN}"
153153
_DEFAULT_UNIVERSE = "googleapis.com"
154154

155+
@staticmethod
156+
def _use_client_cert_effective():
157+
"""Returns whether client certificate should be used for mTLS if the
158+
google-auth version supports should_use_client_cert automatic mTLS enablement.
159+
160+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
161+
162+
Returns:
163+
bool: whether client certificate should be used for mTLS
164+
Raises:
165+
ValueError: (If using a version of google-auth without should_use_client_cert and
166+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
167+
"""
168+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
169+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
170+
return mtls.should_use_client_cert()
171+
else: # pragma: NO COVER
172+
# if unsupported, fallback to reading from env var
173+
use_client_cert_str = os.getenv(
174+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
175+
).lower()
176+
if use_client_cert_str not in ("true", "false"):
177+
raise ValueError(
178+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
179+
" either `true` or `false`"
180+
)
181+
return use_client_cert_str == "true"
182+
155183
@classmethod
156184
def from_service_account_info(cls, info: dict, *args, **kwargs):
157185
"""Creates an instance of this client using the provided credentials
@@ -359,20 +387,16 @@ def get_mtls_endpoint_and_cert_source(
359387
)
360388
if client_options is None:
361389
client_options = client_options_lib.ClientOptions()
362-
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
390+
use_client_cert = AdReviewCenterAdServiceClient._use_client_cert_effective()
363391
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
364-
if use_client_cert not in ("true", "false"):
365-
raise ValueError(
366-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
367-
)
368392
if use_mtls_endpoint not in ("auto", "never", "always"):
369393
raise MutualTLSChannelError(
370394
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
371395
)
372396

373397
# Figure out the client cert source to use.
374398
client_cert_source = None
375-
if use_client_cert == "true":
399+
if use_client_cert:
376400
if client_options.client_cert_source:
377401
client_cert_source = client_options.client_cert_source
378402
elif mtls.has_default_client_cert_source():
@@ -404,20 +428,14 @@ def _read_environment_variables():
404428
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
405429
is not any of ["auto", "never", "always"].
406430
"""
407-
use_client_cert = os.getenv(
408-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
409-
).lower()
431+
use_client_cert = AdReviewCenterAdServiceClient._use_client_cert_effective()
410432
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
411433
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
412-
if use_client_cert not in ("true", "false"):
413-
raise ValueError(
414-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
415-
)
416434
if use_mtls_endpoint not in ("auto", "never", "always"):
417435
raise MutualTLSChannelError(
418436
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
419437
)
420-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
438+
return use_client_cert, use_mtls_endpoint, universe_domain_env
421439

422440
@staticmethod
423441
def _get_client_cert_source(provided_cert_source, use_cert_flag):

packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/client.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,34 @@ def _get_default_mtls_endpoint(api_endpoint):
153153
_DEFAULT_ENDPOINT_TEMPLATE = "admanager.{UNIVERSE_DOMAIN}"
154154
_DEFAULT_UNIVERSE = "googleapis.com"
155155

156+
@staticmethod
157+
def _use_client_cert_effective():
158+
"""Returns whether client certificate should be used for mTLS if the
159+
google-auth version supports should_use_client_cert automatic mTLS enablement.
160+
161+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
162+
163+
Returns:
164+
bool: whether client certificate should be used for mTLS
165+
Raises:
166+
ValueError: (If using a version of google-auth without should_use_client_cert and
167+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
168+
"""
169+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
170+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
171+
return mtls.should_use_client_cert()
172+
else: # pragma: NO COVER
173+
# if unsupported, fallback to reading from env var
174+
use_client_cert_str = os.getenv(
175+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
176+
).lower()
177+
if use_client_cert_str not in ("true", "false"):
178+
raise ValueError(
179+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
180+
" either `true` or `false`"
181+
)
182+
return use_client_cert_str == "true"
183+
156184
@classmethod
157185
def from_service_account_info(cls, info: dict, *args, **kwargs):
158186
"""Creates an instance of this client using the provided credentials
@@ -384,20 +412,16 @@ def get_mtls_endpoint_and_cert_source(
384412
)
385413
if client_options is None:
386414
client_options = client_options_lib.ClientOptions()
387-
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
415+
use_client_cert = AdUnitServiceClient._use_client_cert_effective()
388416
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
389-
if use_client_cert not in ("true", "false"):
390-
raise ValueError(
391-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
392-
)
393417
if use_mtls_endpoint not in ("auto", "never", "always"):
394418
raise MutualTLSChannelError(
395419
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
396420
)
397421

398422
# Figure out the client cert source to use.
399423
client_cert_source = None
400-
if use_client_cert == "true":
424+
if use_client_cert:
401425
if client_options.client_cert_source:
402426
client_cert_source = client_options.client_cert_source
403427
elif mtls.has_default_client_cert_source():
@@ -429,20 +453,14 @@ def _read_environment_variables():
429453
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
430454
is not any of ["auto", "never", "always"].
431455
"""
432-
use_client_cert = os.getenv(
433-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
434-
).lower()
456+
use_client_cert = AdUnitServiceClient._use_client_cert_effective()
435457
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
436458
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
437-
if use_client_cert not in ("true", "false"):
438-
raise ValueError(
439-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
440-
)
441459
if use_mtls_endpoint not in ("auto", "never", "always"):
442460
raise MutualTLSChannelError(
443461
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
444462
)
445-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
463+
return use_client_cert, use_mtls_endpoint, universe_domain_env
446464

447465
@staticmethod
448466
def _get_client_cert_source(provided_cert_source, use_cert_flag):

0 commit comments

Comments
 (0)