Sign Up

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_api DaytonaApiClient:SnapshotsApi - The snapshots API client
  • object_storage_api DaytonaApiClient:ObjectStorageApi - The object storage API client
  • default_region_id String, nil - Default region ID for snapshot creation
  • otel_state Daytona: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:

  • page Integer, Nil -
  • limit Integer, Nil -
  • source_sandbox_id String, 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:

  • snapshot Daytona: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:

  • name String - 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:

  • params Daytona:CreateSnapshotParams - Parameters for snapshot creation
  • on_logs Proc, 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:

  • snapshot Daytona:Snapshot, String - The Snapshot instance, or its ID or name. Call cost matches delete: 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