export type RESTWebhook = {name: string, url: string, enable: boolean, type: string, cfg_type: string}; export type RESTProxy = {url: string, username: string, password?: string | undefined}; export type RESTSystemConfigConfig = {new_service_policy_mode?: string | undefined, unused_group_aging?: number | undefined, syslog_ip?: string | undefined, syslog_ip_proto?: number | undefined, syslog_port?: number | undefined, syslog_level?: string | undefined, syslog_status?: boolean | undefined, syslog_categories?: Array | undefined, syslog_in_json?: boolean | undefined, single_cve_per_syslog: boolean, auth_order?: Array | undefined, auth_by_platform?: boolean | undefined, webhooks?: Array | undefined, cluster_name: string, controller_debug?: Array | undefined, monitor_service_mesh?: boolean | undefined, registry_http_proxy_status?: boolean | undefined, registry_https_proxy_status?: boolean | undefined, registry_http_proxy?: RESTProxy | undefined, registry_https_proxy?: RESTProxy | undefined, ibmsa_ep_enabled?: boolean | undefined, ibmsa_ep_dashboard_url?: string | undefined, xff_enabled?: boolean | undefined}; export type RESTSystemConfigConfigData = {config: RESTSystemConfigConfig, fed_config: RESTSystemConfigConfig}; export type PatchApiSystemConfigArgs = {'X-Auth-Token': string, body: RESTSystemConfigConfigData}; export type PatchApiSystemConfigOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * System configure * * PATCH /system/config */ export const patchApiSystemConfig = async (args: PatchApiSystemConfigArgs, options: PatchApiSystemConfigOptions) => { 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(/\/+$/, '')}/system/config${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 };