export type GetApiApiV2KennelDownloadAssetNameOptions = {baseUrl: string, JWTBearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download asset * * GET /api/v2/kennel/download/{asset_name} * * Also accepts auth: SignedRequest + RequestDate + HMACSignature */ export const getApiApiV2KennelDownloadAssetName = async (options: GetApiApiV2KennelDownloadAssetNameOptions) => { const {baseUrl, fetch: fetchFn = fetch, JWTBearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (JWTBearerToken !== undefined) headers.set('authorization', `Bearer ${JWTBearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/kennel/download/${encodeURIComponent(String(args.asset_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() };