@vercel/sdk
Version:
<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>
130 lines (121 loc) • 3.51 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
/**
* The status of the snapshot.
*/
export const SnapshotStatus = {
Created: "created",
Deleted: "deleted",
Failed: "failed",
} as const;
/**
* The status of the snapshot.
*/
export type SnapshotStatus = ClosedEnum<typeof SnapshotStatus>;
/**
* The method used to create the snapshot.
*/
export const CreationMethod = {
Automatic: "automatic",
Manual: "manual",
} as const;
/**
* The method used to create the snapshot.
*/
export type CreationMethod = ClosedEnum<typeof CreationMethod>;
/**
* This object contains information related to a Snapshot of a Vercel Sandbox session (v2 API).
*/
export type Snapshot = {
/**
* The unique identifier of the snapshot.
*/
id: string;
/**
* The unique identifier of the session from which the snapshot was created.
*/
sourceSessionId: string;
/**
* The region where the snapshot is stored.
*/
region?: string | undefined;
/**
* The regions where the snapshot is available.
*/
regions?: Array<string> | undefined;
/**
* The status of the snapshot.
*/
status: SnapshotStatus;
/**
* The size of the snapshot in bytes.
*/
sizeBytes: number;
/**
* The time when the snapshot will expire, in milliseconds since the epoch. If not set, the snapshot does not have any expiration.
*/
expiresAt?: number | undefined;
/**
* The time when the snapshot was created, in milliseconds since the epoch.
*/
createdAt: number;
/**
* The last time the snapshot was updated, in milliseconds since the epoch.
*/
updatedAt: number;
/**
* The last time the snapshot was used (e.g. to resume or create a sandbox), in milliseconds since the epoch. Falls back to `createdAt` for older snapshots that predate this field.
*/
lastUsedAt: number;
/**
* The method used to create the snapshot.
*/
creationMethod?: CreationMethod | undefined;
/**
* The unique identifier of the parent snapshot, if this snapshot was created from another snapshot.
*/
parentId?: string | undefined;
};
/** @internal */
export const SnapshotStatus$inboundSchema: z.ZodNativeEnum<
typeof SnapshotStatus
> = z.nativeEnum(SnapshotStatus);
/** @internal */
export const CreationMethod$inboundSchema: z.ZodNativeEnum<
typeof CreationMethod
> = z.nativeEnum(CreationMethod);
/** @internal */
export const Snapshot$inboundSchema: z.ZodType<
Snapshot,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
sourceSessionId: types.string(),
region: types.optional(types.string()),
regions: types.optional(z.array(types.string())),
status: SnapshotStatus$inboundSchema,
sizeBytes: types.number(),
expiresAt: types.optional(types.number()),
createdAt: types.number(),
updatedAt: types.number(),
lastUsedAt: types.number(),
creationMethod: types.optional(CreationMethod$inboundSchema),
parentId: types.optional(types.string()),
});
export function snapshotFromJSON(
jsonString: string,
): SafeParseResult<Snapshot, SDKValidationError> {
return safeParse(
jsonString,
(x) => Snapshot$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Snapshot' from JSON`,
);
}