Skip to content

Commit

Permalink
Merge pull request Azure#346 from rickle-msft/New-Storage-SDK-V10-Pre…
Browse files Browse the repository at this point in the history
…view-dev

New storage sdk v10 preview dev
  • Loading branch information
rickle-msft authored Jul 31, 2018
2 parents 49ce678 + 0d2069e commit dd704b1
Show file tree
Hide file tree
Showing 36 changed files with 1,587 additions and 307 deletions.
7 changes: 6 additions & 1 deletion BreakingChanges.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
2018.07.03 Version 10.0.1-Preview
XXXX.XX.XX Version XX.X.X-Preview
* Changed BlobListingDetails constructor to take a flag to include deleted blobs.
* Restructured the blob and container listing responses.
* BlockBlobURL.MAX_PUT_BLOCK_BYTES renamed to BlockBlobURL.MAX_STAGE_BLOCK_BYTES.

2018.07.03 Version 10.0.1-Preview
* Created the StorageException type, which deserializes the XML payload in an error response if present and gives access to the ErrorCode header as a property.
* Changed the AppendBlobAccessConditions field types to be Long instead of Int.
* Changed RequestRetryOptions maxTries and tryTimeout fields to be Integer instead of int. 0 is no longer allowed.
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
XXXX.XX.XX Version XX.X.X-Preview
* Support for 2017-07-29 REST version. Please see our REST api documentation and blogs for information about the related added features.
* Support for setting a block blob's tier.
* Added support for soft delete feature. If a delete retention policy is enabled through the set service properties API, then blobs or snapshots can be deleted softly and retained for a specified number of days, before being permanently removed by garbage collection.
* Changed BlobListingDetails constructor to take a flag to include deleted blobs.
* Restructured the blob and container listing responses.
* BlockBlobURL.MAX_PUT_BLOCK_BYTES renamed to BlockBlobURL.MAX_STAGE_BLOCK_BYTES.

