Skip to content

Commit c5e1af2

Browse files
authored
update datalake head and list operations - more blob migration (#798)
1 parent 267d8ce commit c5e1af2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+466
-166
lines changed

sdk/storage_blobs/Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "azure_storage_blobs"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
description = "Azure Blob Storage crate from the Azure SDK for Rust"
55
readme = "README.md"
66
authors = ["Microsoft Corp."]
@@ -13,8 +13,10 @@ categories = ["api-bindings"]
1313
edition = "2021"
1414

1515
[dependencies]
16-
azure_core = { path = "../core", version = "0.3", default-features=false }
17-
azure_storage = { path = "../storage", version = "0.3", default-features=false, features=["account"] }
16+
azure_core = { path = "../core", version = "0.3", default-features = false }
17+
azure_storage = { path = "../storage", version = "0.3", default-features = false, features = [
18+
"account",
19+
] }
1820
base64 = "0.13"
1921
bytes = "1.0"
2022
chrono = { version = "0.4", features = ["serde"] }
@@ -42,4 +44,7 @@ default = ["enable_reqwest"]
4244
test_e2e = []
4345
azurite_workaround = []
4446
enable_reqwest = ["azure_core/enable_reqwest", "azure_storage/enable_reqwest"]
45-
enable_reqwest_rustls = ["azure_core/enable_reqwest_rustls", "azure_storage/enable_reqwest_rustls"]
47+
enable_reqwest_rustls = [
48+
"azure_core/enable_reqwest_rustls",
49+
"azure_storage/enable_reqwest_rustls",
50+
]

sdk/storage_blobs/examples/stream_blob_01.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
4141

4242
fn get_blob_stream(
4343
blob_client: &'_ BlobClient,
44-
) -> impl futures::Stream<Item = Result<GetBlobResponse, Box<dyn std::error::Error + Send + Sync>>> + '_
45-
{
44+
) -> impl futures::Stream<Item = Result<GetBlobResponse, azure_core::error::Error>> + '_ {
4645
let stream = blob_client.get().stream(1024);
4746
stream
4847
}

sdk/storage_blobs/src/blob/requests/acquire_lease_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::AcquireBlobLeaseResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::LEASE_ACTION;
45
use azure_core::headers::{add_mandatory_header, add_optional_header, add_optional_header_ref};
56
use azure_core::prelude::*;
@@ -33,9 +34,7 @@ impl<'a> AcquireLeaseBuilder<'a> {
3334
client_request_id: ClientRequestId => Some(client_request_id),
3435
}
3536

