export type ReindexCollectionSchema = {realms?: (Array | null) | undefined, sync_to_another_dc?: boolean | undefined}; export type CreateApiV1CollectionsCollectionIdReindexArgs = {'App-ID': string, 'Auth-Token': string, collection_id: string, low_priority_indexing?: boolean | undefined, dc_sync?: boolean | undefined, old_parent_id?: string | undefined, new_parent_id?: string | undefined, body: ReindexCollectionSchema}; export type CreateApiV1CollectionsCollectionIdReindexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Reindex collection * * POST /v1/collections/{collection_id}/reindex/ */ export const createApiV1CollectionsCollectionIdReindex = async (args: CreateApiV1CollectionsCollectionIdReindexArgs, options: CreateApiV1CollectionsCollectionIdReindexOptions) => { 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.low_priority_indexing != null) query.append("low_priority_indexing", String(args.low_priority_indexing)) if (args.dc_sync != null) query.append("dc_sync", String(args.dc_sync)) if (args.old_parent_id != null) query.append("old_parent_id", String(args.old_parent_id)) if (args.new_parent_id != null) query.append("new_parent_id", String(args.new_parent_id)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/collections/${encodeURIComponent(String(args.collection_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 };