export type StorageScanSchema = {files?: (Array | null) | undefined, ignore_already_active?: boolean | undefined, paths?: (Array | null) | undefined}; export type CreateApiV1StoragesStorageIdScanArgs = {'App-ID': string, 'Auth-Token': string, storage_id: string, body: StorageScanSchema}; export type CreateApiV1StoragesStorageIdScanOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Requests to scan a storage * * POST /v1/storages/{storage_id}/scan/ */ export const createApiV1StoragesStorageIdScan = async (args: CreateApiV1StoragesStorageIdScanArgs, options: CreateApiV1StoragesStorageIdScanOptions) => { 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/storages/${encodeURIComponent(String(args.storage_id))}/scan/${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 };