Skip to content

WIP: Storage changes post-refactor #2387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions sdk/storage/azure_storage_blob/src/clients/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@
use crate::{
clients::GeneratedBlobClient,
models::{
BlobBlobClientDownloadOptions, BlobBlobClientGetPropertiesOptions,
BlobBlockBlobClientCommitBlockListOptions, BlobBlockBlobClientStageBlockOptions,
BlobBlockBlobClientUploadOptions, BlobProperties, BlockLookupList,
BlobClientDownloadOptions, BlobClientGetPropertiesOptions, BlobProperties,
BlockBlobClientCommitBlockListOptions, BlockBlobClientStageBlockOptions,
BlockBlobClientUploadOptions, BlockLookupList,
},
pipeline::StorageHeadersPolicy,
BlobClientOptions,
};
use azure_core::{
base64, credentials::TokenCredential, BearerTokenCredentialPolicy, Bytes, Policy,
RequestContent, Response, Result, Url,
base64,
credentials::TokenCredential,
http::{
policies::{BearerTokenCredentialPolicy, Policy},
RequestContent, Response, Url,
},
Bytes, Result,
};
use std::sync::Arc;

Expand Down Expand Up @@ -59,7 +64,13 @@ impl BlobClient {
.per_try_policies
.push(Arc::new(oauth_token_policy) as Arc<dyn Policy>);

let client = GeneratedBlobClient::new(endpoint, credential, Some(options))?;
let client = GeneratedBlobClient::new(
endpoint,
credential,
container_name.clone(),
blob_name.clone(),
Some(options),
)?;
Ok(Self {
endpoint: endpoint.parse()?,
container_name,
Expand Down Expand Up @@ -91,13 +102,9 @@ impl BlobClient {
/// * `options` - Optional configuration for the request.
pub async fn get_blob_properties(
&self,
options: Option<BlobBlobClientGetPropertiesOptions<'_>>,
options: Option<BlobClientGetPropertiesOptions<'_>>,
) -> Result<BlobProperties> {
let response = self
.client
.get_blob_blob_client(self.container_name.clone(), self.blob_name.clone())
.get_properties(options)
.await?;
let response = self.client.get_properties(options).await?;

let blob_properties: BlobProperties = response.headers().get()?;
Ok(blob_properties)
Expand All @@ -110,14 +117,9 @@ impl BlobClient {
/// * `options` - Optional configuration for the request.
pub async fn download_blob(
&self,
options: Option<BlobBlobClientDownloadOptions<'_>>,
options: Option<BlobClientDownloadOptions<'_>>,
) -> Result<Response> {
let response = self
.client
.get_blob_blob_client(self.container_name.clone(), self.blob_name.clone())
.download(options)
.await?;
Ok(response)
self.client.download(options)
}

/// Creates a new blob from a data source.
Expand All @@ -144,7 +146,7 @@ impl BlobClient {

let response = self
.client
.get_blob_block_blob_client(self.container_name.clone(), self.blob_name.clone())
.get_block_blob_client(self.container_name.clone(), self.blob_name.clone())
.upload(data, content_length, Some(options))
.await?;
Ok(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ use crate::{
BlobClientOptions,
};
use azure_core::{
credentials::TokenCredential, BearerTokenCredentialPolicy, Policy, Response, Result, Url,
credentials::TokenCredential,
http::{
policies::{BearerTokenCredentialPolicy, Policy},
Response, Url,
},
Result,
};
use std::sync::Arc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ use crate::{
BlobClientOptions,
};
use azure_core::{
credentials::TokenCredential, BearerTokenCredentialPolicy, Policy, Response, Result, Url,
credentials::TokenCredential,
http::{
policies::{BearerTokenCredentialPolicy, Policy},
Response, Url,
},
Result,
};
use std::sync::Arc;

Expand Down
16 changes: 16 additions & 0 deletions sdk/storage/azure_storage_blob/src/clients/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

mod blob_client;
mod blob_container_client;
mod blob_service_client;

pub use blob_client::BlobClient;
pub use blob_container_client::BlobContainerClient as ContainerClient;
pub use blob_service_client::BlobServiceClient as ServiceClient;

pub(crate) use crate::generated::BlobClient as GeneratedBlobClient;
pub use crate::generated::{
AppendBlobClient, BlobClientOptions, BlobContainerClient, BlobServiceClient, BlockBlobClient,
PageBlobClient,
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading