export type NodeCommandProperty = {key?: string | undefined, value?: Record | undefined}; export type NodeCommand = {isSystemCommandType?: boolean | undefined, nodeCommandType?: string | undefined, nodeCommandProperties?: Array | undefined}; export type CreateApi10KbNodesInfoArgs = {localNodeOnly?: boolean | undefined, 'X-Killbill-CreatedBy': string, 'X-Killbill-Reason'?: string | undefined, 'X-Killbill-Comment'?: string | undefined, body: NodeCommand}; export type CreateApi10KbNodesInfoOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Trigger a node command * * POST /1.0/kb/nodesInfo */ export const createApi10KbNodesInfo = async (args: CreateApi10KbNodesInfoArgs, options: CreateApi10KbNodesInfoOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.localNodeOnly != null) query.append("localNodeOnly", String(args.localNodeOnly)) if (args['X-Killbill-CreatedBy'] != null) headers.set("X-Killbill-CreatedBy", String(args['X-Killbill-CreatedBy'])) if (args['X-Killbill-Reason'] != null) headers.set("X-Killbill-Reason", String(args['X-Killbill-Reason'])) if (args['X-Killbill-Comment'] != null) headers.set("X-Killbill-Comment", String(args['X-Killbill-Comment'])) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/1.0/kb/nodesInfo${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 };