export type DeviceId = string; export type JobId = string; export type FotaV2JobExecutionEvents = 'QUEUED' | 'IN_PROGRESS' | 'FAILED' | 'SUCCEEDED' | 'TIMED_OUT' | 'CANCELLED' | 'REJECTED' | 'DOWNLOADING'; export type PatchApiFotaJobExecutionsDeviceIdJobIdArgs = {deviceId: DeviceId, jobId: JobId, body: {details?: string | undefined, status: FotaV2JobExecutionEvents}}; export type PatchApiFotaJobExecutionsDeviceIdJobIdOptions = {baseUrl?: string | undefined, SimpleToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * UpdateFOTAJobExecutionStatus * * PATCH /fota-job-executions/{deviceId}/{jobId} * * Also accepts auth: JSON Web Token */ export const patchApiFotaJobExecutionsDeviceIdJobId = async (args: PatchApiFotaJobExecutionsDeviceIdJobIdArgs, options?: PatchApiFotaJobExecutionsDeviceIdJobIdOptions) => { const {baseUrl = "https://api.nrfcloud.com/v1", fetch: fetchFn = fetch, SimpleToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (SimpleToken !== undefined) headers.set('authorization', `Bearer ${SimpleToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/fota-job-executions/${encodeURIComponent(String(args.deviceId))}/${encodeURIComponent(String(args.jobId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };