export type RESTAdmissionState = {enable?: boolean | undefined, mode?: string | undefined, default_action?: string | undefined, adm_client_mode?: string | undefined, adm_svc_type?: string | undefined, adm_client_mode_options?: ({service?: string | undefined, url?: string | undefined}) | undefined, ctrl_states?: ({validate?: string | undefined, states?: boolean | undefined}) | undefined}; export type RESTAdmissionRuleOption = {name: string, ops: Array, values?: Array | undefined, match_src?: string | undefined, sub_options?: ({rule?: string | undefined, options?: RESTAdmissionRuleOption | undefined}) | undefined}; export type RESTAdmRuleOptions = {rule_options: {rule?: string | undefined, options?: RESTAdmissionRuleOption | undefined}}; export type RESTAdmCatOptions = {k8s_options?: RESTAdmRuleOptions | undefined}; export type RESTAdmRuleCriterion = {name: string, op: string, value: string, sub_criteria?: Array | undefined}; export type RESTAdmRuleTypeOptions = {deny_options: RESTAdmCatOptions, exception_options: RESTAdmCatOptions, psp_collection?: Array | undefined}; export type RESTAdmissionConfigData = {state?: RESTAdmissionState | undefined, admission_options?: RESTAdmRuleTypeOptions | undefined, k8s_env: boolean}; export type PatchApiAdmissionStateArgs = {'X-Auth-Token': string, body: RESTAdmissionConfigData}; export type PatchApiAdmissionStateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update admission state * * PATCH /admission/state */ export const patchApiAdmissionState = async (args: PatchApiAdmissionStateArgs, options: PatchApiAdmissionStateOptions) => { 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(/\/+$/, '')}/admission/state${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 };