export type GetApiAllocationsHostnameArgs = {hostname?: string | undefined, format?: ('json' | 'slurmcfg') | undefined}; export type GetApiAllocationsHostnameOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Display a listing of allocations. * * GET /allocations/{hostname?} */ export const getApiAllocationsHostname = async (args: GetApiAllocationsHostnameArgs, options?: GetApiAllocationsHostnameOptions) => { const {baseUrl = "https://www.rcac.purdue.edu/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.format != null) query.append("format", String(args.format)) const url = `${baseUrl.replace(/\/+$/, '')}/allocations/${encodeURIComponent(String(args['hostname?']))}${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 };