export type RESTServerRoleGroupsConfig = {name: string, role: string, groups: Array}; export type RESTServerRoleGroupsConfigData = {config: RESTServerRoleGroupsConfig}; export type PatchApiServerNameRoleRoleArgs = {'X-Auth-Token': string, name: string, role: string, body: RESTServerRoleGroupsConfigData}; export type PatchApiServerNameRoleRoleOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update server role groups * * PATCH /server/{name}/role/{role} */ export const patchApiServerNameRoleRole = async (args: PatchApiServerNameRoleRoleArgs, options: PatchApiServerNameRoleRoleOptions) => { 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))}/role/${encodeURIComponent(String(args.role))}${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 };