export type CreateApiMinionsRescanArgs = {scanNetwork?: boolean | undefined}; export type CreateApiMinionsRescanOptions = {baseUrl: string, userAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Recheck every minion device status (update server status cache). * * POST /minions/rescan * * Also accepts auth: adminAuth */ export const createApiMinionsRescan = async (args: CreateApiMinionsRescanArgs, options: CreateApiMinionsRescanOptions) => { const {baseUrl, fetch: fetchFn = fetch, userAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.scanNetwork != null) query.append("scanNetwork", String(args.scanNetwork)) if (userAuth !== undefined) headers.set("authentication", userAuth) const url = `${baseUrl.replace(/\/+$/, '')}/minions/rescan${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };