SnapshotService
Service for managing Synodes Snapshots. Can be used to list, get, create and delete Snapshots.
Constructors
new SnapshotService()
new SnapshotService(snapshotsApi: SnapshotsApi, objectStorageApi: ObjectStorageApi): SnapshotServiceParameters:
snapshotsApiSnapshotsApiobjectStorageApiObjectStorageApi
Returns:
SnapshotService
Methods
create()
create(params: CreateSnapshotParams, options: { onLogs: (chunk: string) => void; timeout: number;}): Promise<Snapshot>Creates and registers a new snapshot from the given Image definition.
Parameters:
paramsCreateSnapshotParams - Parameters for snapshot creation.optionsOptions for the create operation.onLogs?(chunk: string) => void - This callback function handles snapshot creation logs.timeout?number - Default is no timeout. Timeout in seconds (0 means no timeout).
Returns:
Promise<Snapshot>
Example:
const image = Image.debianSlim('3.12').pipInstall('numpy');await synodes.snapshot.create({ name: 'my-snapshot', image: image }, { onLogs: console.log });delete()
delete(snapshot: Snapshot): Promise<void>Deletes a Snapshot.
Parameters:
snapshotSnapshot - Snapshot to delete
Returns:
Promise<void>
Throws:
If the Snapshot does not exist or cannot be deleted
Example:
const synodes = new Synodes();const snapshot = await synodes.snapshot.get("snapshot-name");await synodes.snapshot.delete(snapshot);console.log("Snapshot deleted successfully");get()
get(name: string): Promise<Snapshot>Gets a Snapshot by its name.
Parameters:
namestring - Name of the Snapshot to retrieve
Returns:
Promise<Snapshot>- The requested Snapshot
Throws:
If the Snapshot does not exist or cannot be accessed
Example:
const synodes = new Synodes();const snapshot = await synodes.snapshot.get("snapshot-name");console.log(`Snapshot ${snapshot.name} is in state ${snapshot.state}`);list()
list(): Promise<Snapshot[]>List all Snapshots.
Returns:
Promise<Snapshot[]>- List of all Snapshots accessible to the user
Example:
const synodes = new Synodes();const snapshots = await synodes.snapshot.list();console.log(`Found ${snapshots.length} snapshots`);snapshots.forEach(snapshot => console.log(`${snapshot.name} (${snapshot.imageName})`));CreateSnapshotParams
type CreateSnapshotParams = { entrypoint: string[]; image: string | Image; name: string; resources: Resources;};Parameters for creating a new snapshot.
Type declaration:
entrypoint?string[]imagestring | Imagenamestringresources?Resources
Snapshot
type Snapshot = SnapshotDto & { __brand: "Snapshot";};Represents a Synodes Snapshot which is a pre-configured sandbox.
Type declaration:
\_\_brand“Snapshot”