export type RoleDetailsModel = {id?: (string | null) | undefined, name?: (string | null) | undefined, color?: (string | null) | undefined, description?: (string | null) | undefined, actions?: (Array | null) | undefined}; export type UpdateApiApiRolesIdArgs = {id: string, body: RoleDetailsModel}; export type UpdateApiApiRolesIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Edit an existing role and the associated actions, delete the actions that are not in the new list * * PUT /api/roles/{id} */ export const updateApiApiRolesId = async (args: UpdateApiApiRolesIdArgs, options: UpdateApiApiRolesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/roles/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };