Storage policies allow enterprise administrators to choose where their content is physically stored; different policies can be purchased and assigned either as the default policy for the entire enterprise or on a per-user basis.
To get a list of the storage policies that are available for the current user's enterprise,
call the storagePolicies.getAll(options, callback)
method.
client.storagePolicies.getAll()
.then(policies => {
/* policies -> {
next_marker: null,
limit: 1000,
entries:
[ { type: 'storage_policy', id: '42', name: 'Montreal / Dublin' },
{ type: 'storage_policy', id: '126', name: 'Frankfurt / Dublin' },
{ type: 'storage_policy', id: '162', name: 'US' } ] }
*/
});
Information about a specific storage policy (by its ID) can be retrieved by calling
the storagePolicies.get(storagePolicyID, options, callback)
method with the
ID of the assignment object.
client.storagePolicies.get('6')
.then(storagePolicy => {
/* storagePolicy -> {
type: 'storage_policy',
id: '6',
name: 'Tokyo & Singapore' }
*/
});
To assign a storage policy to a user, call the storagePolicies.assign(storagePolicyID, userID, callback)
method with the ID of the storage policy to assign and the ID of the user to which it should be assigned.
Note: This method will check if an assignment already exists for the user and take appropriate action. It should work regardless of the current status of the user.
var storagePolicyID = '7';
var userID = '22222';
client.storagePolicies.assign(storagePolicyID, userID)
.then(assignment => {
/* assignment -> {
type: 'storage_policy_assignment',
id: 'dXNlcl8yMjIyMg==',
storage_policy: 'storage_policy', id: '7' },
assigned_to: { type: 'user', id: '22222' } }
*/
});
To get information about a specific storage policy assignment by ID, call the
storagePolicies.getAssignment(asisgnmentID, callback)
method
with the ID of the storage policy assignment.
client.storagePolicies.getAssignment('dXNlcl8yMjIyMg==')
.then(assignment => {
/* assignment -> {
type: 'storage_policy_assignment',
id: 'dXNlcl8yMjIyMg==',
storage_policy: 'storage_policy', id: '7' },
assigned_to: { type: 'user', id: '22222' } }
*/
});
To determine which storage policy is assigned to a user, call
storagePolicies.getAssignmentForTarget(userID, callback)
with the ID of the user.
client.storagePolicies.getAssignmentForTarget('22222')
.then(assignment => {
/* assignment -> {
type: 'storage_policy_assignment',
id: 'dXNlcl8yMjIyMg==',
storage_policy: 'storage_policy', id: '7' },
assigned_to: { type: 'user', id: '22222' } }
*/
});
To create a new storage policy assignment, call the
storagePolicies.createAssignment(policyID, userID, callback)
method
with the ID of the storage policy to assign and the ID of the user to assign it to.
Note: This method only works if the user does not already have an assignment. If the current state of the user is not known, use the
storagePolicies.assign()
method instead.
client.storagePolicies.createAssignment('7', '22222')
.then(assignment => {
/* assignment -> {
type: 'storage_policy_assignment',
id: 'dXNlcl8yMjIyMg==',
storage_policy: 'storage_policy', id: '7' },
assigned_to: { type: 'user', id: '22222' } }
*/
});
To update a storage policy assignment, for example to update which storage policy is
asisgned to a user, call the storagePolicies.updateAssignment(assignmentID, updates, callback)
method with the ID of the assignment to update and an object containing key/value mapping of fields
to update on the assignment.
// Reassign user 22222 to storage policy 10
var assignmentID = 'dXNlcl8yMjIyMg==';
var updates = {
storage_policy: {
type: 'storage_policy',
id: '10'
}
};
client.storagePolicies.updateAssignment(assignmentID, updates)
.then(updatedAssignment => {
/* updatedAssignment -> {
type: 'storage_policy_assignment',
id: 'dXNlcl8yMjIyMg==',
storage_policy: 'storage_policy', id: '10' },
assigned_to: { type: 'user', id: '22222' } }
*/
});
To remove a storage policy assignment and return the user it was assigned to to the
default storage policy for the enterprise, call
storagePolicies.removeAssignment(assignmentID, callback)
with
the ID of the assignment to remove.
client.storagePolicies.removeAssignment('dXNlcl8yMjIyMg==')
.then(() => {
// deletion succeeded — no value returned
});