Skip to main content
Version: v4.5

IafWorkspace

Use the IafWorkspace API to add and manage workspaces, user groups, users, and other resources in the Passport service.

addAllAccess#

Adds a UserGroup Permission to a Workspace.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
userGroupYesUserGroupPass a userGroup object.
actionsYesPermissionPass a Permission object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Permission -

Examples
let actions = [{ _actions: [  IafPermission.PermConst.Action.Read, IafPermission.PermConst.Action.Share, IafPermission.PermConst.Action.Delete], _namespace: user._namespaces[0], _resourceDesc:{   _irn: IafPermission.NamedUserItemIrnAll }, _user:{   _id: user._id, // Either user or usergroup id   _type: IafPermission.PermConst.UserType.User // Either user or usergroup }}];
const permission = await IafWorkspace.addAllAccess(workspace, userGroup, actions);

addItemAllAccess#

Give a UserGroups full permissions for a Workspace.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
userGroupYesUserGroupPass a UserGroup object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Permission -

Examples
const permission = await IafWorkspace.addItemAllAccess(workspace, userGroup);

addResourceByUserType#

Adds a resource to a Workspace.

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

Workspace -

Examples
const workSpace = await IafWorkspace.addResourceByUserType(workspace, resource);

addUserGroups#

Adds UserGroups to a Workspace.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
userGroupsYesArray<UserGroup>Pass an array of UserGroup objects.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Workspace -

Examples
const updatedWs = await IafWorkspace.addUserGroups(workspace, userGroups);

delete#

Deletes a Workspace when you pass a Workspace object.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

String - 'ok: 204'

Examples
await IafWorkspace.delete(workspace);

get#

Gets a Workspace when you pass a Workspace object.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Workspace -

Examples
const workspace = await IafWorkspace.get(workspace);

getAll#

Gets all Workspace class object.

ParameterRequiredTypeDescription
ctxNoCtxContext, such as namespaces and authentication token information.
optionsYesundefined
Returns

Array<Workspace> -

Examples
const workspaces = await IafWorkspace.getAll(ctx);

getById#

Gets a Workspace when you pass its id.

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

Workspace -

Examples
const workspace = await IafWorkspace.getById(workspace[0]._id);

getResourcesByUserType#

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

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
userTypeYesStringPass the name of the user type that defines the resources you want to get.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Workspace -

Examples
let wsResources = await IafWorkspace.getResourcesByUserType(workspace, "example_user_type");

getUserGroups#

Gets all the UserGroups for a Workspace.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Workspace -

Examples
const userGroups = await IafWorkspace.getUserGroups(workspace);

getUserGroupsForUser#

Gets a User's UserGroups in a Workspace.

ParameterRequiredTypeDescription
userYesUserPass a User object.
workspaceYesWorkspacePass a Workspace object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Workspace -

Examples
const userGroups = await IafWorkspace.getUserGroupsForUser(user, workspace);

getUsers#

Gets the Workspace's users that match a query you pass.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
queryYesstringPass a simple query to get the users you want.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

User -

Examples
const query = { _isSocial: true };const users = await IafWorkspace.getUsers(workspace, query);

hardDelete#

Hard deletes a Workspace when you pass the Workspace's id.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

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

Examples
await IafWorkspace.hardDelete(workspace);

removeResourceByUserType#

Deletes Workspace resources that match the userType you pass.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
resourceYesObjectPass an object that contains a "_userType" property and value.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Workspace -

Examples
const resource = { userType: "example_user_type" };
const workSpace = await IafWorkspace.removeResourceByUserType(workspace, resource);

update#

Updates a Workspace when you pass an updated Workspace object.

ParameterRequiredTypeDescription
workspaceYesWorkspacePass a Workspace object.
ctxNoCtxContext, such as namespaces and authentication token information.
Returns

Workspace - The updated Workspace object

Examples
workspace._shortName = "ex_proj_name";
const updatedWorkspace = await IafWorkspace.update(workspace);