# 管理 Volume
<subtitle>创建、连接、列出、查看和删除 Volume。</subtitle>

> 除了 SDK，您也可以使用 CLI 管理 Volume，参阅 [CLI 指南](/docs/agent-sandbox/product/cli.md)。

## 创建 Volume

```python
from ucloud_sandbox import Volume

volume = Volume.create('my-volume')
print(volume.volume_id)  # Volume ID
print(volume.name)       # 'my-volume'
```

## 连接已有的 Volume

使用 `connect()` 方法，通过 Volume ID 连接到已有的 Volume。

```python
from ucloud_sandbox import Volume

volume = Volume.connect('volume-id')
print(volume.volume_id)  # Volume ID
print(volume.name)       # Volume 名称
```

## 列出 Volume

```python
from ucloud_sandbox import Volume

volumes = Volume.list()
print(volumes)
# [VolumeInfo(volume_id='...', name='my-volume'), ...]
```

## 获取 Volume 信息

```python
from ucloud_sandbox import Volume

info = Volume.get_info('volume-id')
print(info)
# VolumeInfo(volume_id='...', name='my-volume')
```

## 删除 Volume

删除成功时返回 `True`；如果 Volume 不存在，返回 `False`。

```python
from ucloud_sandbox import Volume

success = Volume.destroy('volume-id')
print(success)  # True
```

> **注意**：删除 Volume 会同时删除其中的全部数据。请先确认数据已备份，并确保没有正在使用该 Volume 的沙箱。
