export type RESTAgentConfig = {debug?: Array | undefined, disable_nvprotect?: boolean | undefined, disable_kvcctl?: boolean | undefined}; export type RESTAgentConfigData = {config: RESTAgentConfig}; export type PatchApiEnforcerIdArgs = {'X-Auth-Token': string, id: string, body: RESTAgentConfigData}; export type PatchApiEnforcerIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update enforcer * * PATCH /enforcer/{id} */ export const patchApiEnforcerId = async (args: PatchApiEnforcerIdArgs, options: PatchApiEnforcerIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Auth-Token'] != null) headers.set("X-Auth-Token", String(args['X-Auth-Token'])) const url = `${baseUrl.replace(/\/+$/, '')}/enforcer/${encodeURIComponent(String(args.id))}${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 };