Skip to content

Commit 68f053e

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add support for templates sub-module for Sandboxes in Vertex AI GenAI SDK.
PiperOrigin-RevId: 907839994
1 parent d9675fd commit 68f053e

10 files changed

Lines changed: 2064 additions & 0 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
21+
def test_sandbox_templates_byoc_create(client):
22+
container_image_uri = "us-central1-docker.pkg.dev/agent-sandbox-fishfood-1564/agent-sandbox/custom-jupiter-sandbox:latest"
23+
cpu_request = "1"
24+
memory_request = "500Mi"
25+
cpu_limit = "1"
26+
memory_limit = "500Mi"
27+
config = {
28+
"custom_container_environment": {
29+
"custom_container_spec": {"image_uri": container_image_uri},
30+
"resources": {
31+
"requests": {
32+
"cpu": cpu_request,
33+
"memory": memory_request,
34+
},
35+
"limits": {
36+
"cpu": cpu_limit,
37+
"memory": memory_limit,
38+
},
39+
},
40+
"ports": [
41+
{
42+
"port": 8080,
43+
"protocol": "TCP",
44+
}
45+
],
46+
},
47+
"egress_control_config": {
48+
"internet_access": True,
49+
},
50+
}
51+
sandbox_template_operation = client.agent_engines.sandboxes.templates.create(
52+
name=(
53+
"projects/254005681254/locations/us-central1/reasoningEngines/208148546254274560"
54+
),
55+
display_name="Test Sandbox Template 1",
56+
config=config,
57+
)
58+
assert isinstance(
59+
sandbox_template_operation, types.SandboxEnvironmentTemplateOperation
60+
)
61+
62+
63+
pytestmark = pytest_helper.setup(
64+
file=__file__,
65+
globals_for_file=globals(),
66+
test_method="agent_engines.sandboxes.templates.create",
67+
)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
21+
def test_sandbox_templates_default_create(client):
22+
config = {
23+
"default_container_environment": {
24+
"default_container_category": "DEFAULT_CONTAINER_CATEGORY_COMPUTER_USE",
25+
},
26+
"egress_control_config": {
27+
"internet_access": True,
28+
},
29+
}
30+
sandbox_template_operation = client.agent_engines.sandboxes.templates.create(
31+
name=(
32+
"projects/254005681254/locations/us-central1/reasoningEngines/208148546254274560"
33+
),
34+
display_name="Test Sandbox Template 1",
35+
config=config,
36+
)
37+
assert isinstance(
38+
sandbox_template_operation, types.SandboxEnvironmentTemplateOperation
39+
)
40+
41+
42+
pytestmark = pytest_helper.setup(
43+
file=__file__,
44+
globals_for_file=globals(),
45+
test_method="agent_engines.sandboxes.templates.create",
46+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
21+
def test_sandbox_templates_delete(client):
22+
sandbox_template_delete_operation = client.agent_engines.sandboxes.templates.delete(
23+
name=(
24+
"projects/254005681254/locations/us-central1/reasoningEngines/208148546254274560/sandboxEnvironmentTemplates/4632233691727265792"
25+
),
26+
)
27+
assert isinstance(
28+
sandbox_template_delete_operation,
29+
types.DeleteSandboxEnvironmentTemplateOperation,
30+
)
31+
32+
33+
pytestmark = pytest_helper.setup(
34+
file=__file__,
35+
globals_for_file=globals(),
36+
test_method="agent_engines.sandboxes.templates.delete",
37+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
21+
def test_sandbox_templates_get(client):
22+
sandbox_template_name = "projects/254005681254/locations/us-central1/reasoningEngines/208148546254274560/sandboxEnvironmentTemplates/4632233691727265792"
23+
24+
sandbox_template = client.agent_engines.sandboxes.templates.get(
25+
name=sandbox_template_name
26+
)
27+
assert isinstance(sandbox_template, types.SandboxEnvironmentTemplate)
28+
assert sandbox_template.name == sandbox_template_name
29+
30+
31+
pytestmark = pytest_helper.setup(
32+
file=__file__,
33+
globals_for_file=globals(),
34+
test_method="agent_engines.sandboxes.templates.get",
35+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
21+
def test_get_sandbox_template_operation(client):
22+
operation_name = (
23+
"projects/254005681254/locations/us-central1/operations/7252775414349692928"
24+
)
25+
26+
sandbox_template_operation = client.agent_engines.sandboxes.templates.get_sandbox_environment_template_operation(
27+
operation_name=operation_name
28+
)
29+
assert isinstance(
30+
sandbox_template_operation, types.SandboxEnvironmentTemplateOperation
31+
)
32+
assert sandbox_template_operation.name == operation_name
33+
34+
35+
pytestmark = pytest_helper.setup(
36+
file=__file__,
37+
globals_for_file=globals(),
38+
test_method="agent_engines.sandboxes.templates.get_sandbox_environment_template_operation",
39+
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
21+
def test_sandbox_templates_list(client):
22+
sandbox_templates_list_operation = client.agent_engines.sandboxes.templates.list(
23+
name=(
24+
"projects/254005681254/locations/us-central1/reasoningEngines/208148546254274560"
25+
),
26+
)
27+
assert isinstance(
28+
sandbox_templates_list_operation.sandbox_environment_templates[0],
29+
types.SandboxEnvironmentTemplate,
30+
)
31+
assert isinstance(
32+
sandbox_templates_list_operation, types.ListSandboxEnvironmentTemplatesResponse
33+
)
34+
35+
36+
pytestmark = pytest_helper.setup(
37+
file=__file__,
38+
globals_for_file=globals(),
39+
test_method="agent_engines.sandboxes.templates.list",
40+
)

0 commit comments

Comments
 (0)