export type MinionSetDevice = {mac: string}; export type UpdateApiMinionsNetworkDeviceMinionIdArgs = {minionId: string, body: MinionSetDevice}; export type UpdateApiMinionsNetworkDeviceMinionIdOptions = {baseUrl: string, userAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Replace physical device of given minion. * * PUT /minions/network-device/{minionId} * * Also accepts auth: adminAuth */ export const updateApiMinionsNetworkDeviceMinionId = async (args: UpdateApiMinionsNetworkDeviceMinionIdArgs, options: UpdateApiMinionsNetworkDeviceMinionIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, userAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (userAuth !== undefined) headers.set("authentication", userAuth) const url = `${baseUrl.replace(/\/+$/, '')}/minions/network-device/${encodeURIComponent(String(args.minionId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };