JCLOUDS-1452: Switch to B2 v2 API

Some cleanups but no major changes:

https://www.backblaze.com/blog/backblaze-b2-api-version-2-beta-is-now-open/
This commit is contained in:
Andrew Gaul 2018-09-28 08:58:38 -07:00
parent d621edd79f
commit ce163f3498
11 changed files with 57 additions and 57 deletions

View File

@ -30,7 +30,7 @@ import org.jclouds.rest.annotations.RequestFilters;
public interface AuthorizationApi { public interface AuthorizationApi {
@Named("b2_authorize_account") @Named("b2_authorize_account")
@GET @GET
@Path("/b2api/v1/b2_authorize_account") @Path("/b2api/v2/b2_authorize_account")
@RequestFilters(BasicAuthentication.class) @RequestFilters(BasicAuthentication.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
Authorization authorizeAccount(); Authorization authorizeAccount();

View File

@ -46,14 +46,14 @@ import org.jclouds.rest.binders.BindToJsonPayload;
public interface BucketApi { public interface BucketApi {
@Named("b2_create_bucket") @Named("b2_create_bucket")
@POST @POST
@Path("/b2api/v1/b2_create_bucket") @Path("/b2api/v2/b2_create_bucket")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"}) @PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"})
Bucket createBucket(@PayloadParam("bucketName") String bucketName, @PayloadParam("bucketType") BucketType bucketType); Bucket createBucket(@PayloadParam("bucketName") String bucketName, @PayloadParam("bucketType") BucketType bucketType);
@Named("b2_delete_bucket") @Named("b2_delete_bucket")
@POST @POST
@Path("/b2api/v1/b2_delete_bucket") @Path("/b2api/v2/b2_delete_bucket")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"}) @PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"})
@Fallback(NullOnNotFoundOr404.class) @Fallback(NullOnNotFoundOr404.class)
@ -61,14 +61,14 @@ public interface BucketApi {
@Named("b2_update_bucket") @Named("b2_update_bucket")
@POST @POST
@Path("/b2api/v1/b2_update_bucket") @Path("/b2api/v2/b2_update_bucket")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"}) @PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"})
Bucket updateBucket(@PayloadParam("bucketId") String bucketId, @PayloadParam("bucketType") BucketType bucketType); Bucket updateBucket(@PayloadParam("bucketId") String bucketId, @PayloadParam("bucketType") BucketType bucketType);
@Named("b2_list_buckets") @Named("b2_list_buckets")
@POST @POST
@Path("/b2api/v1/b2_list_buckets") @Path("/b2api/v2/b2_list_buckets")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"}) @PayloadParams(keys = {"accountId"}, values = {"{jclouds.identity}"})
BucketList listBuckets(); BucketList listBuckets();

View File

