Sandboxes(api_client_: google.genai._api_client.BaseApiClient)API documentation for Sandboxes class.
Properties
snapshots
API documentation for snapshots property.
templates
API documentation for templates property.
Methods
create
create(
*,
name: str,
poll_interval_seconds: float = 0.1,
spec: typing.Optional[
typing.Union[
vertexai._genai.types.common.SandboxEnvironmentSpec,
vertexai._genai.types.common.SandboxEnvironmentSpecDict,
]
] = None,
config: typing.Optional[
typing.Union[
vertexai._genai.types.common.CreateAgentEngineSandboxConfig,
vertexai._genai.types.common.CreateAgentEngineSandboxConfigDict,
]
] = None
) -> vertexai._genai.types.common.AgentEngineSandboxOperationCreates a new sandbox in the Agent Engine.
| Parameters | |
|---|---|
| Name | Description |
name |
str
Required. The name of the agent engine to create sandbox for. projects/{project}/locations/{location}/reasoningEngines/{resource_id} |
poll_interval_seconds |
float
Optional. The interval in seconds to poll for sandbox creation completion. |
spec |
SandboxEnvironmentSpec
Optional. The specification for the sandbox to create. |
config |
CreateAgentEngineSandboxConfigOrDict
Optional. The configuration for the sandbox. |
| Returns | |
|---|---|
| Type | Description |
AgentEngineSandboxOperation |
The operation for creating the sandbox. |
delete
delete(
*,
name: str,
config: typing.Optional[
typing.Union[
vertexai._genai.types.common.DeleteAgentEngineSandboxConfig,
vertexai._genai.types.common.DeleteAgentEngineSandboxConfigDict,
]
] = None
) -> vertexai._genai.types.common.DeleteAgentEngineSandboxOperationDeletes an agent engine sandbox.
| Parameters | |
|---|---|
| Name | Description |
name |
str
Required. A fully-qualified resource name or ID such as projects/{project}/locations/{location}/reasoningEngines/{resource_id}/SandboxEnvironments/{sandbox_id} or a shortened name such as "reasoningEngines/{resource_id}/sandboxEnvironments/{sandbox_id}". |
config |
DeleteAgentEngineSandboxConfigOrDict
Optional. The configuration for the sandbox to delete. |
execute_code
execute_code(
*,
name: str,
input_data: dict[str, typing.Any],
config: typing.Optional[
typing.Union[
vertexai._genai.types.common.ExecuteCodeAgentEngineSandboxConfig,
vertexai._genai.types.common.ExecuteCodeAgentEngineSandboxConfigDict,
]
] = None
) -> vertexai._genai.types.common.ExecuteSandboxEnvironmentResponseExecutes code in the Agent Engine sandbox.
| Parameters | |
|---|---|
| Name | Description |
name |
str
Required. The name of the agent engine sandbox to run code in. projects/{project}/locations/{location}/reasoningEngines/{resource_id}/SandboxEnvironments/{sandbox_id} |
input_data |
dict[str, Any]
Required. The input to the code to execute. |
config |
ExecuteCodeAgentEngineSandboxConfigOrDict
Optional. The configuration for the sandboxes to run code in. |
| Returns | |
|---|---|
| Type | Description |
ExecuteSandboxEnvironmentResponse |
The response from executing the code. |
generate_access_token
generate_access_token(service_account_email: str, timeout: int = 3600) -> strSigns a JWT with a Google Cloud service account.
| Parameters | |
|---|---|
| Name | Description |
service_account_email |
str
Required. The email of the service account to use for signing. |
timeout |
int
Optional. The timeout in seconds for the token. Defaults to 3600. |
| Returns | |
|---|---|
| Type | Description |
str |
The signed JWT. |
generate_browser_ws_headers
generate_browser_ws_headers(
sandbox_environment: vertexai._genai.types.common.SandboxEnvironment,
service_account_email: str,
port: str = "8080",
timeout: int = 3600,
psc_endpoint: typing.Optional[str] = None,
) -> tuple[str, dict[str, str]]Generates the websocket upgrade headers for the browser.
| Parameters | |
|---|---|
| Name | Description |
sandbox_environment |
types.SandboxEnvironment
Required. The sandbox environment to generate websocket headers for. |
service_account_email |
str
Required. The email of the service account to use for signing. |
port |
str
Optional. The port to use for the CDP websocket endpoint url fetching. Defaults to "8080". This should be one of the ports specified during template creation. |
timeout |
int
Optional. The timeout in seconds for the token. Defaults to 3600. |
psc_endpoint |
str
Optional. Host (RFC1918 IP or resolvable internal hostname) of the customer-side PSC endpoint forwarding rule that targets |
| Returns | |
|---|---|
| Type | Description |
tuple[str, dict[str, str]] |
A tuple containing the websocket URL and the headers for websocket upgrade. |
get
get(
*,
name: str,
config: typing.Optional[
typing.Union[
vertexai._genai.types.common.GetAgentEngineSandboxConfig,
vertexai._genai.types.common.GetAgentEngineSandboxConfigDict,
]
] = None
) -> vertexai._genai.types.common.SandboxEnvironmentGets an agent engine sandbox.
| Parameters | |
|---|---|
| Name | Description |
name |
str
Required. A fully-qualified resource name or ID such as projects/{project}/locations/{location}/reasoningEngines/{resource_id}/SandboxEnvironments/{sandbox_id} or a shortened name such as "reasoningEngines/{resource_id}/sandboxEnvironments/{sandbox_id}". |
config |
GetAgentEngineSandboxConfigOrDict
Optional. The configuration for the sandbox to get. |
list
list(
*,
name: str,
config: typing.Optional[
typing.Union[
vertexai._genai.types.common.ListAgentEngineSandboxesConfig,
vertexai._genai.types.common.ListAgentEngineSandboxesConfigDict,
]
] = None
) -> typing.Iterator[vertexai._genai.types.common.SandboxEnvironment]Lists Agent Engine sandboxes.
| Parameters | |
|---|---|
| Name | Description |
name |
str
Required. The name of the agent engine to list sandboxes for. projects/{project}/locations/{location}/reasoningEngines/{resource_id}/SandboxEnvironments/{sandbox_id} |
config |
ListAgentEngineSandboxConfig
Optional. The configuration for the sandboxes to list. |
| Returns | |
|---|---|
| Type | Description |
Iterable[SandboxEnvironment] |
An iterable of agent engine sandboxes. |
send_command
send_command(
*,
http_method: str,
access_token: str,
sandbox_environment: vertexai._genai.types.common.SandboxEnvironment,
port: str = "8080",
path: typing.Optional[str] = None,
query_params: typing.Optional[dict[str, object]] = None,
headers: typing.Optional[dict[str, str]] = None,
request_dict: typing.Optional[dict[str, object]] = None,
psc_endpoint: typing.Optional[str] = None
) -> google.genai.types.HttpResponseSends a command to the sandbox.
| Parameters | |
|---|---|
| Name | Description |
http_method |
str
Required. The HTTP method to use for the command. |
access_token |
str
Required. The access token to use for authorization. |
sandbox_environment |
types.SandboxEnvironment
Required. The sandbox environment to send the command to. |
port |
str
Optional. The port to use for the token. Defaults to "8080". This should be one of the ports specified during template creation. |
path |
str
Optional. The path to send the command to. |
query_params |
dict[str, object]
Optional. The query parameters to include in the command. |
headers |
dict[str, str]
Optional. The headers to include in the command. |
request_dict |
dict[str, object]
Optional. The request body to include in the command. |
psc_endpoint |
str
Optional. Host (RFC1918 IP or resolvable internal hostname) of the customer-side PSC endpoint forwarding rule that targets |
| Returns | |
|---|---|
| Type | Description |
genai_types.HttpResponse |
The response from the sandbox. |