export type GetApiAuthoringV1ResourcesIdArgs = {id: string, mode?: 'download' | undefined, 'bypass-cache'?: string | undefined}; export type GetApiAuthoringV1ResourcesIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Retrieve an existing resource. * * GET /authoring/v1/resources/{id} */ export const getApiAuthoringV1ResourcesId = async (args: GetApiAuthoringV1ResourcesIdArgs, options: GetApiAuthoringV1ResourcesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.mode != null) query.append("mode", String(args.mode)) if (args['bypass-cache'] != null) query.append("bypass-cache", String(args['bypass-cache'])) const url = `${baseUrl.replace(/\/+$/, '')}/authoring/v1/resources/${encodeURIComponent(String(args.id))}${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() };