export type CreateApiV2BackupBandwidthThrottleArgs = {body: {deviceId?: number | undefined, bandwidthThrottle?: ({enabled?: boolean | undefined, workHoursKbps?: number | undefined, nonWorkHoursKbps?: number | undefined, workHoursUserUnit?: string | undefined, nonWorkHoursUserUnit?: string | undefined, workSchedule?: ({endHour?: number | undefined, endMinute?: number | undefined, startHour?: number | undefined, startMinute?: number | undefined, weekDays?: Array | undefined}) | undefined}) | undefined}}; export type CreateApiV2BackupBandwidthThrottleOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sets the bandwidth throttle for a device * * POST /v2/backup/bandwidth-throttle * * Also accepts auth: sessionKey */ export const createApiV2BackupBandwidthThrottle = async (args: CreateApiV2BackupBandwidthThrottleArgs, options: CreateApiV2BackupBandwidthThrottleOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/backup/bandwidth-throttle${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 };