Multizones#598
Conversation
…AssignmentForTarget to return an entry as well as implemented helper function assign
|
Hi @carycheng, thanks for the pull request. Before we can merge it, we need you to sign our Contributor License Agreement. You can do so electronically here: http://opensource.box.com/cla Once you have signed, just add a comment to this pull request saying, "CLA signed". Thanks! |
| *[Get Assignment For Target](#get-assignment-for-target) | ||
| *[Update Existing Assignment](#update-existing-assignment) | ||
| *[Assign Storage Policy](#assign-storage-policy) | ||
| *[Delete Assignment](#delete-assignment) |
There was a problem hiding this comment.
You'll need a space between the asterisks and titles to make these actually turn into bullets
| BoxStoragePolicy.Info storagePolicyInfo = storagePolicy.getInfo(); | ||
| ``` | ||
|
|
||
| [get-info]: |
There was a problem hiding this comment.
These links still need to be filled in
| Get Storage Policy | ||
| ------------------ | ||
|
|
||
| Calling [`getInfo(String...)`][get-info] will return BoxStoragePolicy.Info object |
There was a problem hiding this comment.
We should add the parameter names to the method signatures in all of these
| Calling [`delete()`][delete] will remove the storage policy assignment from the user. | ||
|
|
||
| ```java | ||
| BoxStoragePolicyAssignment assignment = new BoxStoragePolicyAssignment(api, "user_1234"); |
There was a problem hiding this comment.
Since the MultiZones team is changing the IDs to be obfuscated, we should make the example match the real ID format (maybe just base64 encoded)
| /** | ||
| * Represents a BoxStoragePolicy. | ||
| */ | ||
| @BoxResourceType("BoxStoragePolicy") |
There was a problem hiding this comment.
I think the string in this annotation is supposed to be the Box type, e.g. "storage_policy"
| /** | ||
| * Represents a BoxStoragePolicyAssignment. | ||
| */ | ||
| @BoxResourceType("BoxStoragePolicyAssignment") |
There was a problem hiding this comment.
I think the string in this annotation is supposed to be the Box type, e.g. "storage_policy_assignment"
| BoxJSONResponse response = (BoxJSONResponse) request.send(); | ||
| return new Info(response.getJSON()); | ||
| } | ||
|
|
There was a problem hiding this comment.
We should probably also add an assign() method to this class, otherwise it's not very useful to have instances
| final String assignedToType = "user"; | ||
| final String assignedToID = "5678"; | ||
|
|
||
| final JsonObject fakeJSONResponse = JsonObject.readFrom("{\n" |
There was a problem hiding this comment.
These should be moved into fixtures to align with the new testing pattern
|
|
||
| @Test | ||
| @Category(IntegrationTest.class) | ||
| public void testAssignStoragePolicySucceeds() { |
| -------------------------- | ||
|
|
||
| Updating a storage policy assignment information is done by calling | ||
| [`updateInfo(BoxStoragePolicyAssignment.Info updatedInfo)`][update-info]. |
| Calling the static [`getAll(BoxAPIConnection api)`][get-list-of-storage-policies] | ||
| 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 ...)`][get-list-storage-policies-with-fields] method. |
There was a problem hiding this comment.
This link is broken, looks like it doesn't match the identifier below with the URL
| * @param userID the ID of the user you want to assign the Storage Policy to. | ||
| * @return information about this {@link BoxStoragePolicyAssignment}. | ||
| */ | ||
| public static BoxStoragePolicyAssignment.Info assign(BoxAPIConnection api, String storagePolicyID, String userID) { |
There was a problem hiding this comment.
There's already a static one of these on BoxStoragePolicyAssignment — this one should probably be an instance method
| public class BoxStoragePolicyAssignment extends BoxResource { | ||
|
|
||
| /** | ||
| * Storage PolicIES Assignment URL Template. |
There was a problem hiding this comment.
[nit] Strange capitalization in this comment
| /** | ||
| * The default limit for returning a storage policy info. | ||
| */ | ||
| private static final int STORAGE_POLICY_INFO_LIMIT = 1; |
|
|
||
| BoxStoragePolicyAssignment storagePolicyAssignment = new BoxStoragePolicyAssignment(api, | ||
| response.getJsonObject().get("entries").asArray().get(0).asObject().get("id").asString()); | ||
| BoxStoragePolicyAssignment.Info info = storagePolicyAssignment.new |
There was a problem hiding this comment.
This pattern is very yucky — we should try to eliminate this weirdness in the future
No description provided.