export type UpdateApiApiV1EsindexIndexNameArgs = {indexName: string, action?: string | undefined}; export type UpdateApiApiV1EsindexIndexNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PUT /api/v1/esindex/{indexName} */ export const updateApiApiV1EsindexIndexName = async (args: UpdateApiApiV1EsindexIndexNameArgs, options: UpdateApiApiV1EsindexIndexNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.action != null) query.append("action", String(args.action)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/esindex/${encodeURIComponent(String(args.indexName))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };