Skip to content

Commit

Permalink
Rename StorageClient to BlobServiceClient (Azure#4707)
Browse files Browse the repository at this point in the history
* Renamed StorageClient to BlobServiceClient

* Cleanup README

* Fix README example links

* Fixed XML serialization issue
  • Loading branch information
alzimmermsft authored and sima-zhu committed Jul 30, 2019
1 parent a48ecb7 commit 24d7400
Show file tree
Hide file tree
Showing 35 changed files with 165 additions and 165 deletions.
2 changes: 1 addition & 1 deletion storage/client/blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ https://aka.ms/azure-sdk-preview1-java.

**Breaking changes: New API design**
- Operations are now scoped to a particular client:
- `StorageClient`: StorageURL's functionality was migrated to StorageClient. This client handles account-level operations. This includes managing service properties and listing the containers within an account.
- `BlobServiceClient`: StorageURL's functionality was migrated to BlobServiceClient. This client handles account-level operations. This includes managing service properties and listing the containers within an account.
- `ContainerClient`: ContainerURL's functionality was migrated to ContainerClient. The client handles operations for a particular container. This includes creating or deleting that container, as well as listing the blobs within that container.
- `BlobClient`: BlobURL's functionality was migrated to BlobClient, TransferManager download functionality was migrated to BlobClient and TransferManager upload functionality was migrated to BlockBlobClient. The client handles most operations, excluding upload, for an individual blob, including downloading data and working with blob properties.
There are subclients (BlockBlobClient, PageBlobClient, AppendBlobClient) available for their respective blob types on the service.
Expand Down
54 changes: 27 additions & 27 deletions storage/client/blob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ Blob storage is designed for:

The following sections provide several code snippets covering some of the most common Azure Storage Blob tasks, including:

- [Create storage client](#create-storage-client)
- [Create container client](#create-container-client)
- [Create blob client](#create-blob-client)
- [Create BlobServiceClient](#create-blobserviceclient)
- [Create ContainerClient](#create-containerclient)
- [Create BlobClient](#create-blobclient)
- [Create a container](#create-a-container)
- [Upload a blob from InputStream](#uploading-a-blob-from-a-stream)
- [Upload a blob from File](#uploading-a-blob-from-file)
Expand All @@ -108,70 +108,70 @@ The following sections provide several code snippets covering some of the most c
- [Enumerating blobs](#enumerating-blobs)
- [Authenticate with Azure.Identity](#authenticate-with-azureidentity)

### Create storage client
### Create BlobServiceClient

Create a storage client using the [`sasToken`](#get-credentials) generated above.
Create a BlobServiceClient using the [`sasToken`](#get-credentials) generated above.
```java
StorageClient storageClient = StorageClient.builder()
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint("<your-storage-blob-url>")
.credential("<your-sasToken>")
.build();
.buildClient();
```

### Create container client
### Create ContainerClient

Create a container client if storage client exists.
Create a ContainerClient if a BlobServiceClient exists.
```java
ContainerClient containerClient = storageClient.getContainerClient("mycontainer");
ContainerClient containerClient = blobServiceClient.getContainerClient("mycontainer");
```

or

Create the container client from the builder [`sasToken`](#get-credentials) generated above.
Create the ContainerClient from the builder [`sasToken`](#get-credentials) generated above.
```java
ContainerClient containerClient = ContainerClient.builder()
ContainerClient containerClient = new ContainerClientBuilder()
.endpoint("<your-storage-blob-url>")
.credential("<your-sasToken>")
.containerName("mycontainer")
.build();
.buildClient();
```

### Create blob client
### Create BlobClient

Create a blob client if container client exists.
Create a BlobClient if container client exists.
```java
BlobClient blobClient = containerClient.getBlobClient("myblob");
```

or

Create the blob client from the builder [`sasToken`](#get-credentials) generated above.
Create the BlobClient from the builder [`sasToken`](#get-credentials) generated above.
```java
BlobClient blobClient = BlobClient.builder()
BlobClient blobClient = new BlobClientBuilder()
.endpoint("<your-storage-blob-url>")
.credential("<your-sasToken>")
.containerName("mycontainer")
.blobName("myblob")
.build();
.buildBlobClient();
```

### Create a container

Create a container from storage client.
Create a container from a BlobServiceClient.
```java
storageClient.createContainer("mycontainer");
blobServiceClient.createContainer("mycontainer");
```

or

Create a container using container client.
Create a container using ContainerClient.
```java
containerClient.create();
```

### Uploading a blob from a stream

Upload data stream to a blob using blockBlobClient generated from containerClient.
Upload data stream to a blob using BlockBlobClient generated from a ContainerClient.

```java
BlockBlobClient blockBlobClient = containerClient.getBlockBlobClient("myblockblob");
Expand All @@ -183,7 +183,7 @@ try (ByteArrayInputStream dataStream = new ByteArrayInputStream(dataSample.getBy

### Uploading a blob from `File`

Upload a file to a blob using blockBlobClient generated from containerClient.
Upload a file to a blob using BlockBlobClient generated from ContainerClient.

```java
BlockBlobClient blockBlobClient = containerClient.getBlockBlobClient("myblockblob");
Expand All @@ -192,7 +192,7 @@ blobClient.uploadFromFile("local-file.jpg");

### Downloading a blob to output stream

Download blob to output stream using blobClient.
Download blob to output stream using BlobClient.

```java
try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream("downloaded-file.jpg")) {
Expand All @@ -202,14 +202,14 @@ try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream("downloaded-f

### Downloading a blob to local path

Download blob to local file using blobClient.
Download blob to local file using BlobClient.
```java
blobClient.downloadToFile("downloaded-file.jpg");
```

### Enumerating blobs

Enumerating all blobs using `ContainerClient`
Enumerating all blobs using ContainerClient
```java
containerClient.listBlobsFlat()
.forEach(
Expand All @@ -222,7 +222,7 @@ containerClient.listBlobsFlat()
The [Azure Identity library][identity] provides Azure Active Directory support for authenticating with Azure Storage.

```java
StorageClient storageClient = StorageClient.storageClientBuilder()
BlobServiceClient storageClient = BlobServiceClient.storageClientBuilder()
.endpoint(endpoint)
.credential(new DefaultAzureCredential())
.buildClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Anonymous credentials are to be used with with HTTP(S) requests that read blobs from public containers or requests
* that use a Shared Access Signature (SAS). This is because Anonymous credentials will not set an Authorization header.
* Pass an instance of this class as the credentials parameter when creating a new pipeline (typically with
* {@link StorageClient}).
* {@link BlobServiceClient}).
*/
public final class AnonymousCredentialPolicy implements HttpPipelinePolicy {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* <p>
* This client contains operations on a blob. Operations on a container are available on {@link ContainerAsyncClient},
* and operations on the service are available on {@link StorageAsyncClient}.
* and operations on the service are available on {@link BlobServiceAsyncClient}.
*
* <p>
* Please refer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* <p>
* This client contains operations on a blob. Operations on a container are available on {@link ContainerClient},
* and operations on the service are available on {@link StorageClient}.
* and operations on the service are available on {@link BlobServiceClient}.
*
* <p>
* Please refer to the <a href=https://docs.microsoft.com/en-us/rest/api/storageservices/understanding-block-blobs--append-blobs--and-page-blobs>Azure Docs</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*
* <p>
* This client contains operations on a blob. Operations on a container are available on {@link ContainerAsyncClient},
* and operations on the service are available on {@link StorageAsyncClient}.
* and operations on the service are available on {@link BlobServiceAsyncClient}.
*
* <p>
* Please refer to the <a href=https://docs.microsoft.com/en-us/rest/api/storageservices/understanding-block-blobs--append-blobs--and-page-blobs>Azure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*
* <p>
* This client contains operations on a blob. Operations on a container are available on {@link ContainerClient}, and
* operations on the service are available on {@link StorageClient}.
* operations on the service are available on {@link BlobServiceClient}.
*
* <p>
* Please refer to the <a href=https://docs.microsoft.com/en-us/rest/api/storageservices/understanding-block-blobs--append-blobs--and-page-blobs>Azure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static com.azure.storage.blob.Utility.postProcessResponse;

/**
* Client to a storage account. It may only be instantiated through a {@link StorageClientBuilder}. This class does not
* Client to a storage account. It may only be instantiated through a {@link BlobServiceClientBuilder}. This class does not
* hold any state about a particular storage account but is instead a convenient way of sending off appropriate requests
* to the resource on the service. It may also be used to construct URLs to blobs and containers.
*
Expand All @@ -50,15 +50,15 @@
* operation, until {@code .subscribe()} is called on the reactive response. You can simply convert one of these
* responses to a {@link java.util.concurrent.CompletableFuture} object through {@link Mono#toFuture()}.
*/
public final class StorageAsyncClient {
public final class BlobServiceAsyncClient {
private final AzureBlobStorageImpl azureBlobStorage;

/**
* Package-private constructor for use by {@link StorageClientBuilder}.
* Package-private constructor for use by {@link BlobServiceClientBuilder}.
*
* @param azureBlobStorageBuilder the API client builder for blob storage API
*/
StorageAsyncClient(AzureBlobStorageBuilder azureBlobStorageBuilder) {
BlobServiceAsyncClient(AzureBlobStorageBuilder azureBlobStorageBuilder) {
this.azureBlobStorage = azureBlobStorageBuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.time.OffsetDateTime;

/**
* Client to a storage account. It may only be instantiated through a {@link StorageClientBuilder}. This class does not
* Client to a storage account. It may only be instantiated through a {@link BlobServiceClientBuilder}. This class does not
* hold any state about a particular storage account but is instead a convenient way of sending off appropriate requests
* to the resource on the service. It may also be used to construct URLs to blobs and containers.
*
Expand All @@ -36,16 +36,16 @@
* Please see <a href=https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction>here</a> for more
* information on containers.
*/
public final class StorageClient {
private final StorageAsyncClient storageAsyncClient;
public final class BlobServiceClient {
private final BlobServiceAsyncClient blobServiceAsyncClient;

/**
* Package-private constructor for use by {@link StorageClientBuilder}.
* Package-private constructor for use by {@link BlobServiceClientBuilder}.
*
* @param storageAsyncClient the async storage account client
* @param blobServiceAsyncClient the async storage account client
*/
StorageClient(StorageAsyncClient storageAsyncClient) {
this.storageAsyncClient = storageAsyncClient;
BlobServiceClient(BlobServiceAsyncClient blobServiceAsyncClient) {
this.blobServiceAsyncClient = blobServiceAsyncClient;
}

/**
Expand All @@ -56,7 +56,7 @@ public final class StorageClient {
* @return A {@link ContainerClient} object pointing to the specified container
*/
public ContainerClient getContainerClient(String containerName) {
return new ContainerClient(storageAsyncClient.getContainerAsyncClient(containerName));
return new ContainerClient(blobServiceAsyncClient.getContainerAsyncClient(containerName));
}

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public Response<ContainerClient> createContainer(String containerName, Metadata
* @return A response containing status code and HTTP headers
*/
public VoidResponse deleteContainer(String containerName) {
return storageAsyncClient.deleteContainer(containerName).block();
return blobServiceAsyncClient.deleteContainer(containerName).block();
}

/**
Expand All @@ -105,7 +105,7 @@ public VoidResponse deleteContainer(String containerName) {
* @return the URL.
*/
public URL getAccountUrl() {
return storageAsyncClient.getAccountUrl();
return blobServiceAsyncClient.getAccountUrl();
}

/**
Expand All @@ -129,7 +129,7 @@ public Iterable<ContainerItem> listContainers() {
* @return The list of containers.
*/
public Iterable<ContainerItem> listContainers(ListContainersOptions options, Duration timeout) {
Flux<ContainerItem> response = storageAsyncClient.listContainers(options);
Flux<ContainerItem> response = blobServiceAsyncClient.listContainers(options);

return timeout == null ? response.toIterable() : response.timeout(timeout).toIterable();
}
Expand All @@ -153,7 +153,7 @@ public Response<StorageServiceProperties> getProperties() {
*/
public Response<StorageServiceProperties> getProperties(Duration timeout) {

Mono<Response<StorageServiceProperties>> response = storageAsyncClient.getProperties();
Mono<Response<StorageServiceProperties>> response = blobServiceAsyncClient.getProperties();

return Utility.blockWithOptionalTimeout(response, timeout);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ public VoidResponse setProperties(StorageServiceProperties properties) {
* @return The storage account properties.
*/
public VoidResponse setProperties(StorageServiceProperties properties, Duration timeout) {
Mono<VoidResponse> response = storageAsyncClient.setProperties(properties);
Mono<VoidResponse> response = blobServiceAsyncClient.setProperties(properties);

return Utility.blockWithOptionalTimeout(response, timeout);
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public Response<UserDelegationKey> getUserDelegationKey(OffsetDateTime start, Of
*/
public Response<UserDelegationKey> getUserDelegationKey(OffsetDateTime start, OffsetDateTime expiry,
Duration timeout) {
Mono<Response<UserDelegationKey>> response = storageAsyncClient.getUserDelegationKey(start, expiry);
Mono<Response<UserDelegationKey>> response = blobServiceAsyncClient.getUserDelegationKey(start, expiry);

return Utility.blockWithOptionalTimeout(response, timeout);
}
Expand All @@ -237,7 +237,7 @@ public Response<StorageServiceStats> getStatistics() {
* @return The storage account statistics.
*/
public Response<StorageServiceStats> getStatistics(Duration timeout) {
Mono<Response<StorageServiceStats>> response = storageAsyncClient.getStatistics();
Mono<Response<StorageServiceStats>> response = blobServiceAsyncClient.getStatistics();

return Utility.blockWithOptionalTimeout(response, timeout);
}
Expand All @@ -260,7 +260,7 @@ public Response<StorageAccountInfo> getAccountInfo() {
* @return The storage account info.
*/
public Response<StorageAccountInfo> getAccountInfo(Duration timeout) {
Mono<Response<StorageAccountInfo>> response = storageAsyncClient.getAccountInfo();
Mono<Response<StorageAccountInfo>> response = blobServiceAsyncClient.getAccountInfo();

return Utility.blockWithOptionalTimeout(response, timeout);
}
Expand All @@ -276,7 +276,7 @@ public Response<StorageAccountInfo> getAccountInfo(Duration timeout) {
*/
public String generateAccountSAS(AccountSASService accountSASService, AccountSASResourceType accountSASResourceType,
AccountSASPermission accountSASPermission, OffsetDateTime expiryTime) {
return this.storageAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime);
return this.blobServiceAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime);
}

/**
Expand All @@ -295,6 +295,6 @@ public String generateAccountSAS(AccountSASService accountSASService, AccountSAS
public String generateAccountSAS(AccountSASService accountSASService, AccountSASResourceType accountSASResourceType,
AccountSASPermission accountSASPermission, OffsetDateTime expiryTime, OffsetDateTime startTime, String version, IPRange ipRange,
SASProtocol sasProtocol) {
return this.storageAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime, startTime, version, ipRange, sasProtocol);
return this.blobServiceAsyncClient.generateAccountSAS(accountSASService, accountSASResourceType, accountSASPermission, expiryTime, startTime, version, ipRange, sasProtocol);
}
}
Loading

0 comments on commit 24d7400

Please sign in to comment.