export type CreateUserRequest = {data?: ({user?: string | undefined, pass?: string | undefined, groups?: Array | undefined}) | undefined}; export type CreateApiLdapUserArgs = {sessionId?: string | undefined, body: CreateUserRequest}; export type CreateApiLdapUserOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create * * POST /ldap/user */ export const createApiLdapUser = async (args: CreateApiLdapUserArgs, options?: CreateApiLdapUserOptions) => { const {baseUrl = "http://:8085/gbds/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args.sessionId != null) headers.set("sessionId", String(args.sessionId)) const url = `${baseUrl.replace(/\/+$/, '')}/ldap/user${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 res.blob() };