apps/docs/src/content/docs/en/java-sdk/snapshot.mdx
Service for managing Daytona Snapshots.
Provides operations to create, list, retrieve, and delete snapshots.
public Snapshot create(String name, String imageName)
Creates a snapshot from an existing image reference.
Parameters:
name String - snapshot nameimageName String - source image name or tagReturns:
Snapshot - created SnapshotThrows:
io.daytona.sdk.exception.DaytonaException - if the API request failspublic Snapshot create(String name, Image image, Consumer<String> onLogs)
Creates a snapshot from a declarative Image with optional build log streaming.
Parameters:
name String - snapshot nameimage Image - declarative image definitiononLogs Consumer<String> - callback for build log lines; null to skip streamingReturns:
Snapshot - created Snapshot in active or error stateThrows:
DaytonaException - if the API request fails or the build failspublic 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:
name String - snapshot nameimage Image - declarative image definitionresources io.daytona.sdk.model.Resources - CPU/GPU/memory/disk resources; null for defaultsonLogs Consumer<String> - callback for build log lines; null to skip streamingReturns:
Snapshot - created Snapshot in active or error stateThrows:
DaytonaException - if the API request fails or the build failspublic PaginatedSnapshots list(Integer page, Integer limit)
Lists snapshots with pagination.
Parameters:
page Integer - page number starting from 1; defaults to 1 when nulllimit Integer - maximum number of items per page; defaults to 10 when nullReturns:
PaginatedSnapshots - paginated snapshot resultThrows:
io.daytona.sdk.exception.DaytonaException - if the API request failspublic Snapshot get(String nameOrId)
Retrieves a snapshot by name or ID.
Parameters:
nameOrId String - snapshot name or identifierReturns:
Snapshot - matching SnapshotThrows:
io.daytona.sdk.exception.DaytonaException - if no snapshot is found or request failspublic void delete(String id)
Deletes a snapshot by ID.
Parameters:
id String - snapshot identifierThrows:
io.daytona.sdk.exception.DaytonaException - if deletion fails