Skip to main content
Version: v4.6

IafUserGroup

Use the IafUserGroup API to create and manage user groups, user group invites, users, and user configs in the Passport and Item Service.

addAllAccess#

Give all access permissions to a UserGroup and its Users when you pass the UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupThe UserGroup object
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Permission - A Permission object with all access permissions.

Examples
const permission = await IafUserGroup.addAllAccess(userGroup);

addAllAccessToGroup#

Give all access permissions to a UserGroup and its users when you pass the UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringPass the UserGroup's id.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Permission - A Permission object with all access permissions.

Examples
const permission = await IafUserGroup.addAllAccessToGroup(userGroup._id);

addResourceByUserType#

Adds a resource of a given userType to a UserGroup.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object.
resourceYesObjectPass the resource object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup -

Examples
const resource = {  _name: "example_project_workspace",    _shortName: "example_proj_ws",   _namespaces: "ProjB_HEpftR8X"};
const addedResource = await IafUserGroup.addResourceByUserType(userGroup, resource);

addUserConfigs#

Adds UserConfig class object's to a UserGroup when you pass the UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object.
userConfigsYesUserConfigPass a UserConfig object with the properties and values you want to define the user config.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Array<UserConfig> - The array of UserConfig objects you create.

Examples
const userConfigs = [  {    _name: "Project A setupe user config",    _shortName: "prjASetup",    _userType: "projectA_setup_userconfig"  },  {    _name: "Project B setupe user config",    _shortName: "prjBSetup",    _userType: "projectB_setup_userconfig"  }];
const userConfigs = await IafUserGroup.addUserConfigs(userGroup, userConfigs);

addUserConfigsToGroup#

Adds UserConfig class objects to a UserGroup when you pass the UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringPass the UserGroup's id.
userConfigsYesArray<UserConfig>Pass an array of UserConfig objects that contain the properties and values you want to define the user configuration.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Array<UserConfig> - The array of UserConfig objects you create.

Examples
const userConfigs = [  {    _name: "Project A setupe user config",    _shortName: "prjASetup",    _userType: "projectA_setup_userconfig"  },  {    _name: "Project B setupe user config",    _shortName: "prjBSetup",    _userType: "projectB_setup_userconfig"  }];
const createdUserGroups = await IafUserGroup.addUserConfigsToGroup(userGroup, userConfigs);

addUserToGroup#

Adds a User to an existing UserGroup when you pass a UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object you want to add the user to.
userYesUserPass a User object with the properties and values you want to define the user.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Array<User> - An array that contains only the added User object.

Examples
const updatedUserGroup = await IafUserGroup.addUserToGroup(userGroup, user);

addUserToGroupById#

Adds a User to an existing UserGroup when you pass the UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id
userYesUserThe User object
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup -

Examples
const updatedUserGroup = await IafUserGroup.addUserToGroup(userGroup._id, user._id);

addUserToGroupByInvite#

Adds a User to a UserGroup when they accept the invite.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object.
invitationYesInvitePass the Invite object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup -

Examples
await IafUserGroup.addUserToGroupByInvite(userGroup, invitation);

addUserToGroupByInviteId#

Invites a User to a UserGroup when you pass the Invite's id. The invitee is added to the user group when they accept the invite.

ParameterRequiredTypeDescription
userGroupIdYesStringPass the UserGroup's id.
invitationIdYesStringPass the Invite's id.
ctxYesCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The UserGroup object

Examples
await IafUserGroup.addUserToGroupByInviteId(userGroup._id, invite._id);

cancelInvite#

Cancels a sent Invite to a UserGroup.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass a UserGroup object.
inviteIdYesStringPass the id of the Invite you want to cancel.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<String> - {ok:204} response

Examples
const res = await IafUserGroup.cancelInvite(userGroup, invite._id);

create#

Creates a new UserGroup.

ParameterRequiredTypeDescription
userGroupYesObjectPass a UserGroup JSON object with the properties and values you want to define the user group.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The created UserGroup object.

Examples
const userGroup = {  _name: "user_group_for_testing_purposes",  _shortName: "test_user_group",  _namespaces: "ProjA_HEpftR8X",  _userType: "example_user_group"};
const userGroup = await IafUserGroup.create(userGroup);

createUserGroupPermForUser#

Creates a Permission for a UserGroup for a User when you pass User and UserGroup objects.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object you want to give the User permissions to.
userYesUserPass a User object. You can pass a variable that points to the object, or an object that contains at least the "_id" property and value.
permissionYesPermissionPass a Permission object with the properties and values you want to define the permsission.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Permission - The created Permission object

