SnapshotService
Service for managing Daytona Snapshots.
Provides operations to create, list, retrieve, and delete snapshots.
Methods
create()
public Snapshot create(String name, String imageName)Creates a snapshot from an existing image reference.
Parameters:
nameString - snapshot nameimageNameString - source image name or tag
Returns:
Snapshot- createdSnapshot
Throws:
io.daytona.sdk.exception.DaytonaException- if the API request fails
create()
public Snapshot create(String name, Image image, Consumer<String> onLogs)Creates a snapshot from a declarative Image with optional build log streaming.
Parameters:
nameString - snapshot nameimageImage - declarative image definitiononLogsConsumer<String> - callback for build log lines;nullto skip streaming
Returns:
Snapshot- createdSnapshotin active or error state
Throws:
DaytonaException- if the API request fails or the build fails
create()
public Snapshot create(String name, Image image, io.daytona.sdk.model.Resources resources, Consumer<String> onLogs)Creates a snapshot from a declarative Image with resources and optional build log streaming.
Parameters:
nameString - snapshot nameimageImage - declarative image definitionresourcesio.daytona.sdk.model.Resources - CPU/GPU/memory/disk resources;nullfor defaultsonLogsConsumer<String> - callback for build log lines;nullto skip streaming
Returns:
Snapshot- createdSnapshotin active or error state
Throws:
DaytonaException- if the API request fails or the build fails
list()
public PaginatedSnapshots list(Integer page, Integer limit)Lists snapshots with pagination.
Parameters:
pageInteger - page number starting from 1; defaults to 1 whennulllimitInteger - maximum number of items per page; defaults to 10 whennull
Returns:
PaginatedSnapshots- paginated snapshot result
Throws:
io.daytona.sdk.exception.DaytonaException- if the API request fails
get()
public Snapshot get(String nameOrId)Retrieves a snapshot by name or ID.
Parameters:
nameOrIdString - snapshot name or identifier
Returns:
Snapshot- matchingSnapshot
Throws:
io.daytona.sdk.exception.DaytonaException- if no snapshot is found or request fails
delete()
public void delete(String id)Deletes a snapshot by ID.
Parameters:
idString - snapshot identifier
Throws:
io.daytona.sdk.exception.DaytonaException- if deletion fails