36-
pub async fn execute(
37-
self,
38-
) -> Result<AcquireBlobLeaseResponse, Box<dyn std::error::Error + Send + Sync>> {
37+
pub async fn execute(self) -> Result<AcquireBlobLeaseResponse> {
3938
let mut url = self.blob_client.url_with_segments(None)?;
4039

4140
url.query_pairs_mut().append_pair("comp", "lease");
@@ -63,6 +62,6 @@ impl<'a> AcquireLeaseBuilder<'a> {
6362
.execute_request_check_status(request, http::StatusCode::CREATED)
6463
.await?;
6564

66-
Ok(AcquireBlobLeaseResponse::from_headers(response.headers())?)
65+
AcquireBlobLeaseResponse::from_headers(response.headers())
6766
}
6867
}

sdk/storage_blobs/src/blob/requests/append_block_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::PutBlockResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::{add_optional_header, add_optional_header_ref};
45
use azure_core::prelude::*;
56
use bytes::Bytes;
@@ -39,9 +40,7 @@ impl<'a> AppendBlockBuilder<'a> {
3940
timeout: Timeout => Some(timeout),
4041
}
4142

42-
pub async fn execute(
43-
&self,
44-
) -> Result<PutBlockResponse, Box<dyn std::error::Error + Send + Sync>> {
43+
pub async fn execute(&self) -> Result<PutBlockResponse> {
4544
let mut url = self.blob_client.url_with_segments(None)?;
4645

4746
self.timeout.append_to_url_query(&mut url);
@@ -71,6 +70,6 @@ impl<'a> AppendBlockBuilder<'a> {
7170

7271
debug!("response.headers() == {:#?}", response.headers());
7372

74-
Ok(PutBlockResponse::from_headers(response.headers())?)
73+
PutBlockResponse::from_headers(response.headers())
7574
}
7675
}

sdk/storage_blobs/src/blob/requests/break_lease_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::BreakBlobLeaseResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::LEASE_ACTION;
45
use azure_core::headers::{add_optional_header, add_optional_header_ref};
56
use azure_core::prelude::*;
@@ -31,9 +32,7 @@ impl<'a> BreakLeaseBuilder<'a> {
3132
timeout: Timeout => Some(timeout),
3233
}
3334

34-
pub async fn execute(
35-
&self,
36-
) -> Result<BreakBlobLeaseResponse, Box<dyn std::error::Error + Send + Sync>> {
35+
pub async fn execute(&self) -> Result<BreakBlobLeaseResponse> {
3736
let mut url = self.blob_client.url_with_segments(None)?;
3837

3938
url.query_pairs_mut().append_pair("comp", "lease");
@@ -60,6 +59,6 @@ impl<'a> BreakLeaseBuilder<'a> {
6059
.execute_request_check_status(request, http::StatusCode::ACCEPTED)
6160
.await?;
6261

63-
Ok(BreakBlobLeaseResponse::from_headers(response.headers())?)
62+
BreakBlobLeaseResponse::from_headers(response.headers())
6463
}
6564
}

sdk/storage_blobs/src/blob/requests/change_lease_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::ChangeBlobLeaseResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::LEASE_ACTION;
45
use azure_core::headers::{add_mandatory_header, add_optional_header};
56
use azure_core::prelude::*;
@@ -30,9 +31,7 @@ impl<'a> ChangeLeaseBuilder<'a> {
3031
timeout: Timeout => Some(timeout),
3132
}
3233

33-
pub async fn execute(
34-
&self,
35-
) -> Result<ChangeBlobLeaseResponse, Box<dyn std::error::Error + Send + Sync>> {
34+
pub async fn execute(&self) -> Result<ChangeBlobLeaseResponse> {
3635
let mut url = self.blob_lease_client.url_with_segments(None)?;
3736

3837
url.query_pairs_mut().append_pair("comp", "lease");
@@ -59,6 +58,6 @@ impl<'a> ChangeLeaseBuilder<'a> {
5958
.execute_request_check_status(request, http::StatusCode::OK)
6059
.await?;
6160

62-
Ok(ChangeBlobLeaseResponse::from_headers(response.headers())?)
61+
ChangeBlobLeaseResponse::from_headers(response.headers())
6362
}
6463
}

sdk/storage_blobs/src/blob/requests/clear_page_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::blob::responses::ClearPageResponse;
22
use crate::prelude::*;
33
use crate::BA512Range;
4+
use azure_core::error::Result;
45
use azure_core::headers::{
56
add_mandatory_header, add_optional_header, add_optional_header_ref, BLOB_TYPE, PAGE_WRITE,
67
};
@@ -41,9 +42,7 @@ impl<'a> ClearPageBuilder<'a> {
4142
lease_id: &'a LeaseId => Some(lease_id),
4243
}
4344

44-
pub async fn execute(
45-
&self,
46-
) -> Result<ClearPageResponse, Box<dyn std::error::Error + Send + Sync>> {
45+
pub async fn execute(&self) -> Result<ClearPageResponse> {
4746
let mut url = self.blob_client.url_with_segments(None)?;
4847

4948
self.timeout.append_to_url_query(&mut url);
@@ -78,6 +77,6 @@ impl<'a> ClearPageBuilder<'a> {
7877

7978
debug!("response.headers() == {:#?}", response.headers());
8079

81-
Ok(ClearPageResponse::from_headers(response.headers())?)
80+
ClearPageResponse::from_headers(response.headers())
8281
}
8382
}

sdk/storage_blobs/src/blob/requests/copy_blob_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::blob::responses::CopyBlobResponse;
22
use crate::prelude::*;
33
use crate::RehydratePriority;
4+
use azure_core::error::Result;
45
use azure_core::headers::COPY_SOURCE;
56
use azure_core::headers::{add_mandatory_header, add_optional_header, add_optional_header_ref};
67
use azure_core::prelude::*;
@@ -60,9 +61,7 @@ impl<'a> CopyBlobBuilder<'a> {
6061
rehydrate_priority: RehydratePriority => rehydrate_priority,
6162
}
6263

63-
pub async fn execute(
64-
&self,
65-
) -> Result<CopyBlobResponse, Box<dyn std::error::Error + Send + Sync>> {
64+
pub async fn execute(&self) -> Result<CopyBlobResponse> {
6665
let mut url = self.blob_client.url_with_segments(None)?;
6766

6867
self.timeout.append_to_url_query(&mut url);
@@ -102,6 +101,6 @@ impl<'a> CopyBlobBuilder<'a> {
102101

103102
debug!("response.headers() == {:#?}", response.headers());
104103

105-
Ok((response.headers()).try_into()?)
104+
(response.headers()).try_into()
106105
}
107106
}

sdk/storage_blobs/src/blob/requests/copy_blob_from_url_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::SourceContentMD5;
22
use crate::blob::responses::CopyBlobFromUrlResponse;
33
use crate::prelude::*;
4+
use azure_core::error::Result;
45
use azure_core::headers::{
56
add_mandatory_header, add_optional_header, add_optional_header_ref, COPY_SOURCE, REQUIRES_SYNC,
67
};
@@ -53,9 +54,7 @@ impl<'a> CopyBlobFromUrlBuilder<'a> {
5354
source_content_md5: &'a SourceContentMD5 => Some(source_content_md5),
5455
}
5556

56-
pub async fn execute(
57-
&self,
58-
) -> Result<CopyBlobFromUrlResponse, Box<dyn std::error::Error + Send + Sync>> {
57+
pub async fn execute(&self) -> Result<CopyBlobFromUrlResponse> {
5958
let mut url = self.blob_client.url_with_segments(None)?;
6059

6160
self.timeout.append_to_url_query(&mut url);
@@ -93,6 +92,6 @@ impl<'a> CopyBlobFromUrlBuilder<'a> {
9392

9493
debug!("response.headers() == {:#?}", response.headers());
9594

96-
Ok((response.headers()).try_into()?)
95+
(response.headers()).try_into()
9796
}
9897
}

sdk/storage_blobs/src/blob/requests/delete_blob_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::DeleteBlobResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::{add_mandatory_header, add_optional_header, add_optional_header_ref};
45
use azure_core::prelude::*;
56

@@ -30,9 +31,7 @@ impl<'a> DeleteBlobBuilder<'a> {
3031
client_request_id: ClientRequestId => Some(client_request_id),
3132
}
3233

33-
pub async fn execute(
34-
&self,
35-
) -> Result<DeleteBlobResponse, Box<dyn std::error::Error + Send + Sync>> {
34+
pub async fn execute(&self) -> Result<DeleteBlobResponse> {
3635
let mut url = self.blob_client.url_with_segments(None)?;
3736

3837
self.timeout.append_to_url_query(&mut url);
@@ -59,6 +58,6 @@ impl<'a> DeleteBlobBuilder<'a> {
5958

6059
debug!("response.headers() == {:#?}", response.headers());
6160

62-
Ok(DeleteBlobResponse::from_headers(response.headers())?)
61+
DeleteBlobResponse::from_headers(response.headers())
6362
}
6463
}

sdk/storage_blobs/src/blob/requests/delete_blob_snapshot_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::DeleteBlobResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::{add_optional_header, add_optional_header_ref};
45
use azure_core::prelude::*;
56

@@ -32,9 +33,7 @@ impl<'a> DeleteBlobSnapshotBuilder<'a> {
3233
client_request_id: ClientRequestId => Some(client_request_id),
3334
}
3435

35-
pub async fn execute(
36-
&self,
37-
) -> Result<DeleteBlobResponse, Box<dyn std::error::Error + Send + Sync>> {
36+
pub async fn execute(&self) -> Result<DeleteBlobResponse> {
3837
let mut url = self.blob_client.url_with_segments(None)?;
3938

4039
self.timeout.append_to_url_query(&mut url);
@@ -64,6 +63,6 @@ impl<'a> DeleteBlobSnapshotBuilder<'a> {
6463

6564
debug!("response.headers() == {:#?}", response.headers());
6665

67-
Ok(DeleteBlobResponse::from_headers(response.headers())?)
66+
DeleteBlobResponse::from_headers(response.headers())
6867
}
6968
}

sdk/storage_blobs/src/blob/requests/delete_blob_version_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::DeleteBlobResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::{add_optional_header, add_optional_header_ref};
45
use azure_core::prelude::*;
56

@@ -32,9 +33,7 @@ impl<'a> DeleteBlobVersionBuilder<'a> {
3233
client_request_id: ClientRequestId => Some(client_request_id),
3334
}
3435

35-
pub async fn execute(
36-
&self,
37-
) -> Result<DeleteBlobResponse, Box<dyn std::error::Error + Send + Sync>> {
36+
pub async fn execute(&self) -> Result<DeleteBlobResponse> {
3837
let mut url = self.blob_client.url_with_segments(None)?;
3938

4039
self.timeout.append_to_url_query(&mut url);
@@ -64,6 +63,6 @@ impl<'a> DeleteBlobVersionBuilder<'a> {
6463

6564
debug!("response.headers() == {:#?}", response.headers());
6665

67-
Ok(DeleteBlobResponse::from_headers(response.headers())?)
66+
DeleteBlobResponse::from_headers(response.headers())
6867
}
6968
}

sdk/storage_blobs/src/blob/requests/get_blob_builder.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::blob::responses::GetBlobResponse;
22
use crate::prelude::*;
33
use crate::Header;
4+
use azure_core::error::Result;
45
use azure_core::headers::AsHeaders;
56
use azure_core::headers::{add_optional_header, add_optional_header_ref, CLIENT_REQUEST_ID};
67
use azure_core::prelude::*;
@@ -64,9 +65,7 @@ impl<'a> GetBlobBuilder<'a> {
6465
lease_id: &'a LeaseId => Some(lease_id),
6566
}
6667

67-
pub async fn execute(
68-
&self,
69-
) -> Result<GetBlobResponse, Box<dyn std::error::Error + Send + Sync>> {
68+
pub async fn execute(&self) -> Result<GetBlobResponse> {
7069
let mut url = self.blob_client.url_with_segments(None)?;
7170

7271
self.blob_versioning.append_to_url_query(&mut url);
@@ -104,14 +103,10 @@ impl<'a> GetBlobBuilder<'a> {
104103
.execute_request_check_status(request, expected_status_code)
105104
.await?;
106105

107-
Ok((self.blob_client.blob_name(), response).try_into()?)
106+
(self.blob_client.blob_name(), response).try_into()
108107
}
109108

110-
pub fn stream(
111-
self,
112-
chunk_size: u64,
113-
) -> impl Stream<Item = Result<GetBlobResponse, Box<dyn std::error::Error + Send + Sync>>> + 'a
114-
{
109+
pub fn stream(self, chunk_size: u64) -> impl Stream<Item = Result<GetBlobResponse>> + 'a {
115110
enum States {
116111
Init,
117112
Progress(Range),

sdk/storage_blobs/src/blob/requests/get_blob_metadata_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::blob::responses::GetBlobMetadataResponse;
22
use crate::prelude::*;
3+
use azure_core::error::Result;
34
use azure_core::headers::{add_optional_header, add_optional_header_ref};
45
use azure_core::prelude::*;
56
use std::convert::TryInto;
@@ -31,9 +32,7 @@ impl<'a> GetBlobMetadataBuilder<'a> {
3132
client_request_id: ClientRequestId => Some(client_request_id),
3233
}
3334

34-
pub async fn execute(
35-
self,
36-
) -> Result<GetBlobMetadataResponse, Box<dyn std::error::Error + Send + Sync>> {
35+
pub async fn execute(self) -> Result<GetBlobMetadataResponse> {
3736
let mut url = self.blob_client.url_with_segments(None)?;
3837

3938
url.query_pairs_mut().append_pair("comp", "metadata");
@@ -59,6 +58,6 @@ impl<'a> GetBlobMetadataBuilder<'a> {
5958
.execute_request_check_status(request, http::StatusCode::OK)
6059
.await?;
6160

62-
Ok(response.headers().try_into()?)
61+
response.headers().try_into()
6362
}
6463
}

sdk/storage_blobs/src/blob/requests/get_block_list_builder.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::blob::responses::GetBlockListResponse;
22
use crate::blob::BlockListType;
33
use crate::prelude::*;
4+
use azure_core::error::Result;
45
use azure_core::headers::{add_optional_header, add_optional_header_ref};
56
use azure_core::prelude::*;
67

@@ -33,9 +34,7 @@ impl<'a> GetBlockListBuilder<'a> {
3334
timeout: Timeout => Some(timeout),
3435
}
3536

36-
pub async fn execute(
37-
&self,
38-
) -> Result<GetBlockListResponse, Box<dyn std::error::Error + Send + Sync>> {
37+
pub async fn execute(&self) -> Result<GetBlockListResponse> {
3938
let mut url = self.blob_client.url_with_segments(None)?;
4039

4140
url.query_pairs_mut().append_pair("comp", "blocklist");
@@ -64,9 +63,6 @@ impl<'a> GetBlockListBuilder<'a> {
6463

6564
debug!("response.headers() == {:#?}", response.headers());
6665

67-
Ok(GetBlockListResponse::from_response(
68-
response.headers(),
69-
response.body(),
70-
)?)
66+
GetBlockListResponse::from_response(response.headers(), response.body())
7167
}
7268
}

0 commit comments

Comments
 (0)