Examples
const permission = {   _actions: [ IafPermission.PermConst.Action.Read, IafPermission.PermConst.Action.Share, IafPermission.PermConst.Action.Delete ],   _namespace: userGroup._namespaces[0],};
const userGroupPerm = await IafUserGroup.createUserGroupPermissionForUser(userGroup, user, permission);

createUserGroupPermissionForUser#

Creates a UserGroup permission for a user when you pass the user and UserGroup ids.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id.
userIdYesStringThe User's id.
permissionYesPermissionPass a Permission object with the properties and values you want to define the user permsission.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Permission - The created Permission for a UserGroup.

Examples
const permission = {   _actions: [ IafPermission.PermConst.Action.Read, IafPermission.PermConst.Action.Share, IafPermission.PermConst.Action.Delete ],   _namespace: userGroup._namespaces[0],};
const userGroupPerm = await IafUserGroup.createUserGroupPermissionForUser(  userGroup._id,   currentUser._id,   permission);

delete#

Deletes a UserGroup when you pass the UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupA UserGroup object. Pass either a variable that points to the object, or a UserGroup object that contains at least an "_id" property and value.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

String - 'ok: 204'

Examples
const result = await IafUserGroup.delete(userGroup);

deleteById#

Deletes a UserGroup when you pass its id.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

String - 'ok: 204'

Examples
const result = await IafUserGroup.deleteById(userGroup._id);

deleteUserFromGroup#

Deletes a User from an UserGroup when you pass a UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object you want to add the user to.
userYesUserPass a User object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The updated UserGroup object without the user.

Examples
const updatedUserGroup = await IafUserGroup.deleteUserFromGroup(userGroup, user);

deleteUserFromUserGroup#

Deletes a User from an existing UserGroup when you pass a UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id.
userYesUserThe User object. Pass either a variable that points to the object, or a User object that contains at least an "_id" property and value.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The updated UserGroup object without the user.

Examples
const updatedUserGroup = await IafUserGroup.deleteUserFromUserGroup(userGroup._id, user);

get#

Gets a user group when you pass a UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object. Pass either a variable that points to the object, or a UserGroup object that contains at least an "_id" property and value.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The UserGroup object you request

Examples
const userGroup = await IafUserGroup.get(userGroup);

getById#

Gets a UserGroup when you pass the its id.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The requested UserGroup object

Examples
const userGroup = await IafUserGroup.getById(userGroup._id);

getInvites#

Gets all the sent invites for a UserGroup.

ParameterRequiredTypeDescription
userGroupYesUserGroupUserGroup object
criteriaYesInviteCriteriaPass an InviteCriteria object to filter invites by status.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoInviteOptionsPass an InviteOptions object to set the pagination, offset, and pagesize.
Returns

Promise<Page<Invite>> - A Page object with the Invite objects

Examples
let sentInvites = await IafUserGroup.getInvites(userGroup, criteria);

getResourcesByUserType#

Gets a UserGroup's resources that match the userType you pass.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass a UserGroup object.
userTypeYesStringPass the name of the userType that defines the resources you want to get.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Object - Returns the resource objects you request

Examples
const resources = await IafUserGroup.getResourcesByUserType(userGroup, "example_user_type");

getUserConfigs#

Gets a UserGroup's UserConfig objects when you pass the UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object.
filtersNoObjectPass a simple filter query.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Array<UserConfig> - Returns an array of the UserGroup's UserConfig.

Examples
const filters = { _userType: "example_user_config" };
const userConfigs = await IafUserGroup.getUserConfigs(userGroup, filters);

getUserConfigsInUserGroup#

Gets a UserGroup's UserConfig objects when you pass the UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringPass the UserGroup's id.
filtersNoObjectPass a simple filter query.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserConfig - An array of the UserGroup's UserConfig objects.

Examples
let filters = { _shortName: "example_user_config" };
const userConfigs = await IafUserGroup.getUserConfigsInUserGroup(  userGroup._id,   filters);

getUserInvite#

Gets a Invite for a UserGroup invite when you pass the Invite's id.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass a UserGroup object.
invitationYesInvitePass an Invite object. Pass either a variable that points to the object, or a Invite object that contains at least an "_id" property and value.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Invite - The Invite object

Examples
const userGroupInvite = await IafUserGroup.getUserInvite(userGroup, invitation);

getUserInviteById#

