VolumeService
Service for managing Daytona Volumes.
This service provides methods to list, get, create, and delete Volumes.
Volumes can be mounted to Sandboxes with an optional subpath parameter to mount only a specific S3 prefix within the volume. When no subpath is specified, the entire volume is mounted.
Constructors
new VolumeService()
new VolumeService(volumesApi: VolumesApi): VolumeServiceParameters:
volumesApiVolumesApi
Returns:
VolumeService
Methods
create()
create(name: string): Promise<Volume>Creates a new Volume with the specified name.
Parameters:
namestring - Name for the new Volume
Returns:
Promise<Volume>- The newly created Volume
Throws:
If the Volume cannot be created
Example:
const daytona = new Daytona();const volume = await daytona.volume.create("my-data-volume");console.log(`Created volume ${volume.name} with ID ${volume.id}`);delete()
delete(volume: Volume): Promise<void>Deletes a Volume.
Parameters:
volumeVolume - Volume to delete
Returns:
Promise<void>
Throws:
If the Volume does not exist or cannot be deleted
Example:
const daytona = new Daytona();const volume = await daytona.volume.get("volume-name");await daytona.volume.delete(volume);console.log("Volume deleted successfully");get()
get(name: string, create: boolean): Promise<Volume>Gets a Volume by its name.
Parameters:
namestring - Name of the Volume to retrievecreateboolean = false - Whether to create the Volume if it does not exist
Returns:
Promise<Volume>- The requested Volume
Throws:
If the Volume does not exist or cannot be accessed
Example:
const daytona = new Daytona();const volume = await daytona.volume.get("volume-name", true);console.log(`Volume ${volume.name} is in state ${volume.state}`);list()
list(): Promise<Volume[]>Lists all available Volumes.
Returns:
Promise<Volume[]>- List of all Volumes accessible to the user
Example:
const daytona = new Daytona();const volumes = await daytona.volume.list();console.log(`Found ${volumes.length} volumes`);volumes.forEach(vol => console.log(`${vol.name} (${vol.id})`));Volume
type Volume = VolumeDto & { __brand: "Volume";};Represents a Daytona Volume which is a shared storage volume for Sandboxes.
Type declaration:
\_\_brand“Volume”