Skip to content

Commit 2eafad8

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add support for snapshots for Sandboxes in Vertex AI GenAI SDK.
PiperOrigin-RevId: 897294488
1 parent 68f053e commit 2eafad8

8 files changed

Lines changed: 1604 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Tests for Sandbox Snapshot create operation."""
2+
3+
# Copyright 2026 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring,bad-indentation
18+
19+
from tests.unit.vertexai.genai.replays import pytest_helper
20+
from vertexai._genai import types
21+
22+
23+
def test_create_sandbox_snapshot(client):
24+
snapshot = client.agent_engines.sandboxes.snapshots.create(
25+
source_sandbox_environment_name="projects/802583348448/locations/us-central1/reasoningEngines/6130241318758121472/sandboxEnvironments/525190525100228608",
26+
config={
27+
"display_name": "test_snapshot",
28+
"ttl": "3600s",
29+
"owner": "test_owner",
30+
},
31+
)
32+
33+
assert isinstance(snapshot, types.AgentEngineSandboxSnapshotOperation)
34+
35+
36+
pytestmark = pytest_helper.setup(
37+
file=__file__,
38+
globals_for_file=globals(),
39+
test_method="agent_engines.sandboxes.snapshots.create",
40+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Tests for Sandbox Snapshot delete operation."""
2+
3+
# Copyright 2026 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring,bad-indentation
18+
19+
from tests.unit.vertexai.genai.replays import pytest_helper
20+
from vertexai._genai import types
21+
22+
23+
def test_delete_sandbox_snapshot(client):
24+
result = client.agent_engines.sandboxes.snapshots.delete(
25+
name="projects/802583348448/locations/us-central1/reasoningEngines/6130241318758121472/sandboxEnvironmentSnapshots/421086565159141376",
26+
)
27+
28+
assert isinstance(result, types.DeleteSandboxEnvironmentSnapshotOperation)
29+
30+
31+
pytestmark = pytest_helper.setup(
32+
file=__file__,
33+
globals_for_file=globals(),
34+
test_method="agent_engines.sandboxes.snapshots.delete",
35+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Tests for Sandbox Snapshot get operation."""
2+
3+
# Copyright 2026 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring,bad-indentation
18+
19+
from tests.unit.vertexai.genai.replays import pytest_helper
20+
from vertexai._genai import types
21+
22+
23+
def test_get_sandbox_snapshot(client):
24+
snapshot_name = "projects/802583348448/locations/us-central1/reasoningEngines/6130241318758121472/sandboxEnvironmentSnapshots/421086565159141376"
25+
fetched_snapshot = client.agent_engines.sandboxes.snapshots.get(
26+
name=snapshot_name,
27+
)
28+
29+
assert isinstance(fetched_snapshot, types.SandboxEnvironmentSnapshot)
30+
assert fetched_snapshot.name == snapshot_name
31+
32+
33+
pytestmark = pytest_helper.setup(
34+
file=__file__,
35+
globals_for_file=globals(),
36+
test_method="agent_engines.sandboxes.snapshots.get",
37+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Tests for Sandbox Snapshot list operation."""
2+
3+
# Copyright 2026 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring,bad-indentation
18+
19+
from tests.unit.vertexai.genai.replays import pytest_helper
20+
from vertexai._genai import types
21+
22+
23+
def test_list_sandbox_snapshots(client):
24+
snapshots_list_operation = client.agent_engines.sandboxes.snapshots.list(
25+
name="projects/802583348448/locations/us-central1/reasoningEngines/6130241318758121472",
26+
)
27+
28+
assert isinstance(
29+
snapshots_list_operation.sandbox_environment_snapshots[0],
30+
types.SandboxEnvironmentSnapshot,
31+
)
32+
assert isinstance(
33+
snapshots_list_operation, types.ListSandboxEnvironmentSnapshotsResponse
34+
)
35+
36+
37+
pytestmark = pytest_helper.setup(
38+
file=__file__,
39+
globals_for_file=globals(),
40+
test_method="agent_engines.sandboxes.snapshots.list",
41+
)

0 commit comments

Comments
 (0)