Skip to content

Commit fc129ef

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 9e04198 commit fc129ef

File tree

163 files changed

+19622
-5057
lines changed

Some content is hidden

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

163 files changed

+19622
-5057
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-discoveryengine/google/cloud/discoveryengine_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.cloud.discoveryengine_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.assistant_service import (
2232
AssistantServiceAsyncClient,
@@ -340,6 +350,100 @@
340350
ListUserLicensesResponse,
341351
)
342352

353+
if hasattr(api_core, "check_python_version") and hasattr(
354+
api_core, "check_dependency_versions"
355+
): # pragma: NO COVER
356+
api_core.check_python_version("google.cloud.discoveryengine_v1") # type: ignore
357+
api_core.check_dependency_versions("google.cloud.discoveryengine_v1") # type: ignore
358+
else: # pragma: NO COVER
359+
# An older version of api_core is installed which does not define the
360+
# functions above. We do equivalent checks manually.
361+
try:
362+
import sys
363+
import warnings
364+
365+
_py_version_str = sys.version.split()[0]
366+
_package_label = "google.cloud.discoveryengine_v1"
367+
if sys.version_info < (3, 9):
368+
warnings.warn(
369+
"You are using a non-supported Python version "
370+
+ f"({_py_version_str}). Google will not post any further "
371+
+ f"updates to {_package_label} supporting this Python version. "
372+
+ "Please upgrade to the latest Python version, or at "
373+
+ f"least to Python 3.9, and then update {_package_label}.",
374+
FutureWarning,
375+
)
376+
if sys.version_info[:2] == (3, 9):
377+
warnings.warn(
378+
f"You are using a Python version ({_py_version_str}) "
379+
+ f"which Google will stop supporting in {_package_label} in "
380+
+ "January 2026. Please "
381+
+ "upgrade to the latest Python version, or at "
382+
+ "least to Python 3.10, before then, and "
383+
+ f"then update {_package_label}.",
384+
FutureWarning,
385+
)
386+
387+
def parse_version_to_tuple(version_string: str):
388+
"""Safely converts a semantic version string to a comparable tuple of integers.
389+
Example: "4.25.8" -> (4, 25, 8)
390+
Ignores non-numeric parts and handles common version formats.
391+
Args:
392+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
393+
Returns:
394+
Tuple of integers for the parsed version string.
395+
"""
396+
parts = []
397+
for part in version_string.split("."):
398+
try:
399+
parts.append(int(part))
400+
except ValueError:
401+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
402+
# This is a simplification compared to 'packaging.parse_version', but sufficient
403+
# for comparing strictly numeric semantic versions.
404+
break
405+
return tuple(parts)
406+
407+
def _get_version(dependency_name):
408+
try:
409+
version_string: str = metadata.version(dependency_name)
410+
parsed_version = parse_version_to_tuple(version_string)
411+
return (parsed_version, version_string)
412+
except Exception:
413+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
414+
# or errors during parse_version_to_tuple
415+
return (None, "--")
416+
417+
_dependency_package = "google.protobuf"
418+
_next_supported_version = "4.25.8"
419+
_next_supported_version_tuple = (4, 25, 8)
420+
_recommendation = " (we recommend 6.x)"
421+
(_version_used, _version_used_string) = _get_version(_dependency_package)
422+
if _version_used and _version_used < _next_supported_version_tuple:
423+
warnings.warn(
424+
f"Package {_package_label} depends on "
425+
+ f"{_dependency_package}, currently installed at version "
426+
+ f"{_version_used_string}. Future updates to "
427+
+ f"{_package_label} will require {_dependency_package} at "
428+
+ f"version {_next_supported_version} or higher{_recommendation}."
429+
+ " Please ensure "
430+
+ "that either (a) your Python environment doesn't pin the "
431+
+ f"version of {_dependency_package}, so that updates to "
432+
+ f"{_package_label} can require the higher version, or "
433+
+ "(b) you manually update your Python environment to use at "
434+
+ f"least version {_next_supported_version} of "
435+
+ f"{_dependency_package}.",
436+
FutureWarning,
437+
)
438+
except Exception:
439+
warnings.warn(
440+
"Could not determine the version of Python "
441+
+ "currently being used. To continue receiving "
442+
+ "updates for {_package_label}, ensure you are "
443+
+ "using a supported version of Python; see "
444+
+ "https://devguide.python.org/versions/"
445+
)
446+
343447
__all__ = (
344448
"AssistantServiceAsyncClient",
345449
"CmekConfigServiceAsyncClient",

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1/services/assistant_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 = "discoveryengine.{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
@@ -445,20 +473,16 @@ def get_mtls_endpoint_and_cert_source(
445473
)
446474
if client_options is None:
447475
client_options = client_options_lib.ClientOptions()
448-
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
476+
use_client_cert = AssistantServiceClient._use_client_cert_effective()
449477
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
450-
if use_client_cert not in ("true", "false"):
451-
raise ValueError(
452-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
453-
)
454478
if use_mtls_endpoint not in ("auto", "never", "always"):
455479
raise MutualTLSChannelError(
456480
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
457481
)
458482

459483
# Figure out the client cert source to use.
460484
client_cert_source = None
461-
if use_client_cert == "true":
485+
if use_client_cert:
462486
if client_options.client_cert_source:
463487
client_cert_source = client_options.client_cert_source
464488
elif mtls.has_default_client_cert_source():
@@ -490,20 +514,14 @@ def _read_environment_variables():
490514
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
491515
is not any of ["auto", "never", "always"].
492516
"""
493-
use_client_cert = os.getenv(
494-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
495-
).lower()
517+
use_client_cert = AssistantServiceClient._use_client_cert_effective()
496518
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
497519
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
498-
if use_client_cert not in ("true", "false"):
499-
raise ValueError(
500-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
501-
)
502520
if use_mtls_endpoint not in ("auto", "never", "always"):
503521
raise MutualTLSChannelError(
504522
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
505523
)
506-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
524+
return use_client_cert, use_mtls_endpoint, universe_domain_env
507525

508526
@staticmethod
509527
def _get_client_cert_source(provided_cert_source, use_cert_flag):

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1/services/cmek_config_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 = "discoveryengine.{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
@@ -405,20 +433,16 @@ def get_mtls_endpoint_and_cert_source(
405433
)
406434
if client_options is None:
407435
client_options = client_options_lib.ClientOptions()
408-
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
436+
use_client_cert = CmekConfigServiceClient._use_client_cert_effective()
409437
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
410-
if use_client_cert not in ("true", "false"):
411-
raise ValueError(
412-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
413-
)
414438
if use_mtls_endpoint not in ("auto", "never", "always"):
415439
raise MutualTLSChannelError(
416440
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
417441
)
418442

419443
# Figure out the client cert source to use.
420444
client_cert_source = None
421-
if use_client_cert == "true":
445+
if use_client_cert:
422446
if client_options.client_cert_source:
423447
client_cert_source = client_options.client_cert_source
424448
elif mtls.has_default_client_cert_source():
@@ -450,20 +474,14 @@ def _read_environment_variables():
450474
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
451475
is not any of ["auto", "never", "always"].
452476
"""
453-
use_client_cert = os.getenv(
454-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
455-
).lower()
477+
use_client_cert = CmekConfigServiceClient._use_client_cert_effective()
456478
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
457479
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
458-
if use_client_cert not in ("true", "false"):
459-
raise ValueError(
460-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
461-
)
462480
if use_mtls_endpoint not in ("auto", "never", "always"):
463481
raise MutualTLSChannelError(
464482
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
465483
)
466-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
484+
return use_client_cert, use_mtls_endpoint, universe_domain_env
467485

468486
@staticmethod
469487
def _get_client_cert_source(provided_cert_source, use_cert_flag):

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1/services/completion_service/client.py

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

160+
@staticmethod
161+
def _use_client_cert_effective():
162+
"""Returns whether client certificate should be used for mTLS if the
163+
google-auth version supports should_use_client_cert automatic mTLS enablement.
164+
165+
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
166+
167+
Returns:
168+
bool: whether client certificate should be used for mTLS
169+
Raises:
170+
ValueError: (If using a version of google-auth without should_use_client_cert and
171+
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
172+
"""
173+
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
174+
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
175+
return mtls.should_use_client_cert()
176+
else: # pragma: NO COVER
177+
# if unsupported, fallback to reading from env var
178+
use_client_cert_str = os.getenv(
179+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
180+
).lower()
181+
if use_client_cert_str not in ("true", "false"):
182+
raise ValueError(
183+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
184+
" either `true` or `false`"
185+
)
186+
return use_client_cert_str == "true"
187+
160188
@classmethod
161189
def from_service_account_info(cls, info: dict, *args, **kwargs):
162190
"""Creates an instance of this client using the provided credentials
@@ -344,20 +372,16 @@ def get_mtls_endpoint_and_cert_source(
344372
)
345373
if client_options is None:
346374
client_options = client_options_lib.ClientOptions()
347-
use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
375+
use_client_cert = CompletionServiceClient._use_client_cert_effective()
348376
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
349-
if use_client_cert not in ("true", "false"):
350-
raise ValueError(
351-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
352-
)
353377
if use_mtls_endpoint not in ("auto", "never", "always"):
354378
raise MutualTLSChannelError(
355379
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
356380
)
357381

358382
# Figure out the client cert source to use.
359383
client_cert_source = None
360-
if use_client_cert == "true":
384+
if use_client_cert:
361385
if client_options.client_cert_source:
362386
client_cert_source = client_options.client_cert_source
363387
elif mtls.has_default_client_cert_source():
@@ -389,20 +413,14 @@ def _read_environment_variables():
389413
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
390414
is not any of ["auto", "never", "always"].
391415
"""
392-
use_client_cert = os.getenv(
393-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
394-
).lower()
416+
use_client_cert = CompletionServiceClient._use_client_cert_effective()
395417
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
396418
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
397-
if use_client_cert not in ("true", "false"):
398-
raise ValueError(
399-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
400-
)
401419
if use_mtls_endpoint not in ("auto", "never", "always"):
402420
raise MutualTLSChannelError(
403421
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
404422
)
405-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
423+
return use_client_cert, use_mtls_endpoint, universe_domain_env
406424

407425
@staticmethod
408426
def _get_client_cert_source(provided_cert_source, use_cert_flag):

0 commit comments

Comments
 (0)