@ -51,7 +51,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
public interface MultipartApi { public interface MultipartApi {
@Named("b2_start_large_file") @Named("b2_start_large_file")
@POST @POST
@Path("/b2api/v1/b2_start_large_file") @Path("/b2api/v2/b2_start_large_file")
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Produces(APPLICATION_JSON) @Produces(APPLICATION_JSON)
@ -59,7 +59,7 @@ public interface MultipartApi {
@Named("b2_cancel_large_file") @Named("b2_cancel_large_file")
@POST @POST
@Path("/b2api/v1/b2_cancel_large_file") @Path("/b2api/v2/b2_cancel_large_file")
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Produces(APPLICATION_JSON) @Produces(APPLICATION_JSON)
@ -67,7 +67,7 @@ public interface MultipartApi {
@Named("b2_finish_large_file") @Named("b2_finish_large_file")
@POST @POST
@Path("/b2api/v1/b2_finish_large_file") @Path("/b2api/v2/b2_finish_large_file")
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Produces(APPLICATION_JSON) @Produces(APPLICATION_JSON)
@ -75,7 +75,7 @@ public interface MultipartApi {
@Named("b2_get_upload_part_url") @Named("b2_get_upload_part_url")
@POST @POST
@Path("/b2api/v1/b2_get_upload_part_url") @Path("/b2api/v2/b2_get_upload_part_url")
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Produces(APPLICATION_JSON) @Produces(APPLICATION_JSON)
@ -88,7 +88,7 @@ public interface MultipartApi {
@Named("b2_list_parts") @Named("b2_list_parts")
@POST @POST
@Path("/b2api/v1/b2_list_parts") @Path("/b2api/v2/b2_list_parts")
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Produces(APPLICATION_JSON) @Produces(APPLICATION_JSON)
@ -96,7 +96,7 @@ public interface MultipartApi {
@Named("b2_list_unfinished_large_files") @Named("b2_list_unfinished_large_files")
@POST @POST
@Path("/b2api/v1/b2_list_unfinished_large_files") @Path("/b2api/v2/b2_list_unfinished_large_files")
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Produces(APPLICATION_JSON) @Produces(APPLICATION_JSON)

View File

@ -56,7 +56,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
public interface ObjectApi { public interface ObjectApi {
@Named("b2_get_upload_url") @Named("b2_get_upload_url")
@POST @POST
@Path("/b2api/v1/b2_get_upload_url") @Path("/b2api/v2/b2_get_upload_url")
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@ -71,7 +71,7 @@ public interface ObjectApi {
@Named("b2_delete_file_version") @Named("b2_delete_file_version")
@POST @POST
@Path("/b2api/v1/b2_delete_file_version") @Path("/b2api/v2/b2_delete_file_version")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@ -80,7 +80,7 @@ public interface ObjectApi {
@Named("b2_get_file_info") @Named("b2_get_file_info")
@POST @POST
@Path("/b2api/v1/b2_get_file_info") @Path("/b2api/v2/b2_get_file_info")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@ -90,7 +90,7 @@ public interface ObjectApi {
@Named("b2_download_file_by_id") @Named("b2_download_file_by_id")
@GET @GET
@Path("/b2api/v1/b2_download_file_by_id") @Path("/b2api/v2/b2_download_file_by_id")
@RequestFilters(RequestAuthorizationDownload.class) @RequestFilters(RequestAuthorizationDownload.class)
@ResponseParser(ParseB2ObjectFromResponse.class) @ResponseParser(ParseB2ObjectFromResponse.class)
@Fallback(NullOnNotFoundOr404.class) @Fallback(NullOnNotFoundOr404.class)
@ -98,7 +98,7 @@ public interface ObjectApi {
@Named("b2_download_file_by_id") @Named("b2_download_file_by_id")
@GET @GET
@Path("/b2api/v1/b2_download_file_by_id") @Path("/b2api/v2/b2_download_file_by_id")
@RequestFilters(RequestAuthorizationDownload.class) @RequestFilters(RequestAuthorizationDownload.class)
@ResponseParser(ParseB2ObjectFromResponse.class) @ResponseParser(ParseB2ObjectFromResponse.class)
@Fallback(NullOnNotFoundOr404.class) @Fallback(NullOnNotFoundOr404.class)
@ -123,7 +123,7 @@ public interface ObjectApi {
@Deprecated @Deprecated
@Named("b2_list_file_names") @Named("b2_list_file_names")
@GET @GET
@Path("/b2api/v1/b2_list_file_names") @Path("/b2api/v2/b2_list_file_names")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@ -132,7 +132,7 @@ public interface ObjectApi {
@Named("b2_list_file_names") @Named("b2_list_file_names")
@GET @GET
@Path("/b2api/v1/b2_list_file_names") @Path("/b2api/v2/b2_list_file_names")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@ -142,7 +142,7 @@ public interface ObjectApi {
@Deprecated @Deprecated
@Named("b2_list_file_versions") @Named("b2_list_file_versions")
@GET @GET
@Path("/b2api/v1/b2_list_file_versions") @Path("/b2api/v2/b2_list_file_versions")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@ -151,7 +151,7 @@ public interface ObjectApi {
@Named("b2_list_file_versions") @Named("b2_list_file_versions")
@GET @GET
@Path("/b2api/v1/b2_list_file_versions") @Path("/b2api/v2/b2_list_file_versions")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@ -160,7 +160,7 @@ public interface ObjectApi {
@Named("b2_hide_file") @Named("b2_hide_file")
@POST @POST
@Path("/b2api/v1/b2_hide_file") @Path("/b2api/v2/b2_hide_file")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@RequestFilters(RequestAuthorization.class) @RequestFilters(RequestAuthorization.class)
@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)

View File

@ -54,12 +54,12 @@ public final class B2RetryHandler extends BackoffLimitedRetryHandler implements
// B2 requires retrying on a different storage node for uploads // B2 requires retrying on a different storage node for uploads
String path = request.getEndpoint().getPath(); String path = request.getEndpoint().getPath();
if (path.startsWith("/b2api/v1/b2_upload_file")) { if (path.startsWith("/b2api/v2/b2_upload_file")) {
String bucketId = path.split("/")[4]; String bucketId = path.split("/")[4];
UploadUrlResponse uploadUrl = api.getObjectApi().getUploadUrl(bucketId); UploadUrlResponse uploadUrl = api.getObjectApi().getUploadUrl(bucketId);
builder.endpoint(uploadUrl.uploadUrl()) builder.endpoint(uploadUrl.uploadUrl())
.replaceHeader(HttpHeaders.AUTHORIZATION, uploadUrl.authorizationToken()); .replaceHeader(HttpHeaders.AUTHORIZATION, uploadUrl.authorizationToken());
} else if (path.startsWith("/b2api/v1/b2_upload_part")) { } else if (path.startsWith("/b2api/v2/b2_upload_part")) {
String fileId = path.split("/")[4]; String fileId = path.split("/")[4];
GetUploadPartResponse uploadUrl = api.getMultipartApi().getUploadPartUrl(fileId); GetUploadPartResponse uploadUrl = api.getMultipartApi().getUploadPartUrl(fileId);
builder.endpoint(uploadUrl.uploadUrl()) builder.endpoint(uploadUrl.uploadUrl())

View File

@ -65,7 +65,7 @@ final class B2TestUtils {
static void assertAuthentication(MockWebServer server) { static void assertAuthentication(MockWebServer server) {
assertThat(server.getRequestCount()).isGreaterThanOrEqualTo(1); assertThat(server.getRequestCount()).isGreaterThanOrEqualTo(1);
try { try {
assertThat(server.takeRequest().getRequestLine()).isEqualTo("GET /b2api/v1/b2_authorize_account HTTP/1.1"); assertThat(server.takeRequest().getRequestLine()).isEqualTo("GET /b2api/v2/b2_authorize_account HTTP/1.1");
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw Throwables.propagate(e); throw Throwables.propagate(e);
} }

View File

@ -47,7 +47,7 @@ public final class BucketApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_create_bucket", "/create_bucket_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_create_bucket", "/create_bucket_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -67,7 +67,7 @@ public final class BucketApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_delete_bucket", "/delete_bucket_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_delete_bucket", "/delete_bucket_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -85,7 +85,7 @@ public final class BucketApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_delete_bucket", "/delete_bucket_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_delete_bucket", "/delete_bucket_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -105,7 +105,7 @@ public final class BucketApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_update_bucket", "/update_bucket_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_update_bucket", "/update_bucket_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -133,7 +133,7 @@ public final class BucketApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_list_buckets", "/list_buckets_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_list_buckets", "/list_buckets_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }

View File

@ -76,7 +76,7 @@ public final class MultipartApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_start_large_file", "/start_large_file_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_start_large_file", "/start_large_file_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -97,7 +97,7 @@ public final class MultipartApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_cancel_large_file", "/cancel_large_file_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_cancel_large_file", "/cancel_large_file_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -127,7 +127,7 @@ public final class MultipartApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_finish_large_file", "/finish_large_file_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_finish_large_file", "/finish_large_file_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -143,11 +143,11 @@ public final class MultipartApiMockTest {
GetUploadPartResponse response = api.getUploadPartUrl(FILE_ID); GetUploadPartResponse response = api.getUploadPartUrl(FILE_ID);
assertThat(response.authorizationToken()).isEqualTo(AUTHORIZATION_TOKEN); assertThat(response.authorizationToken()).isEqualTo(AUTHORIZATION_TOKEN);
assertThat(response.fileId()).isEqualTo(FILE_ID); assertThat(response.fileId()).isEqualTo(FILE_ID);
assertThat(response.uploadUrl()).isEqualTo(URI.create("https://pod-000-1016-09.backblaze.com/b2api/v1/b2_upload_part/4_ze73ede9c9c8412db49f60715_f100b4e93fbae6252_d20150824_m224353_c900_v8881000_t0001/0037")); assertThat(response.uploadUrl()).isEqualTo(URI.create("https://pod-000-1016-09.backblaze.com/b2api/v2/b2_upload_part/4_ze73ede9c9c8412db49f60715_f100b4e93fbae6252_d20150824_m224353_c900_v8881000_t0001/0037"));
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_get_upload_part_url", "/get_upload_part_url_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_get_upload_part_url", "/get_upload_part_url_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -159,7 +159,7 @@ public final class MultipartApiMockTest {
try { try {
MultipartApi api = api(server.getUrl("/").toString(), "b2").getMultipartApi(); MultipartApi api = api(server.getUrl("/").toString(), "b2").getMultipartApi();
GetUploadPartResponse uploadPart = GetUploadPartResponse.create(FILE_ID, server.getUrl("/b2api/v1/b2_upload_part/4a48fe8875c6214145260818/c001_v0001007_t0042").toURI(), AUTHORIZATION_TOKEN); GetUploadPartResponse uploadPart = GetUploadPartResponse.create(FILE_ID, server.getUrl("/b2api/v2/b2_upload_part/4a48fe8875c6214145260818/c001_v0001007_t0042").toURI(), AUTHORIZATION_TOKEN);
long contentLength = 100 * 1000 * 1000; long contentLength = 100 * 1000 * 1000;
Payload payload = Payloads.newByteSourcePayload(TestUtils.randomByteSource().slice(0, contentLength)); Payload payload = Payloads.newByteSourcePayload(TestUtils.randomByteSource().slice(0, contentLength));
payload.getContentMetadata().setContentLength(contentLength); payload.getContentMetadata().setContentLength(contentLength);
@ -170,7 +170,7 @@ public final class MultipartApiMockTest {
assertThat(response.partNumber()).isEqualTo(1); assertThat(response.partNumber()).isEqualTo(1);
assertThat(server.getRequestCount()).isEqualTo(1); assertThat(server.getRequestCount()).isEqualTo(1);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_upload_part/4a48fe8875c6214145260818/c001_v0001007_t0042"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_upload_part/4a48fe8875c6214145260818/c001_v0001007_t0042");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -210,7 +210,7 @@ public final class MultipartApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_list_parts", "/list_parts_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_list_parts", "/list_parts_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -238,7 +238,7 @@ public final class MultipartApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_list_unfinished_large_files", "/list_unfinished_large_files_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_list_unfinished_large_files", "/list_unfinished_large_files_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }

View File

@ -69,12 +69,12 @@ public final class ObjectApiMockTest {
ObjectApi api = api(server.getUrl("/").toString(), "b2").getObjectApi(); ObjectApi api = api(server.getUrl("/").toString(), "b2").getObjectApi();
UploadUrlResponse response = api.getUploadUrl(BUCKET_ID); UploadUrlResponse response = api.getUploadUrl(BUCKET_ID);
assertThat(response.bucketId()).isEqualTo(BUCKET_ID); assertThat(response.bucketId()).isEqualTo(BUCKET_ID);
assertThat(response.uploadUrl()).isEqualTo(URI.create("https://pod-000-1005-03.backblaze.com/b2api/v1/b2_upload_file?cvt=c001_v0001005_t0027&bucket=4a48fe8875c6214145260818")); assertThat(response.uploadUrl()).isEqualTo(URI.create("https://pod-000-1005-03.backblaze.com/b2api/v2/b2_upload_file?cvt=c001_v0001005_t0027&bucket=4a48fe8875c6214145260818"));
assertThat(response.authorizationToken()).isEqualTo("2_20151009170037_f504a0f39a0f4e657337e624_9754dde94359bd7b8f1445c8f4cc1a231a33f714_upld"); assertThat(response.authorizationToken()).isEqualTo("2_20151009170037_f504a0f39a0f4e657337e624_9754dde94359bd7b8f1445c8f4cc1a231a33f714_upld");
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_get_upload_url", "/get_upload_url_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_get_upload_url", "/get_upload_url_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -96,7 +96,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_get_upload_url", "/get_upload_url_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_get_upload_url", "/get_upload_url_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -110,7 +110,7 @@ public final class ObjectApiMockTest {
ObjectApi api = api(server.getUrl("/").toString(), "b2").getObjectApi(); ObjectApi api = api(server.getUrl("/").toString(), "b2").getObjectApi();
String accountId = "d522aa47a10f"; String accountId = "d522aa47a10f";
UploadUrlResponse uploadUrl = UploadUrlResponse.create(BUCKET_ID, server.getUrl("/b2api/v1/b2_upload_file/4a48fe8875c6214145260818/c001_v0001007_t0042").toURI(), "FAKE-AUTHORIZATION-TOKEN"); UploadUrlResponse uploadUrl = UploadUrlResponse.create(BUCKET_ID, server.getUrl("/b2api/v2/b2_upload_file/4a48fe8875c6214145260818/c001_v0001007_t0042").toURI(), "FAKE-AUTHORIZATION-TOKEN");
Payload payload = Payloads.newStringPayload(PAYLOAD); Payload payload = Payloads.newStringPayload(PAYLOAD);
payload.getContentMetadata().setContentType(CONTENT_TYPE); payload.getContentMetadata().setContentType(CONTENT_TYPE);
UploadFileResponse response = api.uploadFile(uploadUrl, FILE_NAME, SHA1, FILE_INFO, payload); UploadFileResponse response = api.uploadFile(uploadUrl, FILE_NAME, SHA1, FILE_INFO, payload);
@ -125,7 +125,7 @@ public final class ObjectApiMockTest {
assertThat(response.fileInfo()).isEqualTo(FILE_INFO); assertThat(response.fileInfo()).isEqualTo(FILE_INFO);
assertThat(server.getRequestCount()).isEqualTo(1); assertThat(server.getRequestCount()).isEqualTo(1);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_upload_file/4a48fe8875c6214145260818/c001_v0001007_t0042"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_upload_file/4a48fe8875c6214145260818/c001_v0001007_t0042");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -144,7 +144,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_delete_file_version", "/delete_object_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_delete_file_version", "/delete_object_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -166,7 +166,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_delete_file_version", "/delete_object_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_delete_file_version", "/delete_object_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -194,7 +194,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_get_file_info", "/get_file_info_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_get_file_info", "/get_file_info_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -212,7 +212,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_get_file_info", "/get_file_info_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_get_file_info", "/get_file_info_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -248,11 +248,11 @@ public final class ObjectApiMockTest {
RecordedRequest request = server.takeRequest(); RecordedRequest request = server.takeRequest();
assertThat(request.getMethod()).isEqualTo("GET"); assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/b2api/v1/b2_authorize_account"); assertThat(request.getPath()).isEqualTo("/b2api/v2/b2_authorize_account");
request = server.takeRequest(); request = server.takeRequest();
assertThat(request.getMethod()).isEqualTo("GET"); assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/b2api/v1/b2_download_file_by_id?fileId=4_h4a48fe8875c6214145260818_f000000000000472a_d20140104_m032022_c001_v0000123_t0104"); assertThat(request.getPath()).isEqualTo("/b2api/v2/b2_download_file_by_id?fileId=4_h4a48fe8875c6214145260818_f000000000000472a_d20140104_m032022_c001_v0000123_t0104");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -280,11 +280,11 @@ public final class ObjectApiMockTest {
RecordedRequest request = server.takeRequest(); RecordedRequest request = server.takeRequest();
assertThat(request.getMethod()).isEqualTo("GET"); assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/b2api/v1/b2_authorize_account"); assertThat(request.getPath()).isEqualTo("/b2api/v2/b2_authorize_account");
request = server.takeRequest(); request = server.takeRequest();
assertThat(request.getMethod()).isEqualTo("GET"); assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/b2api/v1/b2_download_file_by_id?fileId=4_h4a48fe8875c6214145260818_f000000000000472a_d20140104_m032022_c001_v0000123_t0104"); assertThat(request.getPath()).isEqualTo("/b2api/v2/b2_download_file_by_id?fileId=4_h4a48fe8875c6214145260818_f000000000000472a_d20140104_m032022_c001_v0000123_t0104");
assertThat(request.getHeaders()).contains("Range: bytes=42-69"); assertThat(request.getHeaders()).contains("Range: bytes=42-69");
} finally { } finally {
server.shutdown(); server.shutdown();
@ -321,7 +321,7 @@ public final class ObjectApiMockTest {
RecordedRequest request = server.takeRequest(); RecordedRequest request = server.takeRequest();
assertThat(request.getMethod()).isEqualTo("GET"); assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/b2api/v1/b2_authorize_account"); assertThat(request.getPath()).isEqualTo("/b2api/v2/b2_authorize_account");
request = server.takeRequest(); request = server.takeRequest();
assertThat(request.getMethod()).isEqualTo("GET"); assertThat(request.getMethod()).isEqualTo("GET");
@ -361,7 +361,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_list_file_names", "/list_file_names_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_list_file_names", "/list_file_names_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -405,7 +405,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_list_file_versions", "/list_file_versions_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_list_file_versions", "/list_file_versions_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }
@ -428,7 +428,7 @@ public final class ObjectApiMockTest {
assertThat(server.getRequestCount()).isEqualTo(2); assertThat(server.getRequestCount()).isEqualTo(2);
assertAuthentication(server); assertAuthentication(server);
assertRequest(server.takeRequest(), "POST", "/b2api/v1/b2_hide_file", "/hide_file_request.json"); assertRequest(server.takeRequest(), "POST", "/b2api/v2/b2_hide_file", "/hide_file_request.json");
} finally { } finally {
server.shutdown(); server.shutdown();
} }

View File

@ -1,5 +1,5 @@
{ {
"authorizationToken": "3_20160409004829_42b8f80ba60fb4323dcaad98_ec81302316fccc2260201cbf17813247f312cf3b_000_uplg", "authorizationToken": "3_20160409004829_42b8f80ba60fb4323dcaad98_ec81302316fccc2260201cbf17813247f312cf3b_000_uplg",
"fileId": "4_za71f544e781e6891531b001a_f200ec353a2184825_d20160409_m004829_c000_v0001016_t0028", "fileId": "4_za71f544e781e6891531b001a_f200ec353a2184825_d20160409_m004829_c000_v0001016_t0028",
"uploadUrl": "https://pod-000-1016-09.backblaze.com/b2api/v1/b2_upload_part/4_ze73ede9c9c8412db49f60715_f100b4e93fbae6252_d20150824_m224353_c900_v8881000_t0001/0037" "uploadUrl": "https://pod-000-1016-09.backblaze.com/b2api/v2/b2_upload_part/4_ze73ede9c9c8412db49f60715_f100b4e93fbae6252_d20150824_m224353_c900_v8881000_t0001/0037"
} }

View File

@ -1,5 +1,5 @@
{ {
"bucketId" : "4a48fe8875c6214145260818", "bucketId" : "4a48fe8875c6214145260818",
"uploadUrl" : "https://pod-000-1005-03.backblaze.com/b2api/v1/b2_upload_file?cvt=c001_v0001005_t0027&bucket=4a48fe8875c6214145260818", "uploadUrl" : "https://pod-000-1005-03.backblaze.com/b2api/v2/b2_upload_file?cvt=c001_v0001005_t0027&bucket=4a48fe8875c6214145260818",
"authorizationToken" : "2_20151009170037_f504a0f39a0f4e657337e624_9754dde94359bd7b8f1445c8f4cc1a231a33f714_upld" "authorizationToken" : "2_20151009170037_f504a0f39a0f4e657337e624_9754dde94359bd7b8f1445c8f4cc1a231a33f714_upld"
} }