Gets an Invite for a User in a given UserGroup.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id
invitationIdYesStringThe Invite id
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Invite - The Invite object

Examples
const userGroupInvite = await IafUserGroup.getUserInviteById(userGroup._id, invite._id);

getUsers#

Gets a UserGroup's User class object when you pass a UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object.
ctxNoCtxContext, such as namespaces and authentication token information.
optionsNoJSONPass a JSON object with the options parameters you want, such as "_offset", and "_pageSize".
Returns

Page<User> - A Page object with the User objects you request

Examples
const users = await IafUserGroup.getUsers(userGroup, ctx);

getUsersInGroup#

Gets a UserGroup's users when you pass the UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id
ctxNoCtxContext, such as namespaces and authentication token information.
optionsYesJSONOptional parameters such as _offset and _pageSize, which are by default 0 and 10 respectively
Returns

Array<User> - An array with the User objects you request

Examples
const users = await IafUserGroup.getUsersInGroup(userGroup._id, ctx);

hardDelete#

Hard deletes a UserGroup when you pass the UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass a UserGroup object. Pass either a variable that points to the object, or a UserGroup object that contains at least an "_id" property and value.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

String - 'ok: 204' - set purge=true

Examples
const result = await IafUserGroup.hardDelete(userGroup);

inviteUsersToGroup#

Invites users by email to a UserGroup when you pass a UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupThe UserGroup object.
dataYesArray<Invite>Pass an array of Invite objects. Either define a new object or reference the "_id" value of an existing Invite object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Invite - Created Invite object

Examples
const data = [ { _email: "[email protected]" }, { _email: "[email protected]" } ];
const invites = await IafUserGroup.inviteUsersToGroup(userGroup, data);

inviteUsersToGroupById#

Invites users to a UserGroup when you pass the UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id.
dataYesArray<Invite>Pass an array of Invite objects. Either define a new object or reference the "_id" value of an existing Invite object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Invite - The Invite class object

Examples
const data = [ { _email: "[email protected]" }, { _email: "[email protected]" } ];
const invites = await IafUserGroup.inviteUsersToGroupById(userGroup._id, data);

rejectInvite#

Rejects a specific Invite to a UserGroup.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object.
inviteIdYesStringPass the id of the Invite you want to reject.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Promise<String> - {ok:204} response

Examples
const res = await IafUserGroup.rejectInvite(userGroup, invite._id);

removeResourceByUserType#

Removes a UserGroup resource of a given userType.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass a UserGroup object.
resourceYesObjectPass the resource object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - Returns the updated UserGroup object without the removed resource.

Examples
let resource = {  _name: "example_project_workspace",    _shortName: "example_proj_ws",   _namespaces: "ProjB_HEpftR8X"};
await IafUserGroup.removeResourceByUserType(userGroup, resource);

removeUserConfig#

Removes a UserConfig object from a UserGroup when you pass the UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass the UserGroup object.
userConfigYesUserConfigPass the UserConfig object you want to remove.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The updated UserGroup object without the UserConfig.

Examples
const updatedUsergroup = await IafUserGroup.removeUserConfig(userGroup, userConfig);

removeUserConfigInUserGroup#

Removes a UserConfig from a UserGroup when you pass the UserGroup's id.

ParameterRequiredTypeDescription
userGroupIdYesStringPass the UserGroup's id.
userConfigIdYesStringThe UserConfig's id.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The updated UserGroup object without the UserConfig.

Examples
const updatedUsergroup = await IafUserGroup.removeUserConfigInUserGroup(userGroup._id, userGroup._id);

update#

Updates a UserGroup in the database when you pass an updated version of the UserGroup object.

ParameterRequiredTypeDescription
userGroupYesUserGroupPass an updated UserGroup object that maintains the correct "_id" property. The UserGroup object you pass overwrites the values of the stored user group.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The updated UserGroup object

Examples
const userGroup = {  _id: <user-group-id>,  _shortName: "updated_user_group",  _userType: "updated_user_group"};
const updatedUserGroup = await IafUserGroup.update(userGroup);

updateById#

Updates a UserGroup when you pass its id and an updated UserGroup object with the properties you want to update.

ParameterRequiredTypeDescription
userGroupIdYesStringThe UserGroup's id
userGroupYesUserGroupPass a UserGroup object with the properties and values you want to update.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

UserGroup - The updated UserGroup object

Examples
userGroup._userType = "updated_user_group";
const updatedUserGroup = await IafUserGroup.updateById(userGroup._id, userGroup);