export type CreateApiV2ItamUnmanagedDeviceNodeIdDecommissionArgs = {nodeId: number}; export type CreateApiV2ItamUnmanagedDeviceNodeIdDecommissionOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Decommission an Unmanaged Device * * POST /v2/itam/unmanaged-device/{nodeId}/decommission * * Also accepts auth: sessionKey */ export const createApiV2ItamUnmanagedDeviceNodeIdDecommission = async (args: CreateApiV2ItamUnmanagedDeviceNodeIdDecommissionArgs, options: CreateApiV2ItamUnmanagedDeviceNodeIdDecommissionOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/itam/unmanaged-device/${encodeURIComponent(String(args.nodeId))}/decommission${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };