export type GetApiWikiRestApiContentIdChildAttachmentAttachmentIdDownloadArgs = {id: string, attachmentId: string, version?: number | undefined, status?: Array | undefined}; export type GetApiWikiRestApiContentIdChildAttachmentAttachmentIdDownloadOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get URI to download attachment * * GET /wiki/rest/api/content/{id}/child/attachment/{attachmentId}/download * * Also accepts auth: oAuthDefinitions */ export const getApiWikiRestApiContentIdChildAttachmentAttachmentIdDownload = async (args: GetApiWikiRestApiContentIdChildAttachmentAttachmentIdDownloadArgs, options: GetApiWikiRestApiContentIdChildAttachmentAttachmentIdDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.version != null) query.append("version", String(args.version)) for (const item of args.status ?? []) query.append("status", String(item)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/wiki/rest/api/content/${encodeURIComponent(String(args.id))}/child/attachment/${encodeURIComponent(String(args.attachmentId))}/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 undefined };