Skip to content
← Public packages

@cameronpak/box

Full Box Public API v1 client: lifecycle, prompts, files, commands, snapshots, environments, webhooks, desktop, hosting, and account.

src/get-named-snapshot.ts

22 lines · 698 B · TypeScript
import { boxRequest, failure, type Result } from './client.ts'
import type { NamedSnapshot } from './types.ts'

export type GetNamedSnapshotInput = { name: string }

export type GetNamedSnapshotOutput = { snapshot: NamedSnapshot }

/** Get one named snapshot by name. Poll this after saveNamedSnapshot. */
export default async function getNamedSnapshot(
	input: GetNamedSnapshotInput,
): Promise<Result<GetNamedSnapshotOutput>> {
	if (!input?.name) {
		return failure<GetNamedSnapshotOutput>({
			code: 'invalid_snapshot_name',
			message: 'name is required.',
			status: 400,
		})
	}
	return boxRequest<GetNamedSnapshotOutput>({
		path: '/named-snapshots/' + encodeURIComponent(input.name),
	})
}