export type PublicCreateGroupRequest = {name: string, description?: string | undefined, groupId: string, externalGroups?: Array | undefined, externalGroupRegex?: Array | undefined}; export type CreateApiPublicV1GroupsArgs = {body: PublicCreateGroupRequest}; export type CreateApiPublicV1GroupsOptions = {baseUrl: string, httpAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new group in the organization * * POST /public/v1/groups */ export const createApiPublicV1Groups = async (args: CreateApiPublicV1GroupsArgs, options: CreateApiPublicV1GroupsOptions) => { const {baseUrl, fetch: fetchFn = fetch, httpAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (httpAuth !== undefined) headers.set('authorization', `Bearer ${httpAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/groups${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 };