export type GetApiSnapshotsSnapshotNameArgs = {snapshot_name: string}; export type GetApiSnapshotsSnapshotNameOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download storage snapshot * * GET /snapshots/{snapshot_name} * * Also accepts auth: bearerAuth */ export const getApiSnapshotsSnapshotName = async (args: GetApiSnapshotsSnapshotNameArgs, options?: GetApiSnapshotsSnapshotNameOptions) => { const {baseUrl = "http://localhost:6333", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (apiKey !== undefined) headers.set("api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/snapshots/${encodeURIComponent(String(args.snapshot_name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };