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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| userGroup | Yes | UserGroup | Pass a userGroup object. |
| actions | Yes | Permission | Pass a Permission object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| userGroup | Yes | UserGroup | Pass a UserGroup object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const permission = await IafWorkspace.addItemAllAccess(workspace, userGroup);addResourceByUserType#
Adds a resource to a Workspace.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| resource | Yes | Object | Pass the resource object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const workSpace = await IafWorkspace.addResourceByUserType(workspace, resource);addUserGroups#
Adds UserGroups to a Workspace.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| userGroups | Yes | Array<UserGroup> | Pass an array of UserGroup objects. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const updatedWs = await IafWorkspace.addUserGroups(workspace, userGroups);delete#
Deletes a Workspace when you pass a Workspace object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
String - 'ok: 204'
await IafWorkspace.delete(workspace);get#
Gets a Workspace when you pass a Workspace object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const workspace = await IafWorkspace.get(workspace);getAll#
Gets all Workspace class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
| options | Yes | undefined |
const workspaces = await IafWorkspace.getAll(ctx);getById#
Gets a Workspace when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspaceId | Yes | string | Pass the Workspace's id. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const workspace = await IafWorkspace.getById(workspace[0]._id);getResourcesByUserType#
Gets a Workspace's resources that match the userType you pass.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| userType | Yes | String | Pass the name of the user type that defines the resources you want to get. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
let wsResources = await IafWorkspace.getResourcesByUserType(workspace, "example_user_type");getUserGroups#
Gets all the UserGroups for a Workspace.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const userGroups = await IafWorkspace.getUserGroups(workspace);getUserGroupsForUser#
Gets a User's UserGroups in a Workspace.
| Parameter | Required | Type | Description |
|---|---|---|---|
| user | Yes | User | Pass a User object. |
| workspace | Yes | Workspace | Pass a Workspace object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const userGroups = await IafWorkspace.getUserGroupsForUser(user, workspace);getUsers#
Gets the Workspace's users that match a query you pass.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| query | Yes | string | Pass a simple query to get the users you want. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
User -
const query = { _isSocial: true };const users = await IafWorkspace.getUsers(workspace, query);hardDelete#
Hard deletes a Workspace when you pass the Workspace's id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
String - 'ok: 204' - set purge=true
await IafWorkspace.hardDelete(workspace);removeResourceByUserType#
Deletes Workspace resources that match the userType you pass.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| resource | Yes | Object | Pass an object that contains a "_userType" property and value. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
const resource = { userType: "example_user_type" };
const workSpace = await IafWorkspace.removeResourceByUserType(workspace, resource);update#
Updates a Workspace when you pass an updated Workspace object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| workspace | Yes | Workspace | Pass a Workspace object. |
| ctx | No | Ctx | Context, such as namespaces and authentication token information. |
Workspace - The updated Workspace object
workspace._shortName = "ex_proj_name";
const updatedWorkspace = await IafWorkspace.update(workspace);