Skip to content

Commit 1129dd2

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add support for templates sub-module for Sandboxes in Vertex AI GenAI SDK.
PiperOrigin-RevId: 904556301
1 parent 0bb2ecd commit 1129dd2

10 files changed

Lines changed: 2072 additions & 0 deletions
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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": {
30+
"image_uri": container_image_uri
31+
},
32+
"resources": {
33+
"requests": {
34+
"cpu": cpu_request,
35+
"memory": memory_request,
36+
},
37+
"limits": {
38+
"cpu": cpu_limit,
39+
"memory": memory_limit,
40+
}
41+
},
42+
"ports": [
43+
{
44+
"port": 8080,
45+
"protocol": "TCP",
46+
}
47+
]
48+
},
49+
"egress_control_config": {
50+
"internet_access": True,
51+
},
52+
}
53+
sandbox_template_operation = client.agent_engines.sandboxes.templates.create(
54+
name=(
55+
"projects/254005681254/locations/us-central1/reasoningEngines/208148546254274560"
56+
),
57+
display_name="Test Sandbox Template 1",
58+
config=config,
59+
)
60+
assert isinstance(
61+
sandbox_template_operation,
62+
types.SandboxEnvironmentTemplateOperation
63+
)
64+
65+
66+
pytestmark = pytest_helper.setup(
67+
file=__file__,
68+
globals_for_file=globals(),
69+
test_method="agent_engines.sandboxes.templates.create",
70+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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,
39+
types.SandboxEnvironmentTemplateOperation
40+
)
41+
42+
43+
pytestmark = pytest_helper.setup(
44+
file=__file__,
45+
globals_for_file=globals(),
46+
test_method="agent_engines.sandboxes.templates.create",
47+
)
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: 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_get(client):
22+
sandbox_template_name = (
23+
"projects/254005681254/locations/us-central1/reasoningEngines/208148546254274560/sandboxEnvironmentTemplates/4632233691727265792"
24+
)
25+
26+
sandbox_template = client.agent_engines.sandboxes.templates.get(
27+
name=sandbox_template_name
28+
)
29+
assert isinstance(sandbox_template, types.SandboxEnvironmentTemplate)
30+
assert sandbox_template.name == sandbox_template_name
31+
32+
33+
pytestmark = pytest_helper.setup(
34+
file=__file__,
35+
globals_for_file=globals(),
36+
test_method="agent_engines.sandboxes.templates.get",
37+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 = (
27+
client.agent_engines.sandboxes.templates.get_sandbox_environment_template_operation(
28+
operation_name=operation_name
29+
)
30+
)
31+
assert isinstance(
32+
sandbox_template_operation, types.SandboxEnvironmentTemplateOperation)
33+
assert sandbox_template_operation.name == operation_name
34+
35+
36+
pytestmark = pytest_helper.setup(
37+
file=__file__,
38+
globals_for_file=globals(),
39+
test_method=
40+
"agent_engines.sandboxes.templates.get_sandbox_environment_template_operation",
41+
)
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)