export type DeleteApiV2DeviceIdMaintenanceArgs = {id: number}; export type DeleteApiV2DeviceIdMaintenanceOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cancel maintenance * * DELETE /v2/device/{id}/maintenance * * Also accepts auth: sessionKey */ export const deleteApiV2DeviceIdMaintenance = async (args: DeleteApiV2DeviceIdMaintenanceArgs, options: DeleteApiV2DeviceIdMaintenanceOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/device/${encodeURIComponent(String(args.id))}/maintenance${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };