From e0c1cead5d5d5b7997a8896558f2b6a79c28b5a6 Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Thu, 9 Apr 2026 14:09:46 -0700 Subject: [PATCH] feat: Add support for snapshots for Sandboxes in Vertex AI GenAI SDK. PiperOrigin-RevId: 897294488 --- vertexai/_genai/sandbox_snapshots.py | 709 +++++++++++++++++++++++++++ vertexai/_genai/sandboxes.py | 29 ++ vertexai/_genai/types/__init__.py | 50 ++ vertexai/_genai/types/common.py | 314 ++++++++++++ 4 files changed, 1102 insertions(+) create mode 100644 vertexai/_genai/sandbox_snapshots.py diff --git a/vertexai/_genai/sandbox_snapshots.py b/vertexai/_genai/sandbox_snapshots.py new file mode 100644 index 0000000000..255d6471e8 --- /dev/null +++ b/vertexai/_genai/sandbox_snapshots.py @@ -0,0 +1,709 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Code generated by the Google Gen AI SDK generator DO NOT EDIT. + +import json +import logging +from typing import Any, Optional, Union +from urllib.parse import urlencode + +from google.genai import _api_module +from google.genai import _common +from google.genai._common import get_value_by_path as getv +from google.genai._common import set_value_by_path as setv + +from . import types + + +logger = logging.getLogger("vertexai_genai.sandboxsnapshots") + + +def _CreateSandboxEnvironmentSnapshotRequestParameters_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ["name"]) is not None: + setv(to_object, ["_url", "name"], getv(from_object, ["name"])) + + if getv(from_object, ["sandbox_environment_snapshot"]) is not None: + setv( + to_object, + ["sandbox_environment_snapshot"], + getv(from_object, ["sandbox_environment_snapshot"]), + ) + + return to_object + + +def _DeleteSandboxEnvironmentSnapshotRequestParameters_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ["name"]) is not None: + setv(to_object, ["_url", "name"], getv(from_object, ["name"])) + + return to_object + + +def _GetSandboxEnvironmentSnapshotRequestParameters_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ["name"]) is not None: + setv(to_object, ["_url", "name"], getv(from_object, ["name"])) + + return to_object + + +def _ListSandboxEnvironmentSnapshotsConfig_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + + if getv(from_object, ["page_size"]) is not None: + setv(parent_object, ["_query", "pageSize"], getv(from_object, ["page_size"])) + + if getv(from_object, ["page_token"]) is not None: + setv(parent_object, ["_query", "pageToken"], getv(from_object, ["page_token"])) + + if getv(from_object, ["filter"]) is not None: + setv(parent_object, ["_query", "filter"], getv(from_object, ["filter"])) + + return to_object + + +def _ListSandboxEnvironmentSnapshotsRequestParameters_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ["name"]) is not None: + setv(to_object, ["_url", "name"], getv(from_object, ["name"])) + + if getv(from_object, ["config"]) is not None: + _ListSandboxEnvironmentSnapshotsConfig_to_vertex( + getv(from_object, ["config"]), to_object + ) + + return to_object + + +class SandboxSnapshots(_api_module.BaseModule): + """Sandbox environment snapshot commands.""" + + def create( + self, + *, + name: str, + sandbox_environment_snapshot: types.SandboxEnvironmentSnapshotOrDict, + config: Optional[types.CreateSandboxEnvironmentSnapshotConfigOrDict] = None, + ) -> types.SandboxEnvironmentSnapshot: + """ + Snapshots a sandbox environment. + + """ + + parameter_model = types._CreateSandboxEnvironmentSnapshotRequestParameters( + name=name, + sandbox_environment_snapshot=sandbox_environment_snapshot, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _CreateSandboxEnvironmentSnapshotRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}:snapshot".format_map(request_url_dict) + else: + path = "{name}:snapshot" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = self._api_client.request("post", path, request_dict, http_options) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.SandboxEnvironmentSnapshot._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value + + def delete( + self, + *, + name: str, + config: Optional[types.DeleteSandboxEnvironmentSnapshotConfigOrDict] = None, + ) -> types.DeleteSandboxEnvironmentSnapshotOperation: + """ + Deletes a sandbox environment snapshot. + + """ + + parameter_model = types._DeleteSandboxEnvironmentSnapshotRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _DeleteSandboxEnvironmentSnapshotRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}".format_map(request_url_dict) + else: + path = "{name}" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = self._api_client.request("delete", path, request_dict, http_options) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.DeleteSandboxEnvironmentSnapshotOperation._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value + + def get( + self, + *, + name: str, + config: Optional[types.GetSandboxEnvironmentSnapshotConfigOrDict] = None, + ) -> types.SandboxEnvironmentSnapshot: + """ + Gets a sandbox environment snapshot. + + """ + + parameter_model = types._GetSandboxEnvironmentSnapshotRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _GetSandboxEnvironmentSnapshotRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}".format_map(request_url_dict) + else: + path = "{name}" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = self._api_client.request("get", path, request_dict, http_options) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.SandboxEnvironmentSnapshot._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value + + def list( + self, + *, + name: str, + config: Optional[types.ListSandboxEnvironmentSnapshotsConfigOrDict] = None, + ) -> types.ListSandboxEnvironmentSnapshotsResponse: + """ + Lists sandbox environment snapshots. + + """ + + parameter_model = types._ListSandboxEnvironmentSnapshotsRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _ListSandboxEnvironmentSnapshotsRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}/sandboxEnvironmentSnapshots".format_map(request_url_dict) + else: + path = "{name}/sandboxEnvironmentSnapshots" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = self._api_client.request("get", path, request_dict, http_options) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.ListSandboxEnvironmentSnapshotsResponse._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value + + +class AsyncSandboxSnapshots(_api_module.BaseModule): + """Sandbox environment snapshot commands.""" + + async def create( + self, + *, + name: str, + sandbox_environment_snapshot: types.SandboxEnvironmentSnapshotOrDict, + config: Optional[types.CreateSandboxEnvironmentSnapshotConfigOrDict] = None, + ) -> types.SandboxEnvironmentSnapshot: + """ + Snapshots a sandbox environment. + + """ + + parameter_model = types._CreateSandboxEnvironmentSnapshotRequestParameters( + name=name, + sandbox_environment_snapshot=sandbox_environment_snapshot, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _CreateSandboxEnvironmentSnapshotRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}:snapshot".format_map(request_url_dict) + else: + path = "{name}:snapshot" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = await self._api_client.async_request( + "post", path, request_dict, http_options + ) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.SandboxEnvironmentSnapshot._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value + + async def delete( + self, + *, + name: str, + config: Optional[types.DeleteSandboxEnvironmentSnapshotConfigOrDict] = None, + ) -> types.DeleteSandboxEnvironmentSnapshotOperation: + """ + Deletes a sandbox environment snapshot. + + """ + + parameter_model = types._DeleteSandboxEnvironmentSnapshotRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _DeleteSandboxEnvironmentSnapshotRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}".format_map(request_url_dict) + else: + path = "{name}" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = await self._api_client.async_request( + "delete", path, request_dict, http_options + ) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.DeleteSandboxEnvironmentSnapshotOperation._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value + + async def get( + self, + *, + name: str, + config: Optional[types.GetSandboxEnvironmentSnapshotConfigOrDict] = None, + ) -> types.SandboxEnvironmentSnapshot: + """ + Gets a sandbox environment snapshot. + + """ + + parameter_model = types._GetSandboxEnvironmentSnapshotRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _GetSandboxEnvironmentSnapshotRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}".format_map(request_url_dict) + else: + path = "{name}" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = await self._api_client.async_request( + "get", path, request_dict, http_options + ) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.SandboxEnvironmentSnapshot._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value + + async def list( + self, + *, + name: str, + config: Optional[types.ListSandboxEnvironmentSnapshotsConfigOrDict] = None, + ) -> types.ListSandboxEnvironmentSnapshotsResponse: + """ + Lists sandbox environment snapshots. + + """ + + parameter_model = types._ListSandboxEnvironmentSnapshotsRequestParameters( + name=name, + config=config, + ) + + request_url_dict: Optional[dict[str, str]] + if not self._api_client.vertexai: + raise ValueError("This method is only supported in the Vertex AI client.") + else: + request_dict = _ListSandboxEnvironmentSnapshotsRequestParameters_to_vertex( + parameter_model + ) + request_url_dict = request_dict.get("_url") + if request_url_dict: + path = "{name}/sandboxEnvironmentSnapshots".format_map(request_url_dict) + else: + path = "{name}/sandboxEnvironmentSnapshots" + + query_params = request_dict.get("_query") + if query_params: + path = f"{path}?{urlencode(query_params)}" + # TODO: remove the hack that pops config. + request_dict.pop("config", None) + + http_options: Optional[types.HttpOptions] = None + if ( + parameter_model.config is not None + and parameter_model.config.http_options is not None + ): + http_options = parameter_model.config.http_options + + request_dict = _common.convert_to_dict(request_dict) + request_dict = _common.encode_unserializable_types(request_dict) + + response = await self._api_client.async_request( + "get", path, request_dict, http_options + ) + + response_dict = {} if not response.body else json.loads(response.body) + + return_value = types.ListSandboxEnvironmentSnapshotsResponse._from_response( + response=response_dict, + kwargs=( + { + "config": { + "response_schema": getattr( + parameter_model.config, "response_schema", None + ), + "response_json_schema": getattr( + parameter_model.config, "response_json_schema", None + ), + "include_all_fields": getattr( + parameter_model.config, "include_all_fields", None + ), + } + } + if getattr(parameter_model, "config", None) + else {} + ), + ) + + self._api_client._verify_response(return_value) + return return_value diff --git a/vertexai/_genai/sandboxes.py b/vertexai/_genai/sandboxes.py index dcea0f260e..7dc7455740 100644 --- a/vertexai/_genai/sandboxes.py +++ b/vertexai/_genai/sandboxes.py @@ -16,6 +16,7 @@ # Code generated by the Google Gen AI SDK generator DO NOT EDIT. import functools +import importlib import json import logging import mimetypes @@ -76,6 +77,13 @@ def _CreateAgentEngineSandboxRequestParameters_to_vertex( getv(from_object, ["config"]), to_object ) + if getv(from_object, ["sandbox_environment_snapshot"]) is not None: + setv( + to_object, + ["sandbox_environment_snapshot"], + getv(from_object, ["sandbox_environment_snapshot"]), + ) + return to_object @@ -170,6 +178,7 @@ def _create( name: str, spec: Optional[types.SandboxEnvironmentSpecOrDict] = None, config: Optional[types.CreateAgentEngineSandboxConfigOrDict] = None, + sandbox_environment_snapshot: Optional[str] = None, ) -> types.AgentEngineSandboxOperation: """ Creates a new sandbox in the Agent Engine. @@ -179,6 +188,7 @@ def _create( name=name, spec=spec, config=config, + sandbox_environment_snapshot=sandbox_environment_snapshot, ) request_url_dict: Optional[dict[str, str]] @@ -618,6 +628,23 @@ def _get_sandbox_operation( self._api_client._verify_response(return_value) return return_value + _snapshots = None + + @property + def snapshots(self) -> Any: + if self._snapshots is None: + try: + self._snapshots = importlib.import_module( + ".sandbox_snapshots", __package__ + ) + except ImportError as e: + raise ImportError( + "The agent_engines.sandboxes.snapshots module requires additional packages. " + "Please install them using pip install " + "google-cloud-aiplatform[agent_engines]" + ) from e + return self._snapshots.SandboxSnapshots(self._api_client) + def create( self, *, @@ -970,6 +997,7 @@ async def _create( name: str, spec: Optional[types.SandboxEnvironmentSpecOrDict] = None, config: Optional[types.CreateAgentEngineSandboxConfigOrDict] = None, + sandbox_environment_snapshot: Optional[str] = None, ) -> types.AgentEngineSandboxOperation: """ Creates a new sandbox in the Agent Engine. @@ -979,6 +1007,7 @@ async def _create( name=name, spec=spec, config=config, + sandbox_environment_snapshot=sandbox_environment_snapshot, ) request_url_dict: Optional[dict[str, str]] diff --git a/vertexai/_genai/types/__init__.py b/vertexai/_genai/types/__init__.py index f293f22bc7..e98ce9580c 100644 --- a/vertexai/_genai/types/__init__.py +++ b/vertexai/_genai/types/__init__.py @@ -39,6 +39,7 @@ from .common import _CreateEvaluationRunParameters from .common import _CreateEvaluationSetParameters from .common import _CreateMultimodalDatasetParameters +from .common import _CreateSandboxEnvironmentSnapshotRequestParameters from .common import _CustomJobParameters from .common import _CustomJobParameters from .common import _DeleteAgentEngineMemoryRequestParameters @@ -49,6 +50,7 @@ from .common import _DeleteDatasetRequestParameters from .common import _DeleteMultimodalDatasetRequestParameters from .common import _DeletePromptVersionRequestParameters +from .common import _DeleteSandboxEnvironmentSnapshotRequestParameters from .common import _EvaluateInstancesRequestParameters from .common import _ExecuteCodeAgentEngineSandboxRequestParameters from .common import _GenerateAgentEngineMemoriesRequestParameters @@ -77,6 +79,7 @@ from .common import _GetEvaluationSetParameters from .common import _GetMultimodalDatasetOperationParameters from .common import _GetMultimodalDatasetParameters +from .common import _GetSandboxEnvironmentSnapshotRequestParameters from .common import _ListAgentEngineMemoryRequestParameters from .common import _ListAgentEngineMemoryRevisionsRequestParameters from .common import _ListAgentEngineRequestParameters @@ -89,6 +92,7 @@ from .common import _ListDatasetVersionsRequestParameters from .common import _ListEvaluationMetricsParameters from .common import _ListMultimodalDatasetsRequestParameters +from .common import _ListSandboxEnvironmentSnapshotsRequestParameters from .common import _OptimizeRequestParameters from .common import _OptimizeRequestParameters from .common import _PurgeAgentEngineMemoriesRequestParameters @@ -261,6 +265,9 @@ from .common import CreatePromptVersionConfig from .common import CreatePromptVersionConfigDict from .common import CreatePromptVersionConfigOrDict +from .common import CreateSandboxEnvironmentSnapshotConfig +from .common import CreateSandboxEnvironmentSnapshotConfigDict +from .common import CreateSandboxEnvironmentSnapshotConfigOrDict from .common import CustomCodeExecutionSpec from .common import CustomCodeExecutionSpecDict from .common import CustomCodeExecutionSpecOrDict @@ -315,6 +322,12 @@ from .common import DeletePromptVersionOperation from .common import DeletePromptVersionOperationDict from .common import DeletePromptVersionOperationOrDict +from .common import DeleteSandboxEnvironmentSnapshotConfig +from .common import DeleteSandboxEnvironmentSnapshotConfigDict +from .common import DeleteSandboxEnvironmentSnapshotConfigOrDict +from .common import DeleteSandboxEnvironmentSnapshotOperation +from .common import DeleteSandboxEnvironmentSnapshotOperationDict +from .common import DeleteSandboxEnvironmentSnapshotOperationOrDict from .common import DiskSpec from .common import DiskSpecDict from .common import DiskSpecOrDict @@ -534,6 +547,9 @@ from .common import GetPromptConfig from .common import GetPromptConfigDict from .common import GetPromptConfigOrDict +from .common import GetSandboxEnvironmentSnapshotConfig +from .common import GetSandboxEnvironmentSnapshotConfigDict +from .common import GetSandboxEnvironmentSnapshotConfigOrDict from .common import IdentityType from .common import Importance from .common import IntermediateExtractedMemory @@ -616,6 +632,12 @@ from .common import ListReasoningEnginesSessionsResponse from .common import ListReasoningEnginesSessionsResponseDict from .common import ListReasoningEnginesSessionsResponseOrDict +from .common import ListSandboxEnvironmentSnapshotsConfig +from .common import ListSandboxEnvironmentSnapshotsConfigDict +from .common import ListSandboxEnvironmentSnapshotsConfigOrDict +from .common import ListSandboxEnvironmentSnapshotsResponse +from .common import ListSandboxEnvironmentSnapshotsResponseDict +from .common import ListSandboxEnvironmentSnapshotsResponseOrDict from .common import LLMMetric from .common import LossAnalysisConfig from .common import LossAnalysisConfigDict @@ -986,6 +1008,9 @@ from .common import SandboxEnvironmentConnectionInfoOrDict from .common import SandboxEnvironmentDict from .common import SandboxEnvironmentOrDict +from .common import SandboxEnvironmentSnapshot +from .common import SandboxEnvironmentSnapshotDict +from .common import SandboxEnvironmentSnapshotOrDict from .common import SandboxEnvironmentSpec from .common import SandboxEnvironmentSpecCodeExecutionEnvironment from .common import SandboxEnvironmentSpecCodeExecutionEnvironmentDict @@ -1966,6 +1991,27 @@ "ListAgentEngineSandboxesResponse", "ListAgentEngineSandboxesResponseDict", "ListAgentEngineSandboxesResponseOrDict", + "SandboxEnvironmentSnapshot", + "SandboxEnvironmentSnapshotDict", + "SandboxEnvironmentSnapshotOrDict", + "CreateSandboxEnvironmentSnapshotConfig", + "CreateSandboxEnvironmentSnapshotConfigDict", + "CreateSandboxEnvironmentSnapshotConfigOrDict", + "DeleteSandboxEnvironmentSnapshotConfig", + "DeleteSandboxEnvironmentSnapshotConfigDict", + "DeleteSandboxEnvironmentSnapshotConfigOrDict", + "DeleteSandboxEnvironmentSnapshotOperation", + "DeleteSandboxEnvironmentSnapshotOperationDict", + "DeleteSandboxEnvironmentSnapshotOperationOrDict", + "GetSandboxEnvironmentSnapshotConfig", + "GetSandboxEnvironmentSnapshotConfigDict", + "GetSandboxEnvironmentSnapshotConfigOrDict", + "ListSandboxEnvironmentSnapshotsConfig", + "ListSandboxEnvironmentSnapshotsConfigDict", + "ListSandboxEnvironmentSnapshotsConfigOrDict", + "ListSandboxEnvironmentSnapshotsResponse", + "ListSandboxEnvironmentSnapshotsResponseDict", + "ListSandboxEnvironmentSnapshotsResponseOrDict", "CreateAgentEngineSessionConfig", "CreateAgentEngineSessionConfigDict", "CreateAgentEngineSessionConfigOrDict", @@ -2356,6 +2402,10 @@ "_GetAgentEngineSandboxRequestParameters", "_ListAgentEngineSandboxesRequestParameters", "_GetAgentEngineSandboxOperationParameters", + "_CreateSandboxEnvironmentSnapshotRequestParameters", + "_DeleteSandboxEnvironmentSnapshotRequestParameters", + "_GetSandboxEnvironmentSnapshotRequestParameters", + "_ListSandboxEnvironmentSnapshotsRequestParameters", "_CreateAgentEngineSessionRequestParameters", "_DeleteAgentEngineSessionRequestParameters", "_GetAgentEngineSessionRequestParameters", diff --git a/vertexai/_genai/types/common.py b/vertexai/_genai/types/common.py index b67be65045..cfaf2e0ff6 100644 --- a/vertexai/_genai/types/common.py +++ b/vertexai/_genai/types/common.py @@ -10951,6 +10951,10 @@ class _CreateAgentEngineSandboxRequestParameters(_common.BaseModel): config: Optional[CreateAgentEngineSandboxConfig] = Field( default=None, description="""""" ) + sandbox_environment_snapshot: Optional[str] = Field( + default=None, + description="""The resource name of the SandboxEnvironmentSnapshot to use for creating this SandboxEnvironment.""", + ) class _CreateAgentEngineSandboxRequestParametersDict(TypedDict, total=False): @@ -10965,6 +10969,9 @@ class _CreateAgentEngineSandboxRequestParametersDict(TypedDict, total=False): config: Optional[CreateAgentEngineSandboxConfigDict] """""" + sandbox_environment_snapshot: Optional[str] + """The resource name of the SandboxEnvironmentSnapshot to use for creating this SandboxEnvironment.""" + _CreateAgentEngineSandboxRequestParametersOrDict = Union[ _CreateAgentEngineSandboxRequestParameters, @@ -11518,6 +11525,313 @@ class _GetAgentEngineSandboxOperationParametersDict(TypedDict, total=False): ] +class SandboxEnvironmentSnapshot(_common.BaseModel): + """A sandbox environment snapshot.""" + + expire_time: Optional[datetime.datetime] = Field( + default=None, + description="""Expiration time of the sandbox environment snapshot. + """, + ) + + +class SandboxEnvironmentSnapshotDict(TypedDict, total=False): + """A sandbox environment snapshot.""" + + expire_time: Optional[datetime.datetime] + """Expiration time of the sandbox environment snapshot. + """ + + +SandboxEnvironmentSnapshotOrDict = Union[ + SandboxEnvironmentSnapshot, SandboxEnvironmentSnapshotDict +] + + +class CreateSandboxEnvironmentSnapshotConfig(_common.BaseModel): + """Config for creating a Sandbox Environment Snapshot.""" + + http_options: Optional[genai_types.HttpOptions] = Field( + default=None, description="""Used to override HTTP request options.""" + ) + + +class CreateSandboxEnvironmentSnapshotConfigDict(TypedDict, total=False): + """Config for creating a Sandbox Environment Snapshot.""" + + http_options: Optional[genai_types.HttpOptionsDict] + """Used to override HTTP request options.""" + + +CreateSandboxEnvironmentSnapshotConfigOrDict = Union[ + CreateSandboxEnvironmentSnapshotConfig, CreateSandboxEnvironmentSnapshotConfigDict +] + + +class _CreateSandboxEnvironmentSnapshotRequestParameters(_common.BaseModel): + """Parameters for creating a sandbox environment snapshot.""" + + name: Optional[str] = Field( + default=None, description="""Name of the sandbox environment to snapshot.""" + ) + sandbox_environment_snapshot: Optional[SandboxEnvironmentSnapshot] = Field( + default=None, description="""The sandbox environment snapshot to create.""" + ) + config: Optional[CreateSandboxEnvironmentSnapshotConfig] = Field( + default=None, description="""""" + ) + + +class _CreateSandboxEnvironmentSnapshotRequestParametersDict(TypedDict, total=False): + """Parameters for creating a sandbox environment snapshot.""" + + name: Optional[str] + """Name of the sandbox environment to snapshot.""" + + sandbox_environment_snapshot: Optional[SandboxEnvironmentSnapshotDict] + """The sandbox environment snapshot to create.""" + + config: Optional[CreateSandboxEnvironmentSnapshotConfigDict] + """""" + + +_CreateSandboxEnvironmentSnapshotRequestParametersOrDict = Union[ + _CreateSandboxEnvironmentSnapshotRequestParameters, + _CreateSandboxEnvironmentSnapshotRequestParametersDict, +] + + +class DeleteSandboxEnvironmentSnapshotConfig(_common.BaseModel): + """Config for deleting a Sandbox Environment Snapshot.""" + + http_options: Optional[genai_types.HttpOptions] = Field( + default=None, description="""Used to override HTTP request options.""" + ) + + +class DeleteSandboxEnvironmentSnapshotConfigDict(TypedDict, total=False): + """Config for deleting a Sandbox Environment Snapshot.""" + + http_options: Optional[genai_types.HttpOptionsDict] + """Used to override HTTP request options.""" + + +DeleteSandboxEnvironmentSnapshotConfigOrDict = Union[ + DeleteSandboxEnvironmentSnapshotConfig, DeleteSandboxEnvironmentSnapshotConfigDict +] + + +class _DeleteSandboxEnvironmentSnapshotRequestParameters(_common.BaseModel): + """Parameters for deleting sandbox environment snapshots.""" + + name: Optional[str] = Field( + default=None, + description="""Name of the sandbox environment snapshot to delete.""", + ) + config: Optional[DeleteSandboxEnvironmentSnapshotConfig] = Field( + default=None, description="""""" + ) + + +class _DeleteSandboxEnvironmentSnapshotRequestParametersDict(TypedDict, total=False): + """Parameters for deleting sandbox environment snapshots.""" + + name: Optional[str] + """Name of the sandbox environment snapshot to delete.""" + + config: Optional[DeleteSandboxEnvironmentSnapshotConfigDict] + """""" + + +_DeleteSandboxEnvironmentSnapshotRequestParametersOrDict = Union[ + _DeleteSandboxEnvironmentSnapshotRequestParameters, + _DeleteSandboxEnvironmentSnapshotRequestParametersDict, +] + + +class DeleteSandboxEnvironmentSnapshotOperation(_common.BaseModel): + """Operation for deleting sandbox environment snapshots.""" + + name: Optional[str] = Field( + default=None, + description="""The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""", + ) + metadata: Optional[dict[str, Any]] = Field( + default=None, + description="""Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.""", + ) + done: Optional[bool] = Field( + default=None, + description="""If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""", + ) + error: Optional[dict[str, Any]] = Field( + default=None, + description="""The error result of the operation in case of failure or cancellation.""", + ) + + +class DeleteSandboxEnvironmentSnapshotOperationDict(TypedDict, total=False): + """Operation for deleting sandbox environment snapshots.""" + + name: Optional[str] + """The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""" + + metadata: Optional[dict[str, Any]] + """Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.""" + + done: Optional[bool] + """If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""" + + error: Optional[dict[str, Any]] + """The error result of the operation in case of failure or cancellation.""" + + +DeleteSandboxEnvironmentSnapshotOperationOrDict = Union[ + DeleteSandboxEnvironmentSnapshotOperation, + DeleteSandboxEnvironmentSnapshotOperationDict, +] + + +class GetSandboxEnvironmentSnapshotConfig(_common.BaseModel): + """Config for getting a Sandbox Environment Snapshot.""" + + http_options: Optional[genai_types.HttpOptions] = Field( + default=None, description="""Used to override HTTP request options.""" + ) + + +class GetSandboxEnvironmentSnapshotConfigDict(TypedDict, total=False): + """Config for getting a Sandbox Environment Snapshot.""" + + http_options: Optional[genai_types.HttpOptionsDict] + """Used to override HTTP request options.""" + + +GetSandboxEnvironmentSnapshotConfigOrDict = Union[ + GetSandboxEnvironmentSnapshotConfig, GetSandboxEnvironmentSnapshotConfigDict +] + + +class _GetSandboxEnvironmentSnapshotRequestParameters(_common.BaseModel): + """Parameters for getting a sandbox environment snapshot.""" + + name: Optional[str] = Field( + default=None, description="""Name of the sandbox environment snapshot.""" + ) + config: Optional[GetSandboxEnvironmentSnapshotConfig] = Field( + default=None, description="""""" + ) + + +class _GetSandboxEnvironmentSnapshotRequestParametersDict(TypedDict, total=False): + """Parameters for getting a sandbox environment snapshot.""" + + name: Optional[str] + """Name of the sandbox environment snapshot.""" + + config: Optional[GetSandboxEnvironmentSnapshotConfigDict] + """""" + + +_GetSandboxEnvironmentSnapshotRequestParametersOrDict = Union[ + _GetSandboxEnvironmentSnapshotRequestParameters, + _GetSandboxEnvironmentSnapshotRequestParametersDict, +] + + +class ListSandboxEnvironmentSnapshotsConfig(_common.BaseModel): + """Config for listing sandbox environment snapshots.""" + + http_options: Optional[genai_types.HttpOptions] = Field( + default=None, description="""Used to override HTTP request options.""" + ) + page_size: Optional[int] = Field(default=None, description="""""") + page_token: Optional[str] = Field(default=None, description="""""") + filter: Optional[str] = Field( + default=None, + description="""An expression for filtering the results of the request.""", + ) + + +class ListSandboxEnvironmentSnapshotsConfigDict(TypedDict, total=False): + """Config for listing sandbox environment snapshots.""" + + http_options: Optional[genai_types.HttpOptionsDict] + """Used to override HTTP request options.""" + + page_size: Optional[int] + """""" + + page_token: Optional[str] + """""" + + filter: Optional[str] + """An expression for filtering the results of the request.""" + + +ListSandboxEnvironmentSnapshotsConfigOrDict = Union[ + ListSandboxEnvironmentSnapshotsConfig, ListSandboxEnvironmentSnapshotsConfigDict +] + + +class _ListSandboxEnvironmentSnapshotsRequestParameters(_common.BaseModel): + """Parameters for listing sandbox environment snapshots.""" + + name: Optional[str] = Field( + default=None, + description="""Name of the reasoning engine to list snapshots from.""", + ) + config: Optional[ListSandboxEnvironmentSnapshotsConfig] = Field( + default=None, description="""""" + ) + + +class _ListSandboxEnvironmentSnapshotsRequestParametersDict(TypedDict, total=False): + """Parameters for listing sandbox environment snapshots.""" + + name: Optional[str] + """Name of the reasoning engine to list snapshots from.""" + + config: Optional[ListSandboxEnvironmentSnapshotsConfigDict] + """""" + + +_ListSandboxEnvironmentSnapshotsRequestParametersOrDict = Union[ + _ListSandboxEnvironmentSnapshotsRequestParameters, + _ListSandboxEnvironmentSnapshotsRequestParametersDict, +] + + +class ListSandboxEnvironmentSnapshotsResponse(_common.BaseModel): + """Response for listing sandbox environment snapshots.""" + + sdk_http_response: Optional[genai_types.HttpResponse] = Field( + default=None, description="""Used to retain the full HTTP response.""" + ) + next_page_token: Optional[str] = Field(default=None, description="""""") + sandbox_environment_snapshots: Optional[list[SandboxEnvironmentSnapshot]] = Field( + default=None, description="""List of sandbox environment snapshots.""" + ) + + +class ListSandboxEnvironmentSnapshotsResponseDict(TypedDict, total=False): + """Response for listing sandbox environment snapshots.""" + + sdk_http_response: Optional[genai_types.HttpResponseDict] + """Used to retain the full HTTP response.""" + + next_page_token: Optional[str] + """""" + + sandbox_environment_snapshots: Optional[list[SandboxEnvironmentSnapshotDict]] + """List of sandbox environment snapshots.""" + + +ListSandboxEnvironmentSnapshotsResponseOrDict = Union[ + ListSandboxEnvironmentSnapshotsResponse, ListSandboxEnvironmentSnapshotsResponseDict +] + + class CreateAgentEngineSessionConfig(_common.BaseModel): """Config for creating a Session."""