apps/docs/src/content/docs/en/python-sdk/sync/volume.mdx
class Volume(VolumeDto)
Represents a Daytona Volume which is a shared storage volume for Sandboxes.
Attributes:
id str - Unique identifier for the Volume.name str - Name of the Volume.organization_id str - Organization ID of the Volume.state str - State of the Volume.created_at str - Date and time when the Volume was created.updated_at str - Date and time when the Volume was last updated.last_used_at str - Date and time when the Volume was last used.class VolumeService()
Service for managing Daytona Volumes. Can be used to list, get, create and delete Volumes.
def list() -> list[Volume]
List all Volumes.
Returns:
list[Volume] - List of all Volumes.Example:
daytona = Daytona()
volumes = daytona.volume.list()
for volume in volumes:
print(f"{volume.name} ({volume.id})")
@with_instrumentation()
def get(name: str, create: bool = False) -> Volume
Get a Volume by name.
Arguments:
name str - Name of the Volume to get.create bool - If True, create a new Volume if it doesn't exist.Returns:
Volume - The Volume object.Example:
daytona = Daytona()
volume = daytona.volume.get("test-volume-name", create=True)
print(f"{volume.name} ({volume.id})")
@with_instrumentation()
def create(name: str) -> Volume
Create a new Volume.
Arguments:
name str - Name of the Volume to create.Returns:
Volume - The Volume object.Example:
daytona = Daytona()
volume = daytona.volume.create("test-volume")
print(f"{volume.name} ({volume.id}); state: {volume.state}")
@with_instrumentation()
def delete(volume: Volume) -> None
Delete a Volume.
Arguments:
volume Volume - Volume to delete.Example:
daytona = Daytona()
volume = daytona.volume.get("test-volume")
daytona.volume.delete(volume)
print("Volume deleted")
class VolumeMount(ApiVolumeMount, AsyncApiVolumeMount)
Represents a Volume mount configuration for a Sandbox.
Attributes:
volume_id str - ID or name of the volume to mount.mount_path str - Path where the volume will be mounted in the sandbox.subpath str | None - Optional S3 subpath/prefix within the volume to mount.
When specified, only this prefix will be accessible. When omitted,
the entire volume is mounted.