export type RoleModel = {id?: (string | null) | undefined, name?: (string | null) | undefined, color?: (string | null) | undefined, description?: (string | null) | undefined}; export type AccessControlModel = {id?: (string | null) | undefined, principalId?: (string | null) | undefined, scope?: (string | null) | undefined, role?: RoleModel | undefined}; export type CreateApiApiAccessControlsArgs = {body: AccessControlModel}; export type CreateApiApiAccessControlsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create a new role and the associated actions * * POST /api/access-controls */ export const createApiApiAccessControls = async (args: CreateApiApiAccessControlsArgs, options: CreateApiApiAccessControlsOptions) => { 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/access-controls${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };