export type ReindexFileSchema = {sync_to_another_dc?: boolean | undefined}; export type CreateApiV1AssetsAssetIdFilesFileIdReindexArgs = {'App-ID': string, 'Auth-Token': string, asset_id: string, file_id: string, body: ReindexFileSchema}; export type CreateApiV1AssetsAssetIdFilesFileIdReindexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Trigger reindexing of a file * * POST /v1/assets/{asset_id}/files/{file_id}/reindex/ */ export const createApiV1AssetsAssetIdFilesFileIdReindex = async (args: CreateApiV1AssetsAssetIdFilesFileIdReindexArgs, options: CreateApiV1AssetsAssetIdFilesFileIdReindexOptions) => { 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/${encodeURIComponent(String(args.asset_id))}/files/${encodeURIComponent(String(args.file_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 };