export type GetApiApiProjectsIdArchiveArgs = {id: number, revision: string, direct_download?: boolean | undefined}; export type GetApiApiProjectsIdArchiveOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a project archive file * * GET /api/projects/{id}/archive */ export const getApiApiProjectsIdArchive = async (args: GetApiApiProjectsIdArchiveArgs, options?: GetApiApiProjectsIdArchiveOptions) => { const {baseUrl = "https://api-workflow.treasuredata.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.revision != null) query.append("revision", String(args.revision)) if (args.direct_download != null) query.append("direct_download", String(args.direct_download)) if (ApiKeyAuth !== undefined) headers.set('authorization', `TD1 ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/projects/${encodeURIComponent(String(args.id))}/archive${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 undefined };