-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsnapshot.ts
More file actions
48 lines (43 loc) · 1.71 KB
/
Copy pathsnapshot.ts
File metadata and controls
48 lines (43 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { z } from "zod";
import { networkPolicySchema, sandboxStateSchema } from "@/models/sandbox.js";
const snapshotNameSchema = z.string().trim().min(1).max(64);
export const snapshotDataSchema = z
.object({
id: z.string(),
name: z.string(),
templateId: z.string(),
vcpu: z.number(),
memory: z.number(),
disk: z.number(),
state: sandboxStateSchema.nullish(),
networkPolicy: networkPolicySchema.optional(),
createdAt: z.string(),
})
.catchall(z.unknown());
/** Snapshot resource returned by the control plane API. */
export type SnapshotData = z.infer<typeof snapshotDataSchema>;
export const listSnapshotsParamsSchema = z.object({
query: z.string().max(64).optional(),
sort: z.enum(["created_at", "template_id"]).optional(),
orderBy: z.enum(["asc", "desc"]).optional(),
page: z.number().int().min(1).optional(),
pageSize: z.number().int().min(1).max(100).optional(),
});
/** Parameters accepted when listing snapshots. */
export type ListSnapshotsParams = z.infer<typeof listSnapshotsParamsSchema>;
export const listSnapshotsResponseSchema = z
.object({
items: z.array(snapshotDataSchema),
totalItems: z.number().int().nonnegative(),
})
.catchall(z.unknown());
/** Paginated snapshot list response. */
export type ListSnapshotsResponse = z.infer<typeof listSnapshotsResponseSchema>;
export const restoreSnapshotParamsSchema = z.object({
snapshotName: snapshotNameSchema,
autoPause: z.boolean().optional(),
timeout: z.number().int().min(1).max(28800).optional(),
networkPolicy: networkPolicySchema.optional(),
});
/** Parameters accepted when restoring a snapshot into a new sandbox. */
export type RestoreSnapshotParams = z.infer<typeof restoreSnapshotParamsSchema>;