export type StorageBackendAlertSync = {begin_time?: number | undefined, end_time?: number | undefined}; export type CreateApiV1StoragesStorageIdAlertsSyncArgs = {storage_id: string, body: StorageBackendAlertSync}; export type CreateApiV1StoragesStorageIdAlertsSyncOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Sync alerts from storage device * * POST /v1/storages/{storage_id}/alerts/sync */ export const createApiV1StoragesStorageIdAlertsSync = async (args: CreateApiV1StoragesStorageIdAlertsSyncArgs, options: CreateApiV1StoragesStorageIdAlertsSyncOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/storages/${encodeURIComponent(String(args.storage_id))}/alerts/sync${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 };