Snapshot
class Snapshot(SyncSnapshotDto)Represents a Daytona Snapshot which is a pre-configured sandbox.
Attributes:
idstr - Unique identifier for the Snapshot.organization_idstr | None - Organization ID of the Snapshot.generalbool - Whether the Snapshot is general.namestr - Name of the Snapshot.image_namestr - Name of the Image of the Snapshot.statestr - State of the Snapshot.sizefloat | int | None - Size of the Snapshot.entrypointlist[str] | None - Entrypoint of the Snapshot.cpufloat | int - CPU of the Snapshot.gpufloat | int - GPU of the Snapshot.memfloat | int - Memory of the Snapshot in GiB.diskfloat | int - Disk of the Snapshot in GiB.error_reasonstr | None - Error reason of the Snapshot.created_atstr - Timestamp when the Snapshot was created.updated_atstr - Timestamp when the Snapshot was last updated.last_used_atstr - Timestamp when the Snapshot was last used.
SnapshotService
class SnapshotService()Service for managing Daytona Snapshots. Can be used to list, get, create and delete Snapshots.
SnapshotService.list
@intercept_errors(message_prefix="Failed to list snapshots: ")@with_instrumentation()def list(page: int | None = None, limit: int | None = None) -> PaginatedSnapshotsReturns paginated list of Snapshots.
Arguments:
pageint | None - Page number for pagination (starting from 1).limitint | None - Maximum number of items per page.
Returns:
PaginatedSnapshots- Paginated list of Snapshots.
Example:
daytona = Daytona()result = daytona.snapshot.list(page=2, limit=10)for snapshot in result.items: print(f"{snapshot.name} ({snapshot.image_name})")SnapshotService.delete
@intercept_errors(message_prefix="Failed to delete snapshot: ")@with_instrumentation()def delete(snapshot: Snapshot) -> NoneDelete a Snapshot.
Arguments:
snapshotSnapshot - Snapshot to delete.
Example:
daytona = Daytona()snapshot = daytona.snapshot.get("test-snapshot")daytona.snapshot.delete(snapshot)print("Snapshot deleted")SnapshotService.get
@intercept_errors(message_prefix="Failed to get snapshot: ")@with_instrumentation()def get(name: str) -> SnapshotGet a Snapshot by name.
Arguments:
namestr - Name of the Snapshot to get.
Returns:
Snapshot- The Snapshot object.
Example:
daytona = Daytona()snapshot = daytona.snapshot.get("test-snapshot-name")print(f"{snapshot.name} ({snapshot.image_name})")SnapshotService.create
@intercept_errors(message_prefix="Failed to create snapshot: ")@with_timeout()@with_instrumentation()def create(params: CreateSnapshotParams, *, on_logs: Callable[[str], None] | None = None, timeout: float | None = 0) -> SnapshotCreates and registers a new snapshot from the given Image definition.
Arguments:
paramsCreateSnapshotParams - Parameters for snapshot creation.on_logsCallable[[str], None] - This callback function handles snapshot creation logs.timeoutfloat | None - Default is no timeout. Timeout in seconds (0 means no timeout).
Example:
image = Image.debianSlim('3.12').pipInstall('numpy')daytona.snapshot.create( CreateSnapshotParams(name='my-snapshot', image=image), on_logs=lambda chunk: print(chunk, end=""),)SnapshotService.activate
@with_instrumentation()def activate(snapshot: Snapshot) -> SnapshotActivate a snapshot.
Arguments:
snapshotSnapshot - The Snapshot instance.
Returns:
Snapshot- The activated Snapshot instance.
SnapshotService.process_image_context
@staticmethod@with_instrumentation()def process_image_context(object_storage_api: ObjectStorageApi, image: Image) -> list[str]Processes the image context by uploading it to object storage.
Arguments:
imageImage - The Image instance.
Returns:
list[str]- List of context hashes stored in object storage.
PaginatedSnapshots
class PaginatedSnapshots(PaginatedSnapshotsDto)Represents a paginated list of Daytona Snapshots.
Attributes:
itemslist[Snapshot] - List of Snapshot instances in the current page.totalint - Total number of Snapshots across all pages.pageint - Current page number.total_pagesint - Total number of pages available.
CreateSnapshotParams
class CreateSnapshotParams(BaseModel)Parameters for creating a new snapshot.
Attributes:
namestr - Name of the snapshot.imagestr | Image - Image of the snapshot. If a string is provided, it should be available on some registry. If an Image instance is provided, it will be used to create a new image in Daytona.resourcesResources | None - Resources of the snapshot.entrypointlist[str] | None - Entrypoint of the snapshot.region_idstr | None - ID of the region where the snapshot will be available. Defaults to organization default region if not specified.