export type ReindexAssetSchema = {realms?: (Array | null) | undefined, sync_to_another_dc?: boolean | undefined}; export type CreateApiV1AssetsAssetIdReindexArgs = {'App-ID': string, 'Auth-Token': string, asset_id: string, old_parent_id?: string | undefined, new_parent_id?: string | undefined, low_priority_indexing?: boolean | undefined, dc_sync?: boolean | undefined, body: ReindexAssetSchema}; export type CreateApiV1AssetsAssetIdReindexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Reindex asset * * POST /v1/assets/{asset_id}/reindex/ */ export const createApiV1AssetsAssetIdReindex = async (args: CreateApiV1AssetsAssetIdReindexArgs, options: CreateApiV1AssetsAssetIdReindexOptions) => { 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.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)) 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)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/assets/${encodeURIComponent(String(args.asset_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 };