Fix #26: Implement application keys#27
Conversation
Testing: - unit tests
Testing: - unit tests
Testing: - unit tests
This avoids overloading B2ApplicationKey. Testing: - unit tests
Testing: - unit tests
Add example to B2Sample. Testing: - ran B2Sample against staging
Testing: - unit tests - B2Sample (staging)
Testing: - unit tests - B2Sample (staging)
certainmagic
left a comment
There was a problem hiding this comment.
thanks for the change, BrianB.
i've made a few minor nitpicks.
i think there are two things we should discuss:
-
the compatibility implications of using an enum for the Capabilities.
-
when to merge this PR. generally, i wait until the features are supported by the server before putting the changes into master.
we can chat outside the review system. :)
| import java.util.Iterator; | ||
|
|
||
| /** | ||
| * This interface collects the APIs we provide on our B2FileVersion iterables. |
| import java.util.TreeSet; | ||
|
|
||
| /** | ||
| * Response from b2_create_key and b2_delete_key. Included in response from b2_list_keys. |
There was a problem hiding this comment.
"Response from b2_create_key". i think that comment is a little out-of-date. I think you're returning a B2CreatedApplicationKey from b2_create_key now. :)
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public enum B2Capability { |
There was a problem hiding this comment.
i'm a big fan of having strong typing when we can and enums are better for that than strings. With that said...please read the "DESIGN NOTE" comment about compatibility in B2BucketTypes.java and then let's talk. :)
| private final String bucketId; | ||
| private final String namePrefix; | ||
|
|
||
| private B2CreateKeyRequest(Set<B2Capability> capabilies, |
| import java.util.Objects; | ||
| import java.util.TreeSet; | ||
|
|
||
| public class B2CreatedApplicationKey { |
There was a problem hiding this comment.
maybe comment that this is what's returned from b2_create_key and that it differs from the other version in that it has the secret (like your nice comment below for toApplicationKey()).
|
|
||
| bigHeader(writer, "delete application key"); | ||
| { | ||
| client.deleteKey(B2DeleteKeyRequest.builder(applicationKeyId).build()); |
There was a problem hiding this comment.
you're welcome to add a convenience "deleteKey(String appKeyId)" method to the storage client interface which would create the request and call the real method in the interface.
|
Thanks. I agree about enum/string. I'll change to string.
As for when to merge, I think Marj needs the updated SDK to build the UI.
- BrianB
… On Mar 30, 2018, at 06:33, certainmagic ***@***.***> wrote:
@certainmagic commented on this pull request.
thanks for the change, BrianB.
i've made a few minor nitpicks.
i think there are two things we should discuss:
the compatibility implications of using an enum for the Capabilities.
when to merge this PR. generally, i wait until the features are supported by the server before putting the changes into master.
we can chat outside the review system. :)
In core/src/main/java/com/backblaze/b2/client/B2ListKeysIterable.java <#27 (comment)>:
> @@ -0,0 +1,32 @@
+/*
+ * Copyright 2018, Backblaze Inc. All Rights Reserved.
+ * License https://www.backblaze.com/using_b2_code.html
+ */
+
+package com.backblaze.b2.client;
+
+import com.backblaze.b2.client.structures.B2ApplicationKey;
+import com.backblaze.b2.client.structures.B2ListKeysRequest;
+
+import java.util.Iterator;
+
+/**
+ * This interface collects the APIs we provide on our B2FileVersion iterables.
"B2FileVersion"? :)
In core/src/main/java/com/backblaze/b2/client/structures/B2ApplicationKey.java <#27 (comment)>:
> @@ -0,0 +1,124 @@
+/*
+ * Copyright 2018, Backblaze Inc. All Rights Reserved.
+ * License https://www.backblaze.com/using_b2_code.html
+ */
+
+package com.backblaze.b2.client.structures;
+
+import com.backblaze.b2.json.B2Json;
+
+import java.util.Objects;
+import java.util.TreeSet;
+
+/**
+ * Response from b2_create_key and b2_delete_key. Included in response from b2_list_keys.
"Response from b2_create_key". i think that comment is a little out-of-date. I think you're returning a B2CreatedApplicationKey from b2_create_key now. :)
In core/src/main/java/com/backblaze/b2/client/structures/B2Capability.java <#27 (comment)>:
> + * License https://www.backblaze.com/using_b2_code.html
+ */
+
+package com.backblaze.b2.client.structures;
+
+import com.backblaze.b2.json.B2JsonException;
+import com.backblaze.b2.json.B2JsonReader;
+import com.backblaze.b2.json.B2JsonTypeHandler;
+import com.backblaze.b2.json.B2JsonWriter;
+import com.backblaze.b2.util.B2StringUtil;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public enum B2Capability {
i'm a big fan of having strong typing when we can and enums are better for that than strings. With that said...please read the "DESIGN NOTE" comment about compatibility in B2BucketTypes.java and then let's talk. :)
In core/src/main/java/com/backblaze/b2/client/structures/B2CreateKeyRequest.java <#27 (comment)>:
> +package com.backblaze.b2.client.structures;
+
+import com.backblaze.b2.json.B2Json;
+
+import java.util.Objects;
+import java.util.Set;
+
+public class B2CreateKeyRequest {
+
+ private final Set<B2Capability> capabilies;
+ private final String keyName;
+ private final Long validDurationSeconds;
+ private final String bucketId;
+ private final String namePrefix;
+
+ private B2CreateKeyRequest(Set<B2Capability> capabilies,
"capabilies" :)
In core/src/main/java/com/backblaze/b2/client/structures/B2CreatedApplicationKey.java <#27 (comment)>:
> @@ -0,0 +1,149 @@
+/*
+ * Copyright 2018, Backblaze Inc. All Rights Reserved.
+ * License https://www.backblaze.com/using_b2_code.html
+ */
+
+package com.backblaze.b2.client.structures;
+
+import com.backblaze.b2.json.B2Json;
+
+import java.util.Objects;
+import java.util.TreeSet;
+
+public class B2CreatedApplicationKey {
maybe comment that this is what's returned from b2_create_key and that it differs from the other version in that it has the secret (like your nice comment below for toApplicationKey()).
In samples/src/main/java/com/backblaze/b2/sample/B2Sample.java <#27 (comment)>:
> + final B2CreatedApplicationKey applicationKey =
+ client.createKey(
+ B2CreateKeyRequest.builder(capabilities, "testKey").build()
+ );
+ applicationKeyId = applicationKey.getApplicationKeyId();
+ writer.println("key id: " + applicationKey.getApplicationKeyId() + " key: " + applicationKey.getApplicationKey());
+ }
+
+ bigHeader(writer, "list application keys");
+ for (B2ApplicationKey key : client.applicationKeys()) {
+ writer.println("key id: " + key.getApplicationKeyId() + " capabilities: " + key.getCapabilities());
+ }
+
+ bigHeader(writer, "delete application key");
+ {
+ client.deleteKey(B2DeleteKeyRequest.builder(applicationKeyId).build());
you're welcome to add a convenience "deleteKey(String appKeyId)" method to the storage client interface which would create the request and call the real method in the interface.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#27 (review)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAk2WzUoR-QyfnsnpXG64r6q0rN0b0KLks5tjl5CgaJpZM4TBMsA>.
|
|
We can use the new sdk without putting it in master.
On Fri, Mar 30, 2018 at 10:19 AM, Brian Beach <notifications@github.com>
wrote:
… Thanks. I agree about enum/string. I'll change to string.
As for when to merge, I think Marj needs the updated SDK to build the UI.
- BrianB
> On Mar 30, 2018, at 06:33, certainmagic ***@***.***>
wrote:
>
> @certainmagic commented on this pull request.
>
> thanks for the change, BrianB.
> i've made a few minor nitpicks.
>
> i think there are two things we should discuss:
>
> the compatibility implications of using an enum for the Capabilities.
>
> when to merge this PR. generally, i wait until the features are
supported by the server before putting the changes into master.
>
> we can chat outside the review system. :)
>
> In core/src/main/java/com/backblaze/b2/client/B2ListKeysIterable.java <
#27 (comment)>:
>
> > @@ -0,0 +1,32 @@
> +/*
> + * Copyright 2018, Backblaze Inc. All Rights Reserved.
> + * License https://www.backblaze.com/using_b2_code.html
> + */
> +
> +package com.backblaze.b2.client;
> +
> +import com.backblaze.b2.client.structures.B2ApplicationKey;
> +import com.backblaze.b2.client.structures.B2ListKeysRequest;
> +
> +import java.util.Iterator;
> +
> +/**
> + * This interface collects the APIs we provide on our B2FileVersion
iterables.
> "B2FileVersion"? :)
>
> In core/src/main/java/com/backblaze/b2/client/
structures/B2ApplicationKey.java <https://github.com/Backblaze/
b2-sdk-java/pull/27#discussion_r178319731>:
>
> > @@ -0,0 +1,124 @@
> +/*
> + * Copyright 2018, Backblaze Inc. All Rights Reserved.
> + * License https://www.backblaze.com/using_b2_code.html
> + */
> +
> +package com.backblaze.b2.client.structures;
> +
> +import com.backblaze.b2.json.B2Json;
> +
> +import java.util.Objects;
> +import java.util.TreeSet;
> +
> +/**
> + * Response from b2_create_key and b2_delete_key. Included in response
from b2_list_keys.
> "Response from b2_create_key". i think that comment is a little
out-of-date. I think you're returning a B2CreatedApplicationKey from
b2_create_key now. :)
>
> In core/src/main/java/com/backblaze/b2/client/structures/B2Capability.java
<#27 (comment)>:
>
> > + * License https://www.backblaze.com/using_b2_code.html
> + */
> +
> +package com.backblaze.b2.client.structures;
> +
> +import com.backblaze.b2.json.B2JsonException;
> +import com.backblaze.b2.json.B2JsonReader;
> +import com.backblaze.b2.json.B2JsonTypeHandler;
> +import com.backblaze.b2.json.B2JsonWriter;
> +import com.backblaze.b2.util.B2StringUtil;
> +
> +import java.io.IOException;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +public enum B2Capability {
> i'm a big fan of having strong typing when we can and enums are better
for that than strings. With that said...please read the "DESIGN NOTE"
comment about compatibility in B2BucketTypes.java and then let's talk. :)
>
> In core/src/main/java/com/backblaze/b2/client/
structures/B2CreateKeyRequest.java <https://github.com/Backblaze/
b2-sdk-java/pull/27#discussion_r178320791>:
>
> > +package com.backblaze.b2.client.structures;
> +
> +import com.backblaze.b2.json.B2Json;
> +
> +import java.util.Objects;
> +import java.util.Set;
> +
> +public class B2CreateKeyRequest {
> +
> + private final Set<B2Capability> capabilies;
> + private final String keyName;
> + private final Long validDurationSeconds;
> + private final String bucketId;
> + private final String namePrefix;
> +
> + private B2CreateKeyRequest(Set<B2Capability> capabilies,
> "capabilies" :)
>
> In core/src/main/java/com/backblaze/b2/client/structures/B2CreatedApplicationKey.java
<#27 (comment)>:
>
> > @@ -0,0 +1,149 @@
> +/*
> + * Copyright 2018, Backblaze Inc. All Rights Reserved.
> + * License https://www.backblaze.com/using_b2_code.html
> + */
> +
> +package com.backblaze.b2.client.structures;
> +
> +import com.backblaze.b2.json.B2Json;
> +
> +import java.util.Objects;
> +import java.util.TreeSet;
> +
> +public class B2CreatedApplicationKey {
> maybe comment that this is what's returned from b2_create_key and that
it differs from the other version in that it has the secret (like your nice
comment below for toApplicationKey()).
>
> In samples/src/main/java/com/backblaze/b2/sample/B2Sample.java <
#27 (comment)>:
>
> > + final B2CreatedApplicationKey applicationKey =
> + client.createKey(
> + B2CreateKeyRequest.builder(capabilities, "testKey").build()
> + );
> + applicationKeyId = applicationKey.getApplicationKeyId();
> + writer.println("key id: " + applicationKey.getApplicationKeyId() + "
key: " + applicationKey.getApplicationKey());
> + }
> +
> + bigHeader(writer, "list application keys");
> + for (B2ApplicationKey key : client.applicationKeys()) {
> + writer.println("key id: " + key.getApplicationKeyId() + "
capabilities: " + key.getCapabilities());
> + }
> +
> + bigHeader(writer, "delete application key");
> + {
> + client.deleteKey(B2DeleteKeyRequest.builder(
applicationKeyId).build());
> you're welcome to add a convenience "deleteKey(String appKeyId)" method
to the storage client interface which would create the request and call the
real method in the interface.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub <
#27#
pullrequestreview-108365242>, or mute the thread <https://github.com/
notifications/unsubscribe-auth/AAk2WzUoR-QyfnsnpXG64r6q0rN0b0KLks5tjl5C
gaJpZM4TBMsA>.
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE6SipGzgzMbmCQiRsEGFRiOIvTxR3I1ks5tjmkFgaJpZM4TBMsA>
.
|
This is everything except converting the B2Capability enum to string constants.
This is for compatibility with future extensions. Testing: - unit tests - B2Sample (staging)
.. and IDEA had the comment collapsed so it wasn't visible. :-(
it was missing the "In". i also fixed a similarish misspelling in a local variable for get_download_authorization. i also added a call to setup the clock as a simulator in a test. without that change the clock was being created as a real clock, not a simulator by that test and it was messing up other tests that expected it to be a clock simulator. (there could be more of these, but this is the one i found.) built & tested with "./gradlew build javadoc writeNewPom". i also ran the sample. as expected, it failed because the servers are currently expecting the misspelling. i commented that section of the sample out and everything else succeeded.
Keep branch up-to-date, so this PR is ready when the app keys feature goes live.
|
I'm going to merge this to master even though the API isn't fully supported in the service yet. I'll add a note to the README. |
* add B2StoreLargeFileRequest class * add SSE capability to large file uploads * clean up IntelliJ IDEA warnings Co-authored-by: Eric Ding <eding@backblaze.com>
This PR adds fileLockEnabled parameter to B2UpdateBucketRequest
No description provided.