export type SystemAuditRequest = {description?: string | undefined, local?: boolean | undefined, options?: Record | undefined, type?: string | undefined}; export type CreateApiSysAuditPathArgs = {body: SystemAuditRequest}; export type CreateApiSysAuditPathOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Enable a new audit device at the supplied path. * * POST /sys/audit/{path} */ export const createApiSysAuditPath = async (args: CreateApiSysAuditPathArgs, options: CreateApiSysAuditPathOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/sys/audit/${encodeURIComponent(String(args.path))}${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 };