export type JobId = string; export type UpdateApiFotaJobsJobIdCancelArgs = {jobId: JobId, reason?: string | undefined}; export type UpdateApiFotaJobsJobIdCancelOptions = {baseUrl?: string | undefined, SimpleToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * CancelFOTAJob * * PUT /fota-jobs/{jobId}/cancel */ export const updateApiFotaJobsJobIdCancel = async (args: UpdateApiFotaJobsJobIdCancelArgs, options?: UpdateApiFotaJobsJobIdCancelOptions) => { const {baseUrl = "https://api.nrfcloud.com/v1", fetch: fetchFn = fetch, SimpleToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.reason != null) query.append("reason", String(args.reason)) if (SimpleToken !== undefined) headers.set('authorization', `Bearer ${SimpleToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/fota-jobs/${encodeURIComponent(String(args.jobId))}/cancel${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };