export type GroupRoleMapping = {group: string, global_role: string, role_domains?: ({role?: string | undefined, domains?: Array | undefined}) | undefined}; export type RESTServerLDAPConfig = {directory?: string | undefined, hostname?: string | undefined, port?: number | undefined, ssl?: boolean | undefined, base_dn?: string | undefined, bind_dn?: string | undefined, bind_password?: string | undefined, group_member_attr?: string | undefined, username_attr?: string | undefined, enable?: boolean | undefined, default_role?: string | undefined, role_groups?: ({role?: string | undefined, groups?: Array | undefined}) | undefined, group_mapped_roles?: Array | undefined}; export type RESTServerSAMLConfig = {sso_url: string, issuer: string, x509_cert?: string | undefined, group_claim: string, enable?: boolean | undefined, default_role?: string | undefined, role_groups?: ({role?: string | undefined, groups?: Array | undefined}) | undefined, group_mapped_roles?: Array | undefined}; export type RESTServerOIDCConfig = {issuer: string, client_id: string, client_secret?: string | undefined, group_claim: string, scopes?: Array | undefined, enable: boolean, default_role: string, role_groups?: ({role?: string | undefined, groups?: Array | undefined}) | undefined, group_mapped_roles?: Array | undefined}; export type RESTServerConfig = {name: string, ldap?: RESTServerLDAPConfig | undefined, saml?: RESTServerSAMLConfig | undefined, oidc?: RESTServerOIDCConfig | undefined}; export type RESTServerConfigData = {config: RESTServerConfig}; export type PatchApiServerNameArgs = {'X-Auth-Token': string, name: string, body: RESTServerConfigData}; export type PatchApiServerNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update server * * PATCH /server/{name} */ export const patchApiServerName = async (args: PatchApiServerNameArgs, options: PatchApiServerNameOptions) => { 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(/\/+$/, '')}/server/${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 };