export type SystemRawRequest = {compressed?: boolean | undefined, compression_type?: string | undefined, encoding?: string | undefined, value?: string | undefined}; export type CreateApiSysRawPathArgs = {body: SystemRawRequest}; export type CreateApiSysRawPathOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update the value of the key at the given path. * * POST /sys/raw/{path} */ export const createApiSysRawPath = async (args: CreateApiSysRawPathArgs, options: CreateApiSysRawPathOptions) => { 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/raw/${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 };