export type GetApiToolsGenerateUidArgs = {level: string}; export type GetApiToolsGenerateUidOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate an identifier * * GET /tools/generate-uid */ export const getApiToolsGenerateUid = async (args: GetApiToolsGenerateUidArgs, options?: GetApiToolsGenerateUidOptions) => { const {baseUrl = "https://orthanc.uclouvain.be/demo", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.level != null) query.append("level", String(args.level)) const url = `${baseUrl.replace(/\/+$/, '')}/tools/generate-uid${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() };