You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Andrew Gaul <no...@github.com> on 2016/05/28 20:36:45 UTC

[jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 initial object ops (#276)

Upload, download, and delete.
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds-labs/pull/276

-- Commit Summary --

  * JCLOUDS-1005: Backblaze B2 initial object ops

-- File Changes --

    M b2/src/main/java/org/jclouds/b2/B2Api.java (4)
    A b2/src/main/java/org/jclouds/b2/binders/UploadFileBinder.java (56)
    A b2/src/main/java/org/jclouds/b2/domain/B2Object.java (50)
    A b2/src/main/java/org/jclouds/b2/domain/DeleteFileResponse.java (32)
    A b2/src/main/java/org/jclouds/b2/domain/UploadFileResponse.java (40)
    A b2/src/main/java/org/jclouds/b2/domain/UploadUrlResponse.java (35)
    A b2/src/main/java/org/jclouds/b2/features/ObjectApi.java (107)
    A b2/src/main/java/org/jclouds/b2/filters/RequestAuthorizationDownload.java (64)
    A b2/src/main/java/org/jclouds/b2/functions/ParseB2ObjectFromResponse.java (58)
    M b2/src/main/java/org/jclouds/b2/handlers/ParseB2ErrorFromJsonContent.java (3)
    A b2/src/main/java/org/jclouds/b2/reference/B2Headers.java (36)
    A b2/src/test/java/org/jclouds/b2/features/ObjectApiLiveTest.java (157)
    A b2/src/test/java/org/jclouds/b2/features/ObjectApiMockTest.java (346)
    A b2/src/test/resources/delete_object_request.json (4)
    A b2/src/test/resources/delete_object_response.json (4)
    A b2/src/test/resources/get_upload_url_request.json (3)
    A b2/src/test/resources/get_upload_url_response.json (5)
    A b2/src/test/resources/upload_file_response.json (13)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/276.patch
https://github.com/jclouds/jclouds-labs/pull/276.diff

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +import org.jclouds.rest.annotations.MapBinder;
> +import org.jclouds.rest.annotations.PayloadParam;
> +import org.jclouds.rest.annotations.RequestFilters;
> +import org.jclouds.rest.annotations.ResponseParser;
> +import org.jclouds.rest.binders.BindToJsonPayload;
> +
> +@BlobScope(CONTAINER)
> +public interface ObjectApi {
> +   @Named("b2_get_upload_url")
> +   @POST
> +   @Path("/b2api/v1/b2_get_upload_url")
> +   @RequestFilters(RequestAuthorization.class)
> +   @MapBinder(BindToJsonPayload.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   UploadUrlResponse getUploadUrl(@PayloadParam("bucketId") String bucketId);

I'm not sure about this -- users will likely directly feed the result of `getUploadUrl` into `uploadFile`.  Throwing `ContainerNotFoundException` in the former gives more information that the `NullPointerException` from the latter.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r66385850

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +import org.jclouds.b2.domain.UploadUrlResponse;
> +import org.jclouds.b2.reference.B2Headers;
> +import org.jclouds.rest.MapBinder;
> +
> +import com.google.common.base.Preconditions;
> +import com.google.common.net.HttpHeaders;
> +import com.google.common.net.PercentEscaper;
> +
> +public final class UploadFileBinder implements MapBinder {
> +   public static final PercentEscaper escaper = new PercentEscaper("._-/~!$'()*;=:@", false);
> +
> +   @Override
> +   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
> +      UploadUrlResponse uploadUrl = (UploadUrlResponse) postParams.get("uploadUrl");
> +      B2Object b2Object = (B2Object) postParams.get("b2Object");
> +      Preconditions.checkArgument(b2Object.fileId() == null, "fileId must be null, was %s", b2Object.fileId());

Done.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r66389498

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +            expected = byteSource.openStream();
> +            assertThat(actual).hasContentEqualTo(expected);
> +         } finally {
> +            Closeables2.closeQuietly(expected);
> +            Closeables2.closeQuietly(actual);
> +         }
> +      } finally {
> +         if (uploadFile != null) {
> +            objectApi.deleteFileVersion(uploadFile.fileName(), uploadFile.fileId());
> +         }
> +         bucketApi.deleteBucket(response.bucketId());
> +      }
> +   }
> +
> +   @Test(groups = "live")
> +   public void testDownloadFileByNameNonExistent() throws Exception {

Removed.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r66381888

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
Addressed all outstanding review comments.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276#issuecomment-224812187

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +   @POST
> +   @Path("/b2api/v1/b2_delete_file_version")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   DeleteFileResponse deleteFileVersion(@PayloadParam("fileName") String fileName, @PayloadParam("fileId") String fileId);
> +
> +   @Named("b2_get_file_info")
> +   @POST
> +   @Path("/b2api/v1/b2_get_file_info")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   B2Object getFileInfo(@PayloadParam("fileId") String fileId);

Done.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r66384126

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +   @GET
> +   @Path("/b2api/v1/b2_list_file_names")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   B2ObjectList listFileNames(@PayloadParam("bucketId") String bucketId, @PayloadParam("startFileName") @Nullable String startFileName, @PayloadParam("maxFileCount") @Nullable Integer maxFileCount);
> +
> +   @Named("b2_list_file_versions")
> +   @GET
> +   @Path("/b2api/v1/b2_list_file_versions")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   B2ObjectList listFileVersions(@PayloadParam("bucketId") String bucketId, @PayloadParam("startFileId") @Nullable String startFileId, @PayloadParam("startFileName") @Nullable String startFileName, @PayloadParam("maxFileCount") @Nullable Integer maxFileCount);

Oddly, B2 returns 200 when issuing `listFileVersions` against an already-deleted bucket.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r66383547

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +   UploadUrlResponse getUploadUrl(@PayloadParam("bucketId") String bucketId);
> +
> +   @Named("b2_upload_file")
> +   @POST
> +   @MapBinder(UploadFileBinder.class)
> +   @Consumes(APPLICATION_JSON)
> +   UploadFileResponse uploadFile(@PayloadParam("uploadUrl") UploadUrlResponse uploadUrl, @PayloadParam("b2Object") B2Object b2Object);
> +
> +   @Named("b2_delete_file_version")
> +   @POST
> +   @Path("/b2api/v1/b2_delete_file_version")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   DeleteFileResponse deleteFileVersion(@PayloadParam("fileName") String fileName, @PayloadParam("fileId") String fileId);

I changed `ParseB2ErrorFromJsonContent` to throw `KeyNotFoundException` -- what do you think?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r66383342

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
Closed #276.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276#event-688794065

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
+1!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276#issuecomment-225118489

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +         assertThat(b2Object.payload().getContentMetadata().getContentLength()).isEqualTo(PAYLOAD.length());
> +         assertThat(b2Object.payload().getContentMetadata().getContentType()).isEqualTo(CONTENT_TYPE);
> +
> +         assertThat(server.getRequestCount()).isEqualTo(2);
> +
> +         RecordedRequest request = server.takeRequest();
> +         assertThat(request.getMethod()).isEqualTo("GET");
> +         assertThat(request.getPath()).isEqualTo("/b2api/v1/b2_authorize_account");
> +
> +         request = server.takeRequest();
> +         assertThat(request.getMethod()).isEqualTo("GET");
> +         assertThat(request.getPath()).isEqualTo("/file/BUCKET_NAME/typing_test.txt");
> +      } finally {
> +         server.shutdown();
> +      }
> +   }

Add mock tests for the download methods that declare fallbacks.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65692065

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +   @POST
> +   @Path("/b2api/v1/b2_delete_file_version")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   DeleteFileResponse deleteFileVersion(@PayloadParam("fileName") String fileName, @PayloadParam("fileId") String fileId);
> +
> +   @Named("b2_get_file_info")
> +   @POST
> +   @Path("/b2api/v1/b2_get_file_info")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   B2Object getFileInfo(@PayloadParam("fileId") String fileId);

Does it make sense to add a null fallback on a 404?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65691909

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +import com.google.auto.value.AutoValue;
> +
> +@AutoValue
> +public abstract class UploadFileResponse {
> +   public abstract String fileId();
> +   public abstract String fileName();
> +   public abstract String accountId();
> +   public abstract String bucketId();
> +   public abstract long contentLength();
> +   public abstract String contentSha1();
> +   public abstract String contentType();
> +   public abstract Map<String, String> fileInfo();
> +
> +   @SerializedNames({"fileId", "fileName", "accountId", "bucketId", "contentLength", "contentSha1", "contentType", "fileInfo"})
> +   public static UploadFileResponse create(String fileId, String fileName, String accountId, String bucketId, long contentLength, String contentSha1, String contentType, Map<String, String> fileInfo) {
> +      return new AutoValue_UploadFileResponse(fileId, fileName, accountId, bucketId, contentLength, contentSha1, contentType, fileInfo);

Done.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65822788

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Zack Shoylev <no...@github.com>.
Looks good to me!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276#issuecomment-224977317

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +
> +   public static B2Object create(String fileName, String contentSha1, Map<String, String> fileInfo, @Nullable Payload payload) {
> +      return createResponse(null, fileName, contentSha1, fileInfo, payload, null);
> +   }
> +
> +   /** Create a response to a request.  Most external callers should call create. */
> +   public static B2Object createResponse(@Nullable String fileId, String fileName, String contentSha1, Map<String, String> fileInfo, @Nullable Payload payload, @Nullable Date uploadTimestamp) {
> +      Preconditions.checkArgument(contentSha1.length() == Hashing.sha1().bits() / 4,
> +            "Expected hash length of %s, was: %s", Hashing.sha1().bits() / 4, contentSha1.length());
> +      return new AutoValue_B2Object(fileId, fileName, contentSha1, fileInfo, payload, uploadTimestamp, null, null, null, null, null);
> +   }
> +
> +   @SerializedNames({"fileId", "fileName", "accountId", "bucketId", "contentLength", "contentSha1", "contentType", "fileInfo", "action", "uploadTimestamp", "payload"})
> +   public static B2Object createHeadResponse(String fileId, String fileName, String accountId, String bucketId, long contentLength, String contentSha1, String contentType, Map<String, String> fileInfo, Action action, long uploadTimestamp, @Nullable Payload payload) {
> +      return new AutoValue_B2Object(fileId, fileName, contentSha1, fileInfo, null, new Date(uploadTimestamp), action, accountId, bucketId, contentLength, contentType);
> +   }

In all factory methods, enforce immutable collections. Use ImmutableMap.copyOf for fileInfo.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65691186

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Zack Shoylev <no...@github.com>.
> +import org.jclouds.b2.domain.UploadUrlResponse;
> +import org.jclouds.b2.reference.B2Headers;
> +import org.jclouds.rest.MapBinder;
> +
> +import com.google.common.base.Preconditions;
> +import com.google.common.net.HttpHeaders;
> +import com.google.common.net.PercentEscaper;
> +
> +public final class UploadFileBinder implements MapBinder {
> +   public static final PercentEscaper escaper = new PercentEscaper("._-/~!$'()*;=:@", false);
> +
> +   @Override
> +   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
> +      UploadUrlResponse uploadUrl = (UploadUrlResponse) postParams.get("uploadUrl");
> +      B2Object b2Object = (B2Object) postParams.get("b2Object");
> +      Preconditions.checkArgument(b2Object.fileId() == null, "fileId must be null, was %s", b2Object.fileId());

One way we handle this (in Openstack providers) if to have 2 separate classes, one that is used to create an object, and one that is used when reading an object. Thus fields that can only be used for updating or reading cannot be specified incorrectly. AutoValue makes it easier to implement - you implement a regular autovalue for the "read" version of the class, and you implement an AutoValue with an AutoValue builder for the create/update (update could  be a separate class as well).

I also think that doing client-side validation checks is largely empty work and removing them helps to (sometimes completely) eliminate binders and mappers.

Thoughts?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65642740

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +import org.jclouds.rest.annotations.MapBinder;
> +import org.jclouds.rest.annotations.PayloadParam;
> +import org.jclouds.rest.annotations.RequestFilters;
> +import org.jclouds.rest.annotations.ResponseParser;
> +import org.jclouds.rest.binders.BindToJsonPayload;
> +
> +@BlobScope(CONTAINER)
> +public interface ObjectApi {
> +   @Named("b2_get_upload_url")
> +   @POST
> +   @Path("/b2api/v1/b2_get_upload_url")
> +   @RequestFilters(RequestAuthorization.class)
> +   @MapBinder(BindToJsonPayload.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   UploadUrlResponse getUploadUrl(@PayloadParam("bucketId") String bucketId);

Does it make sense to add a null fallback on a 404?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65691920

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +            expected = byteSource.openStream();
> +            assertThat(actual).hasContentEqualTo(expected);
> +         } finally {
> +            Closeables2.closeQuietly(expected);
> +            Closeables2.closeQuietly(actual);
> +         }
> +      } finally {
> +         if (uploadFile != null) {
> +            objectApi.deleteFileVersion(uploadFile.fileName(), uploadFile.fileId());
> +         }
> +         bucketApi.deleteBucket(response.bucketId());
> +      }
> +   }
> +
> +   @Test(groups = "live")
> +   public void testDownloadFileByNameNonExistent() throws Exception {

In general, I don't think we need to "live" test stuff like this. We are creating unnecessary resources just to validate a jclouds behavior that does not give us any value of "how aligned with the provider api we are". The purpose of this test is to verify that we propagate and exception, and that is alreaydy covered in the mock tests.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65691650

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +   @GET
> +   @Path("/b2api/v1/b2_list_file_names")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   B2ObjectList listFileNames(@PayloadParam("bucketId") String bucketId, @PayloadParam("startFileName") @Nullable String startFileName, @PayloadParam("maxFileCount") @Nullable Integer maxFileCount);
> +
> +   @Named("b2_list_file_versions")
> +   @GET
> +   @Path("/b2api/v1/b2_list_file_versions")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   B2ObjectList listFileVersions(@PayloadParam("bucketId") String bucketId, @PayloadParam("startFileId") @Nullable String startFileId, @PayloadParam("startFileName") @Nullable String startFileName, @PayloadParam("maxFileCount") @Nullable Integer maxFileCount);

Does it make sense to add a null fallback on 404 for these list methods?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65691856

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
This looks great @andrewgaul! Just a few minor comments :)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276#issuecomment-223554189

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +
> +   public static B2Object create(String fileName, String contentSha1, Map<String, String> fileInfo, @Nullable Payload payload) {
> +      return createResponse(null, fileName, contentSha1, fileInfo, payload, null);
> +   }
> +
> +   /** Create a response to a request.  Most external callers should call create. */
> +   public static B2Object createResponse(@Nullable String fileId, String fileName, String contentSha1, Map<String, String> fileInfo, @Nullable Payload payload, @Nullable Date uploadTimestamp) {
> +      Preconditions.checkArgument(contentSha1.length() == Hashing.sha1().bits() / 4,
> +            "Expected hash length of %s, was: %s", Hashing.sha1().bits() / 4, contentSha1.length());
> +      return new AutoValue_B2Object(fileId, fileName, contentSha1, fileInfo, payload, uploadTimestamp, null, null, null, null, null);
> +   }
> +
> +   @SerializedNames({"fileId", "fileName", "accountId", "bucketId", "contentLength", "contentSha1", "contentType", "fileInfo", "action", "uploadTimestamp", "payload"})
> +   public static B2Object createHeadResponse(String fileId, String fileName, String accountId, String bucketId, long contentLength, String contentSha1, String contentType, Map<String, String> fileInfo, Action action, long uploadTimestamp, @Nullable Payload payload) {
> +      return new AutoValue_B2Object(fileId, fileName, contentSha1, fileInfo, null, new Date(uploadTimestamp), action, accountId, bucketId, contentLength, contentType);
> +   }

Done.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65822774

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
Updated with all object operations.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276#issuecomment-222721086

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Andrew Gaul <no...@github.com>.
> +         assertThat(b2Object.payload().getContentMetadata().getContentLength()).isEqualTo(PAYLOAD.length());
> +         assertThat(b2Object.payload().getContentMetadata().getContentType()).isEqualTo(CONTENT_TYPE);
> +
> +         assertThat(server.getRequestCount()).isEqualTo(2);
> +
> +         RecordedRequest request = server.takeRequest();
> +         assertThat(request.getMethod()).isEqualTo("GET");
> +         assertThat(request.getPath()).isEqualTo("/b2api/v1/b2_authorize_account");
> +
> +         request = server.takeRequest();
> +         assertThat(request.getMethod()).isEqualTo("GET");
> +         assertThat(request.getPath()).isEqualTo("/file/BUCKET_NAME/typing_test.txt");
> +      } finally {
> +         server.shutdown();
> +      }
> +   }

Done.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r66384570

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +   UploadUrlResponse getUploadUrl(@PayloadParam("bucketId") String bucketId);
> +
> +   @Named("b2_upload_file")
> +   @POST
> +   @MapBinder(UploadFileBinder.class)
> +   @Consumes(APPLICATION_JSON)
> +   UploadFileResponse uploadFile(@PayloadParam("uploadUrl") UploadUrlResponse uploadUrl, @PayloadParam("b2Object") B2Object b2Object);
> +
> +   @Named("b2_delete_file_version")
> +   @POST
> +   @Path("/b2api/v1/b2_delete_file_version")
> +   @MapBinder(BindToJsonPayload.class)
> +   @RequestFilters(RequestAuthorization.class)
> +   @Consumes(APPLICATION_JSON)
> +   @Produces(APPLICATION_JSON)
> +   DeleteFileResponse deleteFileVersion(@PayloadParam("fileName") String fileName, @PayloadParam("fileId") String fileId);

Does it make sense to add a null fallback on a 404?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65691901

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 object operations (#276)

Posted by Ignasi Barrera <no...@github.com>.
> +import com.google.auto.value.AutoValue;
> +
> +@AutoValue
> +public abstract class UploadFileResponse {
> +   public abstract String fileId();
> +   public abstract String fileName();
> +   public abstract String accountId();
> +   public abstract String bucketId();
> +   public abstract long contentLength();
> +   public abstract String contentSha1();
> +   public abstract String contentType();
> +   public abstract Map<String, String> fileInfo();
> +
> +   @SerializedNames({"fileId", "fileName", "accountId", "bucketId", "contentLength", "contentSha1", "contentType", "fileInfo"})
> +   public static UploadFileResponse create(String fileId, String fileName, String accountId, String bucketId, long contentLength, String contentSha1, String contentType, Map<String, String> fileInfo) {
> +      return new AutoValue_UploadFileResponse(fileId, fileName, accountId, bucketId, contentLength, contentSha1, contentType, fileInfo);

Immutable fileinfo

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/276/files/d27eef19e1ef39d560170786aa7a9ef1f711b71b#r65691238