export type RESTCriteriaEntry = {key: string, value: string, op: string}; export type RESTGroupConfig = {name: string, criteria?: Array | undefined, cfg_type: string}; export type RESTGroupConfigData = {config: RESTGroupConfig}; export type PatchApiGroupNameArgs = {'X-Auth-Token': string, name: string, body: RESTGroupConfigData}; export type PatchApiGroupNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update group * * PATCH /group/{name} */ export const patchApiGroupName = async (args: PatchApiGroupNameArgs, options: PatchApiGroupNameOptions) => { 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(/\/+$/, '')}/group/${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 };