Skip to content

Commit 8b8ee02

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 c60f1ac commit 8b8ee02

File tree

183 files changed

+21596
-6043
lines changed

Some content is hidden

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

183 files changed

+21596
-6043
lines changed

.librarian/state.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:d7caef319a25d618e20ba798b103434700bfd80015f525802d87621ca2528c90
1+
image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209
22
libraries:
33
- id: google-ads-admanager
44
version: 0.7.0

packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1/__init__.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@
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.cloud.bigquery_storage_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
30+
2031
from google.cloud.bigquery_storage_v1 import client, types
2132

2233

@@ -28,6 +39,100 @@ class BigQueryWriteClient(client.BigQueryWriteClient):
2839
__doc__ = client.BigQueryWriteClient.__doc__
2940

3041

42+
if hasattr(api_core, "check_python_version") and hasattr(
43+
api_core, "check_dependency_versions"
44+
): # pragma: NO COVER
45+
api_core.check_python_version("google.cloud.bigquery_storage_v1") # type: ignore
46+
api_core.check_dependency_versions("google.cloud.bigquery_storage_v1") # type: ignore
47+
else: # pragma: NO COVER
48+
# An older version of api_core is installed which does not define the
49+
# functions above. We do equivalent checks manually.
50+
try:
51+
import sys
52+
import warnings
53+
54+
_py_version_str = sys.version.split()[0]
55+
_package_label = "google.cloud.bigquery_storage_v1"
56+
if sys.version_info < (3, 9):
57+
warnings.warn(
58+
"You are using a non-supported Python version "
59+
+ f"({_py_version_str}). Google will not post any further "
60+
+ f"updates to {_package_label} supporting this Python version. "
61+
+ "Please upgrade to the latest Python version, or at "
62+
+ f"least to Python 3.9, and then update {_package_label}.",
63+
FutureWarning,
64+
)
65+
if sys.version_info[:2] == (3, 9):
66+
warnings.warn(
67+
f"You are using a Python version ({_py_version_str}) "
68+
+ f"which Google will stop supporting in {_package_label} in "
69+
+ "January 2026. Please "
70+
+ "upgrade to the latest Python version, or at "
71+
+ "least to Python 3.10, before then, and "
72+
+ f"then update {_package_label}.",
73+
FutureWarning,
74+
)
75+
76+
def parse_version_to_tuple(version_string: str):
77+
"""Safely converts a semantic version string to a comparable tuple of integers.
78+
Example: "4.25.8" -> (4, 25, 8)
79+
Ignores non-numeric parts and handles common version formats.
80+
Args:
81+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
82+
Returns:
83+
Tuple of integers for the parsed version string.
84+
"""
85+
parts = []
86+
for part in version_string.split("."):
87+
try:
88+
parts.append(int(part))
89+
except ValueError:
90+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
91+
# This is a simplification compared to 'packaging.parse_version', but sufficient
92+
# for comparing strictly numeric semantic versions.
93+
break
94+
return tuple(parts)
95+
96+
def _get_version(dependency_name):
97+
try:
98+
version_string: str = metadata.version(dependency_name)
99+
parsed_version = parse_version_to_tuple(version_string)
100+
return (parsed_version, version_string)
101+
except Exception:
102+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
103+
# or errors during parse_version_to_tuple
104+
return (None, "--")
105+
106+
_dependency_package = "google.protobuf"
107+
_next_supported_version = "4.25.8"
108+
_next_supported_version_tuple = (4, 25, 8)
109+
_recommendation = " (we recommend 6.x)"
110+
(_version_used, _version_used_string) = _get_version(_dependency_package)
111+
if _version_used and _version_used < _next_supported_version_tuple:
112+
warnings.warn(
113+
f"Package {_package_label} depends on "
114+
+ f"{_dependency_package}, currently installed at version "
115+
+ f"{_version_used_string}. Future updates to "
116+
+ f"{_package_label} will require {_dependency_package} at "
117+
+ f"version {_next_supported_version} or higher{_recommendation}."
118+
+ " Please ensure "
119+
+ "that either (a) your Python environment doesn't pin the "
120+
+ f"version of {_dependency_package}, so that updates to "
121+
+ f"{_package_label} can require the higher version, or "
122+
+ "(b) you manually update your Python environment to use at "
123+
+ f"least version {_next_supported_version} of "
124+
+ f"{_dependency_package}.",
125+
FutureWarning,
126+
)
127+
except Exception:
128+
warnings.warn(
129+
"Could not determine the version of Python "
130+
+ "currently being used. To continue receiving "
131+
+ "updates for {_package_label}, ensure you are "
132+
+ "using a supported version of Python; see "
133+
+ "https://devguide.python.org/versions/"
134+
)
135+
31136
__all__ = (
32137
# google.cloud.bigquery_storage_v1
33138
"__version__",

packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1/services/big_query_read/client.py

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

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

397421
# Figure out the client cert source to use.
398422
client_cert_source = None
399-
if use_client_cert == "true":
423+
if use_client_cert:
400424
if client_options.client_cert_source:
401425
client_cert_source = client_options.client_cert_source
402426
elif mtls.has_default_client_cert_source():
@@ -428,20 +452,14 @@ def _read_environment_variables():
428452
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
429453
is not any of ["auto", "never", "always"].
430454
"""
431-
use_client_cert = os.getenv(
432-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
433-
).lower()
455+
use_client_cert = BigQueryReadClient._use_client_cert_effective()
434456
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
435457
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
436-
if use_client_cert not in ("true", "false"):
437-
raise ValueError(
438-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
439-
)
440458
if use_mtls_endpoint not in ("auto", "never", "always"):
441459
raise MutualTLSChannelError(
442460
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
443461
)
444-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
462+
return use_client_cert, use_mtls_endpoint, universe_domain_env
445463

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

packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1/services/big_query_write/client.py

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

159+
@staticmethod
160+
def _use_client_cert_effective():
161+
"""Returns whether client certificate should be used for mTLS if the
162+
google-auth version supports should_use_client_cert automatic mTLS enablement.
163+
164+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
165+
166+
Returns:
167+
bool: whether client certificate should be used for mTLS
168+
Raises:
169+
ValueError: (If using a version of google-auth without should_use_client_cert and
170+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
171+
"""
172+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
173+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
174+
return mtls.should_use_client_cert()
175+
else: # pragma: NO COVER
176+
# if unsupported, fallback to reading from env var
177+
use_client_cert_str = os.getenv(
178+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
179+
).lower()
180+
if use_client_cert_str not in ("true", "false"):
181+
raise ValueError(
182+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
183+
" either `true` or `false`"
184+
)
185+
return use_client_cert_str == "true"
186+
159187
@classmethod
160188
def from_service_account_info(cls, info: dict, *args, **kwargs):
161189
"""Creates an instance of this client using the provided credentials
@@ -367,20 +395,16 @@ def get_mtls_endpoint_and_cert_source(
367395
)
368396
if client_options is None:
369397
client_options = client_options_lib.ClientOptions()
370-
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
398+
use_client_cert = BigQueryWriteClient._use_client_cert_effective()
371399
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
372-
if use_client_cert not in ("true", "false"):
373-
raise ValueError(
374-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
375-
)
376400
if use_mtls_endpoint not in ("auto", "never", "always"):
377401
raise MutualTLSChannelError(
378402
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
379403
)
380404

381405
# Figure out the client cert source to use.
382406
client_cert_source = None
383-
if use_client_cert == "true":
407+
if use_client_cert:
384408
if client_options.client_cert_source:
385409
client_cert_source = client_options.client_cert_source
386410
elif mtls.has_default_client_cert_source():
@@ -412,20 +436,14 @@ def _read_environment_variables():
412436
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
413437
is not any of ["auto", "never", "always"].
414438
"""
415-
use_client_cert = os.getenv(
416-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
417-
).lower()
439+
use_client_cert = BigQueryWriteClient._use_client_cert_effective()
418440
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
419441
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
420-
if use_client_cert not in ("true", "false"):
421-
raise ValueError(
422-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
423-
)
424442
if use_mtls_endpoint not in ("auto", "never", "always"):
425443
raise MutualTLSChannelError(
426444
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
427445
)
428-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
446+
return use_client_cert, use_mtls_endpoint, universe_domain_env
429447

430448
@staticmethod
431449
def _get_client_cert_source(provided_cert_source, use_cert_flag):

0 commit comments

Comments
 (0)