Class: Groups

Groups(client) → {void}

Simple manager for interacting with all 'Groups' endpoints and actions.

Constructor

new Groups(client) → {void}

Parameters:
Name Type Description
client BoxClient The Box API Client that is responsible for making calls to the API
Source:
Returns:
Type
void

Members

accessLevels :GroupAccessLevel

Enum of valid access levels for groups, which are used to specify who can perform certain actions on the group.
Type:
Source:

userRoles :GroupUserRole

Enum of valid user roles within a group
Type:
Source:

Methods

addUser(groupID, userID, optionsopt, callbackopt) → {Promise.<Object>}

Add a user to a group, which creates a membership record for the user API Endpoint: '/group_memberships' Method: POST
Parameters:
Name Type Attributes Description
groupID string The ID of the group to add the user to
userID string The ID of the user to add the the group
options Object <optional>
Optional parameters for adding the user, can be left null in most cases
Properties
Name Type Attributes Description
role GroupUserRole <optional>
The role of the user in the group
callback function <optional>
Passed the membership record if successful, error otherwise
Source:
Returns:
A promise resolving to the new membership object
Type
Promise.<Object>

addUser(groupID, userID, optionsopt, callbackopt) → {Promise.<Object>}

Add a user to a group, which creates a membership record for the user API Endpoint: '/group_memberships' Method: POST
Parameters:
Name Type Attributes Description
groupID string The ID of the group to add the user to
userID string The ID of the user to add the the group
options Object <optional>
Optional parameters for adding the user, can be left null in most cases
Properties
Name Type Attributes Description
role GroupUserRole <optional>
The role of the user in the group
callback function <optional>
Passed the membership record if successful, error otherwise
Source:
Returns:
A promise resolving to the new membership object
Type
Promise.<Object>

create(name, optionsopt, callbackopt) → {Promise.<Object>}

Used to create a new group API Endpoint: '/groups' Method: POST
Parameters:
Name Type Attributes Description
name string The name for the new group
options Object <optional>
Additional parameters
Properties
Name Type Attributes Description
provenance string <optional>
Used to track the external source where the group is coming from
external_sync_identifier string <optional>
Used as a group identifier for groups coming from an external source
description string <optional>
Description of the group
invitability_level GroupAccessLevel <optional>
Specifies who can invite this group to collaborate on folders
member_viewability_level GroupAccessLevel <optional>
Specifies who can view the members of this group
callback function <optional>
Passed the new group object if it was created successfully, error otherwise
Source:
Returns:
A promise resolving to the new group object
Type
Promise.<Object>

create(name, optionsopt, callbackopt) → {Promise.<Object>}

Used to create a new group API Endpoint: '/groups' Method: POST
Parameters:
Name Type Attributes Description
name string The name for the new group
options Object <optional>
Additional parameters
Properties
Name Type Attributes Description
provenance string <optional>
Used to track the external source where the group is coming from
external_sync_identifier string <optional>
Used as a group identifier for groups coming from an external source
description string <optional>
Description of the group
invitability_level GroupAccessLevel <optional>
Specifies who can invite this group to collaborate on folders
member_viewability_level GroupAccessLevel <optional>
Specifies who can view the members of this group
callback function <optional>
Passed the new group object if it was created successfully, error otherwise
Source:
Returns:
A promise resolving to the new group object
Type
Promise.<Object>

delete(groupID, callbackopt) → {Promise.<void>}

Delete a group API Endpoint: '/groups/:groupID' Method: DELETE
Parameters:
Name Type Attributes Description
groupID string The ID of the group to delete
callback function <optional>
Passed nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

delete(groupID, callbackopt) → {Promise.<void>}

Delete a group API Endpoint: '/groups/:groupID' Method: DELETE
Parameters:
Name Type Attributes Description
groupID string The ID of the group to delete
callback function <optional>
Passed nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

get(groupID, optionsopt, callbackopt) → {Promise.<Object>}

Used to fetch information about a group API Endpoint: '/groups/:groupID' Method: GET
Parameters:
Name Type Attributes Description
groupID string The ID of the group to retrieve
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the group object if successful, error otherwise
Source:
Returns:
A promise resolving to the group object
Type
Promise.<Object>

get(groupID, optionsopt, callbackopt) → {Promise.<Object>}

Used to fetch information about a group API Endpoint: '/groups/:groupID' Method: GET
Parameters:
Name Type Attributes Description
groupID string The ID of the group to retrieve
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the group object if successful, error otherwise
Source:
Returns:
A promise resolving to the group object
Type
Promise.<Object>

getAll(optionsopt, callbackopt) → {Promise.<Object>}

Retreieve a list of groups in the caller's enterprise. This ability is restricted to certain users with permission to view groups. API Endpoint: '/groups' Method: GET
Parameters:
Name Type Attributes Description
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
filter_term string <optional>
Limits the results to only groups whose name starts with the search term
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of groups if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of groups
Type
Promise.<Object>

getAll(optionsopt, callbackopt) → {Promise.<Object>}

Retreieve a list of groups in the caller's enterprise. This ability is restricted to certain users with permission to view groups. API Endpoint: '/groups' Method: GET
Parameters:
Name Type Attributes Description
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
filter_term string <optional>
Limits the results to only groups whose name starts with the search term
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of groups if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of groups
Type
Promise.<Object>

