Skip to content

Commit faed3f4

Browse files
gcf-owl-bot[bot]copybara-github
authored andcommitted
Copybara import of the project:
-- 5da8cb0 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>: feat: add ARCHIVED state to ReasoningEngineRuntimeRevision fix!: An existing value `DEPRECATED` is removed from enum `State` PiperOrigin-RevId: 995789648 Source-Link: googleapis/googleapis@ad11dbf Source-Link: googleapis/googleapis-gen@a662281 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTY2MjI4MTA4Y2RkOWU2MjlkMThkY2NjNGE5MTZjOGVlNjU3NDhlMSJ9 chore(bazel): upgrade Python generator PiperOrigin-RevId: 994037879 Source-Link: googleapis/googleapis@118d1fc Source-Link: googleapis/googleapis-gen@e4046c0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTQwNDZjMGMyNGRhMDJkOGZlZDA5MjljNjljZDdkN2I4M2ZlZjViOSJ9 feat: add context to Memory, MemoryRevision, and IntermediateExtractedMemory in Vertex AI v1beta1 docs: A comment for field `expire_time` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `ttl` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `name` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `display_name` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `description` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `create_time` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `update_time` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `fact` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed docs: A comment for field `scope` in message `.google.cloud.aiplatform.v1beta1.Memory` is changed PiperOrigin-RevId: 990525310 Source-Link: googleapis/googleapis@393b04e Source-Link: googleapis/googleapis-gen@578fbb7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTc4ZmJiNzZlYTQ4ZTdmY2U4ZjAwZWFiNWE0NGRiNjgwOGM5NGM3YSJ9 chore: Update gapic-generator-python to 1.40.0 PiperOrigin-RevId: 988809391 Source-Link: googleapis/googleapis@5174d7c Source-Link: googleapis/googleapis-gen@b19df1f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjE5ZGYxZjYxYTY2N2Y3ZWUyZTgyZmQ5YzgwNDEyMTllYWY5NzAxOSJ9 -- 064fead by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>: 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md COPYBARA_INTEGRATE_REVIEW=#7170 from googleapis:owl-bot-copy 4b48c61 PiperOrigin-RevId: 1002700094
1 parent d004c1c commit faed3f4

484 files changed

Lines changed: 43890 additions & 100865 deletions

File tree

Some content is hidden

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

‎google/cloud/aiplatform/v1/schema/predict/instance_v1/__init__.py‎

Lines changed: 5 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818
)
1919

2020
import google.api_core as api_core
21-
import sys
2221

2322
__version__ = package_version.__version__
2423

25-
from importlib import metadata
26-
2724
# PEP 0810: Explicit Lazy Imports
2825
# Python 3.15+ natively intercepts and defers these imports.
2926
# Developers can disable this behavior and force eager imports.
@@ -53,89 +50,6 @@
5350
from .types.video_classification import VideoClassificationPredictionInstance
5451
from .types.video_object_tracking import VideoObjectTrackingPredictionInstance
5552

