Skip to content

Volume

class Volume(VolumeDto)

Represents a Daytona Volume which is a shared storage volume for Sandboxes.

Attributes:

  • id StrictStr - Unique identifier for the Volume.
  • name StrictStr - Name of the Volume.
  • organization_id StrictStr - Organization ID of the Volume.
  • state StrictStr - State of the Volume.
  • created_at StrictStr - Date and time when the Volume was created.
  • updated_at StrictStr - Date and time when the Volume was last updated.
  • last_used_at StrictStr - Date and time when the Volume was last used.

AsyncVolumeService

class AsyncVolumeService()

Service for managing Daytona Volumes. Can be used to list, get, create and delete Volumes.

AsyncVolumeService.list

async def list() -> List[Volume]

List all Volumes.

Returns:

  • List[Volume] - List of all Volumes.

Example:

async with AsyncDaytona() as daytona:
volumes = await daytona.volume.list()
for volume in volumes:
print(f"{volume.name} ({volume.id})")

AsyncVolumeService.get

async 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:

async with AsyncDaytona() as daytona:
volume = await daytona.volume.get("test-volume-name", create=True)
print(f"{volume.name} ({volume.id})")

AsyncVolumeService.create

async def create(name: str) -> Volume

Create a new Volume.

Arguments:

  • name str - Name of the Volume to create.

Returns:

  • Volume - The Volume object.

Example:

async with AsyncDaytona() as daytona:
volume = await daytona.volume.create("test-volume")
print(f"{volume.name} ({volume.id}); state: {volume.state}")

AsyncVolumeService.delete

async def delete(volume: Volume) -> None

Delete a Volume.

Arguments:

  • volume Volume - Volume to delete.

Example:

async with AsyncDaytona() as daytona:
volume = await daytona.volume.get("test-volume")
await daytona.volume.delete(volume)
print("Volume deleted")