SnapshotService
Section titled “SnapshotService”Service for managing Daytona Snapshots.
Provides operations to create, list, retrieve, and delete snapshots.
Methods
Section titled “Methods”create()
Section titled “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()
Section titled “create()”public Snapshot create(String name, String imageName, SandboxClass sandboxClass)Creates a snapshot from an existing image reference with a target sandbox class.
Parameters:
nameString - snapshot nameimageNameString - source image name or tagsandboxClassSandboxClass - target sandbox class;nullfor default
Returns:
Snapshot- createdSnapshot
Throws:
io.daytona.sdk.exception.DaytonaException- if the API request fails
create()
Section titled “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()
Section titled “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
create()
Section titled “create()”public Snapshot create(String name, Image image, io.daytona.sdk.model.Resources resources, SandboxClass sandboxClass, Consumer<String> onLogs)Creates a snapshot from a declarative Image with resources, sandbox class, and optional build log streaming.
Parameters:
nameString - snapshot nameimageImage - declarative image definitionresourcesio.daytona.sdk.model.Resources - CPU/GPU/memory/disk resources;nullfor defaultssandboxClassSandboxClass - target sandbox class;nullfor defaultonLogsConsumer<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()
Section titled “list()”public PaginatedSnapshots list(Integer page, Integer limit)Lists snapshots with pagination.
try (Daytona daytona = new Daytona()) {PaginatedSnapshots page = daytona.snapshot().list(2, 10);System.out.printf("Page %d of %d (%d snapshots total)%n",page.getPage(), page.getTotalPages(), page.getTotal());for (var snapshot : page.getItems()) {System.out.println(snapshot.getName() + " (" + snapshot.getImageName() + ")");}}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
list()
Section titled “list()”public PaginatedSnapshots list(Integer page, Integer limit, String sourceSandboxId)Lists snapshots with pagination, optionally filtered by source sandbox.
Parameters:
pageInteger - page number starting from 1; defaults to 1 whennulllimitInteger - maximum number of items per page; defaults to 10 whennullsourceSandboxIdString - filter by the ID of the sandbox the snapshot was created from; ignored whennull
Returns:
PaginatedSnapshots- paginated snapshot result
Throws:
io.daytona.sdk.exception.DaytonaException- if the API request fails
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()
Section titled “delete()”public void delete(String nameOrId)Deletes a snapshot by ID or name.
Snapshot names may themselves be UUID-formatted, so a UUID-shaped input is first
tried directly against the ID-only delete endpoint (1 call) and only resolved through
the ID-or-name GET /snapshots lookup on a 404. Non-UUID input is resolved first (2 calls);
a UUID-formatted name costs 3 calls in the worst case.
Parameters:
nameOrIdString - snapshot identifier or name
Throws:
io.daytona.sdk.exception.DaytonaException- if deletion fails
delete()
Section titled “delete()”public void delete(Snapshot snapshot)Deletes a snapshot using its already-known identifier.
Issues a single delete call — no resolution is performed.
Parameters:
snapshotSnapshot - snapshot to delete; itsSnapshot#getId() idis used verbatim
Throws:
io.daytona.sdk.exception.DaytonaException- if deletion fails
activate()
Section titled “activate()”public Snapshot activate(String nameOrId)Activates a snapshot by ID or name.
Snapshot names may themselves be UUID-formatted, so a UUID-shaped input is first
tried directly against the ID-only activate endpoint (1 call) and only resolved through
the ID-or-name GET /snapshots lookup on a 404. Non-UUID input is resolved first (2 calls);
a UUID-formatted name costs 3 calls in the worst case.
Parameters:
nameOrIdString - snapshot identifier or name
Returns:
Snapshot- the activatedSnapshot
Throws:
io.daytona.sdk.exception.DaytonaException- if activation fails or no snapshot is found
activate()
Section titled “activate()”public Snapshot activate(Snapshot snapshot)Activates a snapshot using its already-known identifier.
Issues a single activate call — no resolution is performed.
Parameters:
snapshotSnapshot - snapshot to activate; itsSnapshot#getId() idis used verbatim
Returns:
Snapshot- the activatedSnapshot
Throws:
io.daytona.sdk.exception.DaytonaException- if activation fails