export type RESTFileMonitorFilterConfig = {filter: string, recursive: boolean, behavior: string, applications: Array, group: string}; export type RESTFileMonitorConfig = {add_filters?: Array | undefined, delete_filters?: Array | undefined, update_filters?: Array | undefined}; export type RESTFileMonitorConfigData = {config: RESTFileMonitorConfig}; export type PatchApiFileMonitorNameArgs = {'X-Auth-Token': string, name: string, body: RESTFileMonitorConfigData}; export type PatchApiFileMonitorNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update file monitor * * PATCH /file_monitor/{name} */ export const patchApiFileMonitorName = async (args: PatchApiFileMonitorNameArgs, options: PatchApiFileMonitorNameOptions) => { 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(/\/+$/, '')}/file_monitor/${encodeURIComponent(String(args.name))}${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 };