SnapshotService
SnapshotService class for Daytona SDK.
Constructors
new SnapshotService()
def initialize(snapshots_api:, object_storage_api:, default_region_id: nil, otel_state: nil)
Parameters:
snapshots_apiDaytonaApiClient:SnapshotsApi - The snapshots API clientobject_storage_apiDaytonaApiClient:ObjectStorageApi - The object storage API clientdefault_region_idString, nil - Default region ID for snapshot creationotel_stateDaytona:OtelState, nil -
Returns:
SnapshotService- a new instance of SnapshotService
Methods
list()
def list(page: nil, limit: nil, source_sandbox_id: nil)
List all Snapshots.
Parameters:
pageInteger, Nil -limitInteger, Nil -source_sandbox_idString, Nil - Filter by the ID of the sandbox the snapshot was created from
Returns:
Daytona:PaginatedResource- Paginated list of all Snapshots
Raises:
Daytona:Sdk:Error-
Examples:
daytona = Daytona::Daytona.new
page = daytona.snapshot.list(page: 2, limit: 10)
puts "Page #{page.page} of #{page.total_pages} (#{page.total} snapshots total)"
page.items.each { |snapshot| puts "#{snapshot.name} (#{snapshot.image_name})" }
delete()
def delete(snapshot)
Delete a Snapshot.
Parameters:
snapshotDaytona:Snapshot, String - Snapshot to delete, or its ID or name. Call cost: 1 API call for a Snapshot object or UUID string; 2 for a name (resolve, then delete); up to 3 in the worst case for a UUID-formatted name (the optimistic delete 404s, then resolve + delete).
Returns:
void
Examples:
daytona = Daytona::Daytona.new
snapshot = daytona.snapshot.get("demo")
daytona.snapshot.delete(snapshot)
puts "Snapshot deleted"
get()
def get(name)
Get a Snapshot by ID or name.
Parameters:
nameString - ID or name of the Snapshot to get
Returns:
Daytona:Snapshot- The Snapshot object
Examples:
daytona = Daytona::Daytona.new
snapshot = daytona.snapshot.get("demo")
puts "#{snapshot.name} (#{snapshot.image_name})"
create()
def create(params, on_logs: nil)
Creates and registers a new snapshot from the given Image definition.
Parameters:
paramsDaytona:CreateSnapshotParams - Parameters for snapshot creationon_logsProc, Nil - Callback proc handling snapshot creation logs
Returns:
Daytona:Snapshot- The created snapshot
Examples:
image = Image.debianSlim('3.12').pipInstall('numpy')
params = CreateSnapshotParams.new(name: 'my-snapshot', image: image)
snapshot = daytona.snapshot.create(params) do |chunk|
print chunk
end
activate()
def activate(snapshot)
Activate a snapshot.
Parameters:
snapshotDaytona:Snapshot, String - The Snapshot instance, or its ID or name. Call cost matchesdelete: 1 for an object or UUID string, 2 for a name, up to 3 for a UUID-formatted name (optimistic 404 then resolve + activate).
Returns:
Daytona:Snapshot