export type ReindexProjectSchema = {sync_to_another_dc?: boolean | undefined}; export type CreateApiV1ProjectsProjectIdReindexArgs = {'App-ID': string, 'Auth-Token': string, project_id: string, index_immediately?: boolean | undefined, body: ReindexProjectSchema}; export type CreateApiV1ProjectsProjectIdReindexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Reindex the project * * POST /v1/projects/{project_id}/reindex/ */ export const createApiV1ProjectsProjectIdReindex = async (args: CreateApiV1ProjectsProjectIdReindexArgs, options: CreateApiV1ProjectsProjectIdReindexOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args.index_immediately != null) query.append("index_immediately", String(args.index_immediately)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/projects/${encodeURIComponent(String(args.project_id))}/reindex/${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 undefined };