Skip to content

Latest commit

 

History

History
132 lines (96 loc) · 5.52 KB

storage_policy.md

File metadata and controls

132 lines (96 loc) · 5.52 KB

Storage Policy

Allows the enterprise admin to manage the Storage Policies for users in their enterprise. Used for an enterprise to decide storage location for users based on where they work/reside.

Get Storage Policy

Calling getInfo(String fields ...) will return BoxStoragePolicy.Info object containing information about the storage policy. If necessary to retrieve limited set of fields. It is possible to specify them using param.

BoxStoragePolicy storagePolicy = new BoxStoragePolicy(api, id);
BoxStoragePolicy.Info storagePolicyInfo = storagePolicy.getInfo();

Get List of Storage Policies

Calling the static getAll(BoxAPIConnection api) will return an iterable that will page through all of the storage policies. It is possible to specify maximum number of items per response and fields to retrieve by calling the static getAll(BoxAPIConnection api, int limit, String fields ...) method.

Iterable<BoxStoragePolicy.Info> storagePolicies = BoxStoragePolicy.getAll(api);
for (BoxStoragePolicy.Info storagePolicyInfo : storagePolicies) {
        //Do something with the storage policy.
}

Create New Assignment

To create new storage policy assignment call create(BoxAPIConnection api, String policyID, String userID) method.

BoxStoragePolicyAssignment.Info assignmentInfo = BoxStoragePolicyAssignment.create(api, policyID, userID);

Update Existing Assignment

Updating a storage policy assignment information is done by calling updateInfo(BoxStoragePolicyAssignment.Info updatedInfo).

BoxStoragePolicyAssignment storagePolicyAssignment = new BoxStoragePolicyAssignment(api, "ASSIGNMENT_ID");
BoxStoragePolicyAssignment.Info assignmentInfo = storagePolicyAssignment.new Info();
assignmentInfo.setStoragePolicyID("NEW_STORAGE_POLICY_ID");
storagePolicyAssignment.updateInfo(assignmentInfo);

Get Assignment

Calling getInfo(String fields ...) will return a BoxStoragePolicyAssignment.Info object containing information about the storage policy assignment.

BoxStoragePolicyAssignment storagePolicyAssignment = new BoxStoragePolicyAssignment(api, id);
BoxStoragePolicyAssignment.Info assignmentInfo = storagePolicyAssignment.getInfo();

Get Assignment for Target

Calling getAssignmentForTarget(BoxAPIConnection api, String resolvedForType, String resolvedForID) will return a BoxStorageAssignment.Info object containing information about the storage policy assignment.

BoxStoragePolicyAssignment.Info assignmentInfo = BoxStoragePolicyAssignment.getAssignmentForTarget(api, "user", "1234")

Assign Storage Policy

Calling assign(BoxAPIConnection api, String storagePolicyID, String userID) will check if this user already has storage policy assigned to them. If not then a new this user will be assigned the specified storage policy.

BoxStoragePolicyAssignment.Info assignmentInfo = BoxStoragePolicyAssignment.assign(api, "1234", "5678");

Delete Assignment

Calling delete() will remove the storage policy assignment from the user.

BoxStoragePolicyAssignment assignment = new BoxStoragePolicyAssignment(api, "dXNlcl8xMjM0");
assignment.delete();