export type RoleBindingInput = {customer_id: string, role_id: string, scope_object_id: string, scope_type: 'org' | 'project'}; export type ApplyRoleBindingRequest = {bindings_to_create: Array, bindings_to_delete: Array}; export type CreateApiIamUsersUserIdRoleBindingsArgs = {user_id: string, body: ApplyRoleBindingRequest}; export type CreateApiIamUsersUserIdRoleBindingsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates and deletes role bindings for a user in a single atomic operation. * * POST /iam/users/{user_id}/role-bindings */ export const createApiIamUsersUserIdRoleBindings = async (args: CreateApiIamUsersUserIdRoleBindingsArgs, options?: CreateApiIamUsersUserIdRoleBindingsOptions) => { const {baseUrl = "https://api.cloud.crusoe.ai/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/iam/users/${encodeURIComponent(String(args.user_id))}/role-bindings${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 };