export type RESTCLUSEventCondition = {type?: string | undefined, value?: string | undefined}; export type RESTResponseRuleConfig = {id: number, comment?: string | undefined, group?: string | undefined, event?: string | undefined, conditions?: Array | undefined, actions?: Array | undefined, webhooks?: Array | undefined, disable?: boolean | undefined, cfg_type: string}; export type RESTResponseRuleConfigData = {config: RESTResponseRuleConfig}; export type PatchApiResponseRuleIdArgs = {'X-Auth-Token': string, id: string, body: RESTResponseRuleConfigData}; export type PatchApiResponseRuleIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update a response rule * * PATCH /response/rule/{id} */ export const patchApiResponseRuleId = async (args: PatchApiResponseRuleIdArgs, options: PatchApiResponseRuleIdOptions) => { 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(/\/+$/, '')}/response/rule/${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 };