56-
if hasattr(api_core, "check_python_version") and hasattr(
57-
api_core, "check_dependency_versions"
58-
): # pragma: NO COVER
59-
api_core.check_python_version("google.cloud.aiplatform.v1.schema.predict.instance_v1") # type: ignore
60-
api_core.check_dependency_versions("google.cloud.aiplatform.v1.schema.predict.instance_v1") # type: ignore
61-
else: # pragma: NO COVER
62-
# An older version of api_core is installed which does not define the
63-
# functions above. We do equivalent checks manually.
64-
try:
65-
import warnings
66-
67-
_py_version_str = sys.version.split()[0]
68-
_package_label = "google.cloud.aiplatform.v1.schema.predict.instance_v1"
69-
if sys.version_info < (3, 10):
70-
warnings.warn(
71-
"You are using a non-supported Python version "
72-
+ f"({_py_version_str}). Google will not post any further "
73-
+ f"updates to {_package_label} supporting this Python version. "
74-
+ "Please upgrade to the latest Python version, or at "
75-
+ f"least to Python 3.10, and then update {_package_label}.",
76-
FutureWarning,
77-
)
78-
79-
def parse_version_to_tuple(version_string: str):
80-
"""Safely converts a semantic version string to a comparable tuple of integers.
81-
Example: "6.33.5" -> (6, 33, 5)
82-
Ignores non-numeric parts and handles common version formats.
83-
Args:
84-
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
85-
Returns:
86-
Tuple of integers for the parsed version string.
87-
"""
88-
parts = []
89-
for part in version_string.split("."):
90-
try:
91-
parts.append(int(part))
92-
except ValueError:
93-
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
94-
# This is a simplification compared to 'packaging.parse_version', but sufficient
95-
# for comparing strictly numeric semantic versions.
96-
break
97-
return tuple(parts)
98-
99-
def _get_version(dependency_name):
100-
try:
101-
version_string: str = metadata.version(dependency_name)
102-
parsed_version = parse_version_to_tuple(version_string)
103-
return (parsed_version, version_string)
104-
except Exception:
105-
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
106-
# or errors during parse_version_to_tuple
107-
return (None, "--")
108-
109-
_dependency_package = "google.protobuf"
110-
_next_supported_version = "6.33.5"
111-
_next_supported_version_tuple = (6, 33, 5)
112-
_recommendation = " (we recommend 7.x)"
113-
(_version_used, _version_used_string) = _get_version(_dependency_package)
114-
if _version_used and _version_used < _next_supported_version_tuple:
115-
warnings.warn(
116-
f"Package {_package_label} depends on "
117-
+ f"{_dependency_package}, currently installed at version "
118-
+ f"{_version_used_string}. Future updates to "
119-
+ f"{_package_label} will require {_dependency_package} at "
120-
+ f"version {_next_supported_version} or higher{_recommendation}."
121-
+ " Please ensure "
122-
+ "that either (a) your Python environment doesn't pin the "
123-
+ f"version of {_dependency_package}, so that updates to "
124-
+ f"{_package_label} can require the higher version, or "
125-
+ "(b) you manually update your Python environment to use at "
126-
+ f"least version {_next_supported_version} of "
127-
+ f"{_dependency_package}.",
128-
FutureWarning,
129-
)
130-
except Exception:
131-
warnings.warn(
132-
"Could not determine the version of Python "
133-
+ "currently being used. To continue receiving "
134-
+ "updates for {_package_label}, ensure you are "
135-
+ "using a supported version of Python; see "
136-
+ "https://devguide.python.org/versions/"
137-
)
138-
13953
__all__ = (
14054
"ImageClassificationPredictionInstance",
14155
"ImageObjectDetectionPredictionInstance",
@@ -147,3 +61,8 @@ def _get_version(dependency_name):
14761
"VideoClassificationPredictionInstance",
14862
"VideoObjectTrackingPredictionInstance",
14963
)
64+
65+
api_core.check_python_version("google.cloud.aiplatform.v1.schema.predict.instance_v1")
66+
api_core.check_dependency_versions(
67+
"google.cloud.aiplatform.v1.schema.predict.instance_v1"
68+
)
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
"""A compatibility module for older versions of google-api-core."""
17+
18+
import os
19+
import json
20+
21+
from typing import Any, Dict, List, Optional, Tuple
22+
23+
from google.api_core import path_template
24+
from google.api_core.universe import EmptyUniverseError
25+
from google.auth.exceptions import MutualTLSChannelError
26+
from google.protobuf import json_format
27+
from urllib.parse import urlparse, urlunparse
28+
29+
try:
30+
# note: `#type: ignore` is added because the return type for `should_use_client_cert`
31+
# is different than that of the fallback implementation below. This will be removed once
32+
# we bump the minimum supported version of google-auth.
33+
from google.auth.transport.mtls import should_use_client_cert # type: ignore
34+
except ImportError: # pragma: NO COVER
35+
36+
def should_use_client_cert():
37+
"""Returns whether client certificate should be used for mTLS."""
38+
use_client_cert = os.getenv(
39+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
40+
).lower()
41+
if use_client_cert not in ("true", "false"):
42+
raise ValueError(
43+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
44+
" either `true` or `false`"
45+
)
46+
return use_client_cert == "true"
47+
48+
49+
def read_environment_variables():
50+
"""Returns the environment variables used by the client.
51+
52+
Returns:
53+
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
54+
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
55+
56+
Raises:
57+
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
58+
any of ["true", "false"].
59+
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
60+
is not any of ["auto", "never", "always"].
61+
"""
62+
use_client_cert = should_use_client_cert()
63+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
64+
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
65+
if use_mtls_endpoint not in ("auto", "never", "always"):
66+
raise MutualTLSChannelError(
67+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`,"
68+
" `auto` or `always`"
69+
)
70+
return use_client_cert, use_mtls_endpoint, universe_domain_env
71+
72+
73+
DEFAULT_UNIVERSE = "googleapis.com"
74+
75+
try:
76+
from google.api_core.universe import get_default_mtls_endpoint
77+
except ImportError: # pragma: NO COVER
78+
79+
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
80+
"""Converts api endpoint to mTLS endpoint.
81+
82+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
83+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
84+
Other URLs (including those that do not match these domain suffixes or
85+
already contain '.mtls.') are passed through as-is.
86+
87+
Args:
88+
api_endpoint (Optional[str]): the api endpoint to convert.
89+
90+
Returns:
91+
Optional[str]: converted mTLS api endpoint.
92+
"""
93+
if not api_endpoint or ".mtls." in api_endpoint.lower():
94+
return api_endpoint
95+
96+
has_scheme = "://" in api_endpoint
97+
if not has_scheme:
98+
parsed = urlparse("//" + api_endpoint)
99+
else:
100+
parsed = urlparse(api_endpoint)
101+
102+
host = parsed.hostname
103+
if not host:
104+
return api_endpoint
105+
106+
port = f":{parsed.port}" if parsed.port else ""
107+
108+
lowered_host = host.lower()
109+
suffix_sandbox = ".sandbox.googleapis.com"
110+
suffix_google = ".googleapis.com"
111+
if lowered_host.endswith(suffix_sandbox):
112+
new_host = host[: -len(suffix_sandbox)] + ".mtls.sandbox.googleapis.com"
113+
elif lowered_host.endswith(suffix_google):
114+
new_host = host[: -len(suffix_google)] + ".mtls.googleapis.com"
115+
else:
116+
return api_endpoint
117+
118+
netloc = new_host + port
119+
new_parsed = parsed._replace(netloc=netloc)
120+
121+
if not has_scheme:
122+
return urlunparse(new_parsed)[2:]
123+
else:
124+
return urlunparse(new_parsed)
125+
126+
127+
try:
128+
from google.api_core.universe import get_api_endpoint
129+
except ImportError: # pragma: NO COVER
130+
131+
def get_api_endpoint(
132+
api_override: Optional[str],
133+
universe_domain: str,
134+
default_universe: str,
135+
default_mtls_endpoint: Optional[str],
136+
default_endpoint_template: str,
137+
use_mtls: bool,
138+
) -> str:
139+
"""Return the API endpoint used by the client.
140+
141+
Args:
142+
api_override (Optional[str]): The API endpoint override. If specified,
143+
this is always returned.
144+
universe_domain (str): The universe domain used by the client.
145+
default_universe (str): The default universe domain.
146+
default_mtls_endpoint (Optional[str]): The default mTLS endpoint.
147+
default_endpoint_template (str): The default endpoint template containing
148+
a placeholder `{UNIVERSE_DOMAIN}`.
149+
use_mtls (bool): Whether to use the mTLS endpoint.
150+
151+
Returns:
152+
str: The API endpoint to be used by the client.
153+
154+
Raises:
155+
google.auth.exceptions.MutualTLSChannelError: If mTLS is requested but
156+
not supported in the configured universe domain.
157+
ValueError: If mTLS is requested but no mTLS endpoint is available.
158+
"""
159+
if api_override is not None:
160+
return api_override
161+
162+
if use_mtls:
163+
if universe_domain.lower() != default_universe.lower():
164+
raise MutualTLSChannelError(
165+
f"mTLS is not supported in any universe other than {default_universe}."
166+
)
167+
if not default_mtls_endpoint:
168+
raise ValueError("mTLS endpoint is not available.")
169+
return default_mtls_endpoint
170+
else:
171+
return default_endpoint_template.format(UNIVERSE_DOMAIN=universe_domain)
172+
173+
174+
try:
175+
from google.api_core.universe import get_universe_domain
176+
except ImportError: # pragma: NO COVER
177+
178+
def get_universe_domain(
179+
*potential_universes: Optional[str],
180+
default_universe: str,
181+
) -> str:
182+
"""Return the universe domain used by the client.
183+
184+
Args:
185+
*potential_universes (Optional[str]): Potential universe domains in order of preference.
186+
default_universe (str): The default universe domain.
187+
188+
Returns:
189+
str: The universe domain to be used by the client.
190+
191+
Raises:
192+
EmptyUniverseError: If the resolved universe domain is an empty string.
193+
"""
194+
resolved = next(
195+
(x.strip() for x in potential_universes if x is not None),
196+
default_universe,
197+
)
198+
199+
if not resolved:
200+
raise EmptyUniverseError()
201+
return resolved
202+
203+
204+
try:
205+
from google.api_core.rest_helpers import transcode_request # type: ignore
206+
except ImportError: # pragma: NO COVER
207+
208+
def transcode_request(
209+
http_options: List[Dict[str, str]],
210+
request: Any,
211+
required_fields_default_values: Optional[Dict[str, Any]] = None,
212+
rest_numeric_enums: bool = False,
213+
) -> Tuple[Dict[str, Any], Optional[str], Dict[str, Any]]:
214+
"""Transcodes a request into HTTP method, URI, body, and query parameters.
215+
216+
Args:
217+
http_options (List[Dict[str, str]]): List of HTTP transcoding rules.
218+
request (Any): The protobuf or proto-plus request message.
219+
required_fields_default_values (Optional[Dict[str, Any]]): Dictionary
220+
of required fields default values to merge into query parameters if missing.
221+
rest_numeric_enums (bool): Whether to encode enums as integers.
222+
223+
Returns:
224+
Tuple[Dict[str, Any], Optional[str], Dict[str, Any]]: A tuple containing:
225+
- The raw transcoded request dictionary (containing keys like 'uri', 'method').
226+
- The serialized request body JSON string, or None if no body.
227+
- The query parameters dictionary.
228+
"""
229+
if request is None:
230+
raise TypeError("request cannot be None")
231+
232+
# Convert proto-plus message to its underlying protobuf message if needed
233+
pb_request = getattr(request, "_pb", request)
234+
235+
transcoded_request = path_template.transcode(http_options, pb_request)
236+
237+
body_json = None
238+
if transcoded_request.get("body") is not None:
239+
body_json = json_format.MessageToJson(
240+
transcoded_request["body"],
241+
use_integers_for_enums=rest_numeric_enums,
242+
)
243+
244+
query_params_json = {}
245+
if transcoded_request.get("query_params") is not None:
246+
query_params_json = json.loads(
247+
json_format.MessageToJson(
248+
transcoded_request["query_params"],
249+
use_integers_for_enums=rest_numeric_enums,
250+
)
251+
)
252+
253+
# If required_fields_default_values is provided, we merge default values for missing
254+
# required fields into the query parameters.
255+
if required_fields_default_values:
256+
for k, v in required_fields_default_values.items():
257+
if k not in query_params_json:
258+
query_params_json[k] = v
259+
260+
if rest_numeric_enums:
261+
query_params_json["$alt"] = "json;enum-encoding=int"
262+
263+
return transcoded_request, body_json, query_params_json

0 commit comments

Comments
 (0)