2018.07.03 Version 10.0.1-Preview
* Added the RetryReader class to allow for more reliable streaming on large downloads. This is now the return type of blobURL.download
Expand Down
97 changes: 97 additions & 0 deletions src/main/java/com/microsoft/azure/storage/GeneratedBlockBlobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.microsoft.azure.storage.blob.models.BlockBlobCommitBlockListResponse;
import com.microsoft.azure.storage.blob.models.BlockBlobGetBlockListResponse;
import com.microsoft.azure.storage.blob.models.BlockBlobStageBlockFromURLResponse;
import com.microsoft.azure.storage.blob.models.BlockBlobStageBlockResponse;
import com.microsoft.azure.storage.blob.models.BlockBlobUploadResponse;
import com.microsoft.azure.storage.blob.models.BlockList;
Expand All @@ -38,6 +39,7 @@
import io.reactivex.Maybe;
import io.reactivex.Single;
import io.reactivex.annotations.NonNull;
import java.net.URL;
import java.nio.ByteBuffer;
import java.time.OffsetDateTime;
import java.util.HashMap;
Expand Down Expand Up @@ -84,6 +86,11 @@ private interface BlockBlobsService {
@UnexpectedResponseExceptionType(StorageErrorException.class)
Single<BlockBlobStageBlockResponse> stageBlock(@HostParam("url") String url, @QueryParam("blockid") String blockId, @HeaderParam("Content-Length") long contentLength, @BodyParam("application/octet-stream") Flowable<ByteBuffer> body, @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("comp") String comp);

@PUT("{containerName}/{blob}")
@ExpectedResponses({201})
@UnexpectedResponseExceptionType(StorageErrorException.class)
Single<BlockBlobStageBlockFromURLResponse> stageBlockFromURL(@HostParam("url") String url, @QueryParam("blockid") String blockId, @HeaderParam("Content-Length") long contentLength, @HeaderParam("x-ms-copy-source") URL copySource, @HeaderParam("x-ms-source-range") String sourceRange, @HeaderParam("x-ms-source-content-md5") String sourceContentMD5, @QueryParam("timeout") Integer timeout, @HeaderParam("x-ms-lease-id") String leaseId, @HeaderParam("x-ms-version") String version, @HeaderParam("x-ms-client-request-id") String requestId, @QueryParam("comp") String comp);

@PUT("{containerName}/{blob}")
@ExpectedResponses({201})
@UnexpectedResponseExceptionType(StorageErrorException.class)
Expand Down Expand Up @@ -302,6 +309,96 @@ public Completable stageBlockAsync(@NonNull String blockId, @NonNull long conten
.toCompletable();
}

/**
* The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from a URL.
*
* @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter must be the same size for each block.
* @param contentLength The length of the request.
* @param sourceUrl Specifiy an URL to the copy source.
* @param sourceRange Bytes of source data in the specified range.
* @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source.
* @param timeout The timeout parameter is expressed in seconds. For more information, see &lt;a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations"&gt;Setting Timeouts for Blob Service Operations.&lt;/a&gt;.
* @param leaseId If specified, the operation only succeeds if the container's lease is active and matches this ID.
* @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws StorageErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
public void stageBlockFromURL(@NonNull String blockId, @NonNull long contentLength, @NonNull URL sourceUrl, String sourceRange, byte[] sourceContentMD5, Integer timeout, String leaseId, String requestId) {
stageBlockFromURLAsync(blockId, contentLength, sourceUrl, sourceRange, sourceContentMD5, timeout, leaseId, requestId).blockingAwait();
}

/**
* The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from a URL.
*
* @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter must be the same size for each block.
* @param contentLength The length of the request.
* @param sourceUrl Specifiy an URL to the copy source.
* @param sourceRange Bytes of source data in the specified range.
* @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source.
* @param timeout The timeout parameter is expressed in seconds. For more information, see &lt;a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations"&gt;Setting Timeouts for Blob Service Operations.&lt;/a&gt;.
* @param leaseId If specified, the operation only succeeds if the container's lease is active and matches this ID.
* @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @return a ServiceFuture which will be completed with the result of the network request.
*/
public ServiceFuture<Void> stageBlockFromURLAsync(@NonNull String blockId, @NonNull long contentLength, @NonNull URL sourceUrl, String sourceRange, byte[] sourceContentMD5, Integer timeout, String leaseId, String requestId, ServiceCallback<Void> serviceCallback) {
return ServiceFuture.fromBody(stageBlockFromURLAsync(blockId, contentLength, sourceUrl, sourceRange, sourceContentMD5, timeout, leaseId, requestId), serviceCallback);
}

/**
* The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from a URL.
*
* @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter must be the same size for each block.
* @param contentLength The length of the request.
* @param sourceUrl Specifiy an URL to the copy source.
* @param sourceRange Bytes of source data in the specified range.
* @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source.
* @param timeout The timeout parameter is expressed in seconds. For more information, see &lt;a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations"&gt;Setting Timeouts for Blob Service Operations.&lt;/a&gt;.
* @param leaseId If specified, the operation only succeeds if the container's lease is active and matches this ID.
* @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @return a Single which performs the network request upon subscription.
*/
public Single<BlockBlobStageBlockFromURLResponse> stageBlockFromURLWithRestResponseAsync(@NonNull String blockId, @NonNull long contentLength, @NonNull URL sourceUrl, String sourceRange, byte[] sourceContentMD5, Integer timeout, String leaseId, String requestId) {
if (this.client.url() == null) {
throw new IllegalArgumentException("Parameter this.client.url() is required and cannot be null.");
}
if (blockId == null) {
throw new IllegalArgumentException("Parameter blockId is required and cannot be null.");
}
if (sourceUrl == null) {
throw new IllegalArgumentException("Parameter sourceUrl is required and cannot be null.");
}
if (this.client.version() == null) {
throw new IllegalArgumentException("Parameter this.client.version() is required and cannot be null.");
}
Validator.validate(sourceUrl);
final String comp = "block";
String sourceContentMD5Converted = Base64Util.encodeToString(sourceContentMD5);
return service.stageBlockFromURL(this.client.url(), blockId, contentLength, sourceUrl, sourceRange, sourceContentMD5Converted, timeout, leaseId, this.client.version(), requestId, comp);
}

/**
* The Stage Block operation creates a new block to be committed as part of a blob where the contents are read from a URL.
*
* @param blockId A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal to 64 bytes in size. For a given blob, the length of the value specified for the blockid parameter must be the same size for each block.
* @param contentLength The length of the request.
* @param sourceUrl Specifiy an URL to the copy source.
* @param sourceRange Bytes of source data in the specified range.
* @param sourceContentMD5 Specify the md5 calculated for the range of bytes that must be read from the copy source.
* @param timeout The timeout parameter is expressed in seconds. For more information, see &lt;a href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations"&gt;Setting Timeouts for Blob Service Operations.&lt;/a&gt;.
* @param leaseId If specified, the operation only succeeds if the container's lease is active and matches this ID.
* @param requestId Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @return a Single which performs the network request upon subscription.
*/
public Completable stageBlockFromURLAsync(@NonNull String blockId, @NonNull long contentLength, @NonNull URL sourceUrl, String sourceRange, byte[] sourceContentMD5, Integer timeout, String leaseId, String requestId) {
return stageBlockFromURLWithRestResponseAsync(blockId, contentLength, sourceUrl, sourceRange, sourceContentMD5, timeout, leaseId, requestId)
.toCompletable();
}

/**
* The Commit Block List operation writes a blob by specifying the list of block IDs that make up the blob. In order to be written as part of a blob, a block must have been successfully written to the server in a prior Put Block operation. You can call Put Block List to update a blob by uploading only those blocks that have changed, then committing the new and existing blocks together. You can do this by specifying whether to commit a block from the committed block list or from the uncommitted block list, or to commit the most recently uploaded version of the block, whichever list it may belong to.
*
Expand Down
Loading

0 comments on commit dd704b1

Please sign in to comment.