export type NodeSpec = {Name?: string | undefined, Labels?: {[key: string]: string} | undefined, Role?: ('worker' | 'manager') | undefined, Availability?: ('active' | 'pause' | 'drain') | undefined}; export type CreateApiNodesIdUpdateArgs = {id: string, version: number, body: NodeSpec}; export type CreateApiNodesIdUpdateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update a node * * POST /nodes/{id}/update */ export const createApiNodesIdUpdate = async (args: CreateApiNodesIdUpdateArgs, options: CreateApiNodesIdUpdateOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.version != null) query.append("version", String(args.version)) const url = `${baseUrl.replace(/\/+$/, '')}/nodes/${encodeURIComponent(String(args.id))}/update${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };