export type GetApiV1ArtifactsIdDownloadArgs = {id: string}; export type GetApiV1ArtifactsIdDownloadOptions = {baseUrl?: string | undefined, bearerApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download artifact file * * GET /v1/artifacts/{id}/download */ export const getApiV1ArtifactsIdDownload = async (args: GetApiV1ArtifactsIdDownloadArgs, options?: GetApiV1ArtifactsIdDownloadOptions) => { const {baseUrl = "https://api.nops.io", fetch: fetchFn = fetch, bearerApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (bearerApiKey !== undefined) headers.set('authorization', `Bearer ${bearerApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/artifacts/${encodeURIComponent(String(args.id))}/download${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.text() };