export type ReindexAllSegmentsSchema = {asset_ids: Array | null, ignore_comments?: boolean | undefined, realms?: (Array | null) | undefined, sync_to_another_dc?: boolean | undefined}; export type CreateApiV1AssetsSegmentsReindexArgs = {'App-ID': string, 'Auth-Token': string, body: ReindexAllSegmentsSchema}; export type CreateApiV1AssetsSegmentsReindexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Trigger reindexing of all segments * * POST /v1/assets/segments/reindex/ */ export const createApiV1AssetsSegmentsReindex = async (args: CreateApiV1AssetsSegmentsReindexArgs, options: CreateApiV1AssetsSegmentsReindexOptions) => { 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'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/assets/segments/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 };