export type CreateApiApiV1ApikeyArgs = {apikey: string, body: {indices_max: number, indices_size_max: number, documents_max: number, operations_max: number, rate_limit?: (number | null) | undefined, demo?: boolean | undefined}}; export type CreateApiApiV1ApikeyOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create API Key * * POST /api/v1/apikey */ export const createApiApiV1Apikey = async (args: CreateApiApiV1ApikeyArgs, options?: CreateApiApiV1ApikeyOptions) => { const {baseUrl = "http://127.0.0.1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/plain") if (args.apikey != null) headers.set("apikey", String(args.apikey)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/apikey${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };