## SnapshotService

Service for managing Daytona Snapshots. Can be used to list, get, create and delete Snapshots.

### Constructors

#### new SnapshotService()

```ts
new SnapshotService(
   clientConfig: Configuration, 
   snapshotsApi: SnapshotsApi, 
   objectStorageApi: ObjectStorageApi, 
   defaultRegionId?: string): SnapshotService
```

**Parameters**:

- `clientConfig` _Configuration_
- `snapshotsApi` _SnapshotsApi_
- `objectStorageApi` _ObjectStorageApi_
- `defaultRegionId?` _string_

**Returns**:

- `SnapshotService`

### Methods

#### activate()

```ts
activate(snapshot: Snapshot): Promise<Snapshot>
```

Activates a snapshot.

**Parameters**:

- `snapshot` _Snapshot_ - Snapshot to activate

**Returns**:

- `Promise<Snapshot>` - The activated Snapshot instance

***

#### create()

```ts
create(params: CreateSnapshotParams, options: {
  onLogs: (chunk: string) => void;
  timeout: number;
}): Promise<Snapshot>
```

Creates and registers a new snapshot from the given Image definition.

**Parameters**:

- `params` _CreateSnapshotParams_ - Parameters for snapshot creation.
- `options` _Options 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:**

```ts
const image = Image.debianSlim('3.12').pipInstall('numpy');
await daytona.snapshot.create({ name: 'my-snapshot', image: image }, { onLogs: console.log });
```

***

#### delete()

```ts
delete(snapshot: Snapshot): Promise<void>
```

Deletes a Snapshot.

**Parameters**:

- `snapshot` _Snapshot_ - Snapshot to delete

**Returns**:

- `Promise<void>`

**Throws**:

If the Snapshot does not exist or cannot be deleted

**Example:**

```ts
const daytona = new Daytona();
const snapshot = await daytona.snapshot.get("snapshot-name");
await daytona.snapshot.delete(snapshot);
console.log("Snapshot deleted successfully");
```

***

#### get()

```ts
get(name: string): Promise<Snapshot>
```

Gets a Snapshot by its name.

**Parameters**:

- `name` _string_ - Name of the Snapshot to retrieve

**Returns**:

- `Promise<Snapshot>` - The requested Snapshot

**Throws**:

If the Snapshot does not exist or cannot be accessed

**Example:**

```ts
const daytona = new Daytona();
const snapshot = await daytona.snapshot.get("snapshot-name");
console.log(`Snapshot ${snapshot.name} is in state ${snapshot.state}`);
```

***

#### list()

```ts
list(page?: number, limit?: number): Promise<PaginatedSnapshots>
```

List paginated list of Snapshots.

**Parameters**:

- `page?` _number_ - Page number for pagination (starting from 1)
- `limit?` _number_ - Maximum number of items per page

**Returns**:

- `Promise<PaginatedSnapshots>` - Paginated list of Snapshots

**Example:**

```ts
const daytona = new Daytona();
const result = await daytona.snapshot.list(2, 10);
console.log(`Found ${result.total} snapshots`);
result.items.forEach(snapshot => console.log(`${snapshot.name} (${snapshot.imageName})`));
```

***

## PaginatedSnapshots

Represents a paginated list of Daytona Snapshots.

**Properties**:

- `items` _Snapshot\[\]_ - List of Snapshot instances in the current page.
- `page` _number_ - Current page number.
    - _Inherited from_: `Omit.page`
- `total` _number_ - Total number of Snapshots across all pages.
    - _Inherited from_: `Omit.total`
- `totalPages` _number_ - Total number of pages available.
    
    - _Inherited from_: `Omit.totalPages`

**Extends:**

- `Omit`\<`PaginatedSnapshotsDto`, `"items"`\>
## CreateSnapshotParams

```ts
type CreateSnapshotParams = {
  entrypoint: string[];
  image: string | Image;
  name: string;
  regionId: string;
  resources: Resources;
};
```

Parameters for creating a new snapshot.

**Type declaration**:

- `entrypoint?` _string\[\]_
- `image` _string \| Image_
- `name` _string_
- `regionId?` _string_
- `resources?` _Resources_

## Snapshot

```ts
type Snapshot = SnapshotDto & {
  __brand: "Snapshot";
};
```

Represents a Daytona Snapshot which is a pre-configured sandbox.

**Type declaration**:

- `\_\_brand` _"Snapshot"_

