export type GetApiApiV0DeskModelingExamplesNameArgs = {name: string}; export type GetApiApiV0DeskModelingExamplesNameOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * One single-file example model's source * * GET /api/v0/desk/modeling/examples/{name} */ export const getApiApiV0DeskModelingExamplesName = async (args: GetApiApiV0DeskModelingExamplesNameArgs, options: GetApiApiV0DeskModelingExamplesNameOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v0/desk/modeling/examples/${encodeURIComponent(String(args.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.text() };