export type FactoryAddresses = {cidr: string, count: number, first: string, gateway?: (string | null) | undefined, name: string, routed: boolean}; export type FactoryMetadata = {addresses?: Array | undefined, dump_to_rpool?: (number | null) | undefined, post_job_diagnostic_script?: (string | null) | undefined, pre_job_diagnostic_script?: (string | null) | undefined, root_authorized_keys?: (string | null) | undefined, root_password_hash?: (string | null) | undefined, rpool_disable_sync?: (boolean | null) | undefined, v: '1'}; export type FactoryWorkerAssociate = {ip?: (string | null) | undefined, metadata?: (FactoryMetadata | null) | undefined, private: string}; export type PatchApi0FactoryWorkerWorkerArgs = {worker: string, body: FactoryWorkerAssociate}; export type PatchApi0FactoryWorkerWorkerOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PATCH /0/factory/worker/{worker} */ export const patchApi0FactoryWorkerWorker = async (args: PatchApi0FactoryWorkerWorkerArgs, options: PatchApi0FactoryWorkerWorkerOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/0/factory/worker/${encodeURIComponent(String(args.worker))}${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 };