getCollaborations(groupID, optionsopt, callbackopt) → {Promise.<Object>}

Retreieve a list of collaborations for the group, which show which items the group has access to. API Endpoint: '/groups/:groupID/collaborations' Method: GET
Parameters:
Name Type Attributes Description
groupID string The ID of the group to get collaborations for
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of collaborations if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of collaborations for the group
Type
Promise.<Object>

getCollaborations(groupID, optionsopt, callbackopt) → {Promise.<Object>}

Retreieve a list of collaborations for the group, which show which items the group has access to. API Endpoint: '/groups/:groupID/collaborations' Method: GET
Parameters:
Name Type Attributes Description
groupID string The ID of the group to get collaborations for
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of collaborations if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of collaborations for the group
Type
Promise.<Object>

getMembership(membershipID, optionsopt, callbackopt) → {Promise.<Object>}

Fetch a specific membership record, which shows that a given user is a member of some group. API Endpoint: '/group_memberships/:membershipID' Method: GET
Parameters:
Name Type Attributes Description
membershipID string The ID of the membership to fetch
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the membership record if successful, error otherwise
Source:
Returns:
A promise resolving to the membership object
Type
Promise.<Object>

getMembership(membershipID, optionsopt, callbackopt) → {Promise.<Object>}

Fetch a specific membership record, which shows that a given user is a member of some group. API Endpoint: '/group_memberships/:membershipID' Method: GET
Parameters:
Name Type Attributes Description
membershipID string The ID of the membership to fetch
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
Passed the membership record if successful, error otherwise
Source:
Returns:
A promise resolving to the membership object
Type
Promise.<Object>

getMemberships(groupID, optionsopt, callbackopt) → {Promise.<Object>}

Retreieve a list of memberships for the group, which show which users belong to the group API Endpoint: '/groups/:groupID/memberships' Method: GET
Parameters:
Name Type Attributes Description
groupID string The ID of the group to get memberships for
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of memberships if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of memberships
Type
Promise.<Object>

getMemberships(groupID, optionsopt, callbackopt) → {Promise.<Object>}

Retreieve a list of memberships for the group, which show which users belong to the group API Endpoint: '/groups/:groupID/memberships' Method: GET
Parameters:
Name Type Attributes Description
groupID string The ID of the group to get memberships for
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of memberships if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of memberships
Type
Promise.<Object>

removeMembership(membershipID, callbackopt) → {Promise.<void>}

Used to remove a group membership API Endpoint: '/group_memberships/:membershipID' Method: DELETE
Parameters:
Name Type Attributes Description
membershipID string The ID of the membership to be removed
callback function <optional>
Passed nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

removeMembership(membershipID, callbackopt) → {Promise.<void>}

Used to remove a group membership API Endpoint: '/group_memberships/:membershipID' Method: DELETE
Parameters:
Name Type Attributes Description
membershipID string The ID of the membership to be removed
callback function <optional>
Passed nothing if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

terminateSession(groupIDs) → {Promise.<Object>}

Validates the roles and permissions of the group, and creates asynchronous jobs to terminate the group's sessions. API Endpoint: '/groups/terminate_sessions' Method: POST
Parameters:
Name Type Description
groupIDs Array.<string> A list of group IDs
Source:
Returns:
A promise resolving a message about the request status.
Type
Promise.<Object>

terminateSession(groupIDs) → {Promise.<Object>}

Validates the roles and permissions of the group, and creates asynchronous jobs to terminate the group's sessions. API Endpoint: '/groups/terminate_sessions' Method: POST
Parameters:
Name Type Description
groupIDs Array.<string> A list of group IDs
Source:
Returns:
A promise resolving a message about the request status.
Type
Promise.<Object>

update(groupID, updates, callbackopt) → {Promise.<Object>}

Used to update or modify a group object API Endpoint: '/groups/:groupID' Method: PUT
Parameters:
Name Type Attributes Description
groupID string The ID of the group to update
updates Object Group fields to update
callback function <optional>
Passed the updated group object if successful, error otherwise
Source:
Returns:
A promise resolving to the updated group object
Type
Promise.<Object>

update(groupID, updates, callbackopt) → {Promise.<Object>}

Used to update or modify a group object API Endpoint: '/groups/:groupID' Method: PUT
Parameters:
Name Type Attributes Description
groupID string The ID of the group to update
updates Object Group fields to update
callback function <optional>
Passed the updated group object if successful, error otherwise
Source:
Returns:
A promise resolving to the updated group object
Type
Promise.<Object>

updateMembership(membershipID, options, callbackopt) → {Promise.<Object>}

Used to update or modify a group object API Endpoint: '/group_memberships/:membershipID' Method: PUT
Parameters:
Name Type Attributes Description
membershipID string The ID of the membership to update
options Object Membership record fields to update
callback function <optional>
Passed the updated membership object if successful, error otherwise
Source:
Returns:
A promise resolving to the updated membership object
Type
Promise.<Object>

updateMembership(membershipID, options, callbackopt) → {Promise.<Object>}

Used to update or modify a group object API Endpoint: '/group_memberships/:membershipID' Method: PUT
Parameters:
Name Type Attributes Description
membershipID string The ID of the membership to update
options Object Membership record fields to update
callback function <optional>
Passed the updated membership object if successful, error otherwise
Source:
Returns:
A promise resolving to the updated membership object
Type
Promise.<Object>