AsyncSnapshot | Daytona

Snapshot

class Snapshot(SyncSnapshotDto)

Represents a Daytona Snapshot which is a pre-configured sandbox.

Attributes:

AsyncSnapshotService

class AsyncSnapshotService()

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

AsyncSnapshotService.list

@intercept_errors(message_prefix="Failed to list snapshots: ")
@with_instrumentation()
async def list(page: int | None = None,
               limit: int | None = None,
               source_sandbox_id: str | None = None) -> PaginatedSnapshots

Returns paginated list of Snapshots.

Arguments:

Returns:

Example:

async with AsyncDaytona() as daytona:
    page = await daytona.snapshot.list(page=2, limit=10)
    print(f"Page {page.page} of {page.total_pages} ({page.total} snapshots total)")
    for snapshot in page.items:
        print(f"{snapshot.name} ({snapshot.image_name})")

AsyncSnapshotService.delete

@intercept_errors(message_prefix="Failed to delete snapshot: ")
@with_instrumentation()
async def delete(snapshot: Snapshot | str) -> None

Delete a Snapshot.

Arguments:

Example:

async with AsyncDaytona() as daytona:
    await daytona.snapshot.delete("test-snapshot")
    print("Snapshot deleted")

AsyncSnapshotService.get

@intercept_errors(message_prefix="Failed to get snapshot: ")
@with_instrumentation()
async def get(name: str) -> Snapshot

Get a Snapshot by ID or name.

Arguments:

Returns:

Example:

async with AsyncDaytona() as daytona:
    snapshot = await daytona.snapshot.get("test-snapshot-name")
    print(f"{snapshot.name} ({snapshot.image_name})")

AsyncSnapshotService.create

@intercept_errors(message_prefix="Failed to create snapshot: ")
@with_timeout()
@with_instrumentation()
async def create(params: CreateSnapshotParams,
                 *,
                 on_logs: Callable[[str], None] | None = None,
                 timeout: float | None = 0) -> Snapshot

Creates and registers a new snapshot from the given Image definition.

Arguments:

Example:

image = Image.debianSlim('3.12').pipInstall('numpy')
daytona.snapshot.create(
    CreateSnapshotParams(name='my-snapshot', image=image),
    on_logs=lambda chunk: print(chunk, end=""),
)

AsyncSnapshotService.activate

@with_instrumentation()
async def activate(snapshot: Snapshot | str) -> Snapshot

Activate a snapshot.

Arguments:

Returns:

AsyncSnapshotService.process_image_context

@staticmethod
@with_instrumentation()
async def process_image_context(object_storage_api: ObjectStorageApi,
                                image: Image) -> list[str]

Processes the image context by uploading it to object storage.

Arguments:

Returns:

PaginatedSnapshots

class PaginatedSnapshots(PaginatedSnapshotsDto)

Represents a paginated list of Daytona Snapshots.

Attributes:

CreateSnapshotParams

class CreateSnapshotParams(BaseModel)

Parameters for creating a new snapshot.

Attributes: