Skip to content

Commit 1b51eed

Browse files
bmc-msftdemoray
andauthored
specify additional conditional headers for blob & container operations (#951)
* specify additional conditional headers for blob & container operations Ref: https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations * fmt * address clippy Co-authored-by: Brian Caswell <bcaswell@microsoft.com>
1 parent 537daf7 commit 1b51eed

21 files changed

+123
-33
lines changed

sdk/storage_blobs/examples/put_page_blob_00.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async fn main() -> azure_core::Result<()> {
7474
let res = blob_client
7575
.put_page(BA512Range::new(512, 1023)?, slice)
7676
.hash(digest)
77-
.sequence_number_condition(SequenceNumberCondition::Equal(100))
77+
.if_sequence_number(SequenceNumberCondition::Equal(100))
7878
.into_future()
7979
.await?;
8080
println!("update sequence number condition == {:?}", res);

sdk/storage_blobs/src/blob/operations/append_block.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ operation! {
88
?hash: Hash,
99
?condition_max_size: ConditionMaxSize,
1010
?condition_append_position: ConditionAppendPosition,
11+
?if_modified_since: IfModifiedSinceCondition,
12+
?if_match: IfMatchCondition,
13+
?if_tag: IfTagsCondition,
1114
?lease_id: LeaseId
1215
}
1316

@@ -22,6 +25,8 @@ impl AppendBlockBuilder {
2225
headers.add(self.hash);
2326
headers.add(self.condition_max_size);
2427
headers.add(self.condition_append_position);
28+
headers.add(self.if_modified_since);
29+
headers.add(self.if_match);
2530
headers.add(self.lease_id);
2631

2732
let mut request = self.client.finalize_request(

sdk/storage_blobs/src/blob/operations/clear_page.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ operation! {
1010
ClearPage,
1111
client: BlobClient,
1212
ba512_range: BA512Range,
13-
?sequence_number_condition: SequenceNumberCondition,
14-
?if_modified_since_condition: IfModifiedSinceCondition,
15-
?if_match_condition: IfMatchCondition,
13+
?if_sequence_number: SequenceNumberCondition,
14+
?if_modified_since: IfModifiedSinceCondition,
15+
?if_match: IfMatchCondition,
1616
?lease_id: LeaseId
1717
}
1818

@@ -27,9 +27,9 @@ impl ClearPageBuilder {
2727
headers.insert(PAGE_WRITE, "clear");
2828
headers.insert(BLOB_TYPE, "PageBlob");
2929
headers.add(self.ba512_range);
30-
headers.add(self.sequence_number_condition);
31-
headers.add(self.if_modified_since_condition);
32-
headers.add(self.if_match_condition);
30+
headers.add(self.if_sequence_number);
31+
headers.add(self.if_modified_since);
32+
headers.add(self.if_match);
3333
headers.add(self.lease_id);
3434

3535
let mut request =

sdk/storage_blobs/src/blob/operations/copy_blob.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ operation! {
1313
client: BlobClient,
1414
source_url: Url,
1515
?metadata: Metadata,
16-
?sequence_number_condition: SequenceNumberCondition,
17-
?if_modified_since_condition: IfModifiedSinceCondition,
18-
?if_match_condition: IfMatchCondition,
16+
?if_sequence_number: SequenceNumberCondition,
17+
?if_modified_since: IfModifiedSinceCondition,
18+
?if_match: IfMatchCondition,
19+
?if_tags: IfTagsCondition,
1920
?access_tier: AccessTier,
2021
?lease_id: LeaseId,
21-
?if_source_since_condition: IfSourceModifiedSinceCondition,
22-
?if_source_match_condition: IfSourceMatchCondition,
22+
?if_source_since: IfSourceModifiedSinceCondition,
23+
?if_source_match: IfSourceMatchCondition,
2324
?source_lease_id: SourceLeaseId,
2425
?rehydrate_priority: RehydratePriority
2526
}
@@ -36,13 +37,13 @@ impl CopyBlobBuilder {
3637
headers.add(m);
3738
}
3839
}
39-
headers.add(self.sequence_number_condition);
40-
headers.add(self.if_modified_since_condition);
41-
headers.add(self.if_match_condition);
40+
headers.add(self.if_sequence_number);
41+
headers.add(self.if_modified_since);
42+
headers.add(self.if_match);
4243
headers.add(self.access_tier);
4344
headers.add(self.lease_id);
44-
headers.add(self.if_source_since_condition);
45-
headers.add(self.if_source_match_condition);
45+
headers.add(self.if_source_since);
46+
headers.add(self.if_source_match);
4647
headers.add(self.source_lease_id);
4748
headers.add(
4849
self.rehydrate_priority

sdk/storage_blobs/src/blob/operations/copy_blob_from_url.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ operation! {
1818
source_url: Url,
1919
?is_synchronous: bool,
2020
?metadata: Metadata,
21-
?if_modified_since_condition: IfModifiedSinceCondition,
22-
?if_match_condition: IfMatchCondition,
21+
?if_modified_since: IfModifiedSinceCondition,
22+
?if_match: IfMatchCondition,
23+
?if_source_since: IfSourceModifiedSinceCondition,
24+
?if_source_match: IfSourceMatchCondition,
2325
?lease_id: LeaseId,
24-
?if_source_since_condition: IfSourceModifiedSinceCondition,
25-
?if_source_match_condition: IfSourceMatchCondition,
2626
?source_content_md5: SourceContentMD5
2727
}
2828

@@ -42,11 +42,11 @@ impl CopyBlobFromUrlBuilder {
4242
headers.add(m);
4343
}
4444
}
45-
headers.add(self.if_modified_since_condition);
46-
headers.add(self.if_match_condition);
45+
headers.add(self.if_modified_since);
46+
headers.add(self.if_match);
4747
headers.add(self.lease_id);
48-
headers.add(self.if_source_since_condition);
49-
headers.add(self.if_source_match_condition);
48+
headers.add(self.if_source_since);
49+
headers.add(self.if_source_match);
5050
headers.add(self.source_content_md5);
5151

5252
let mut request =

sdk/storage_blobs/src/blob/operations/delete_blob.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ use chrono::{DateTime, Utc};
55
operation! {
66
DeleteBlob,
77
client: BlobClient,
8+
?if_modified_since: IfModifiedSinceCondition,
9+
?if_match: IfMatchCondition,
10+
?if_tags: IfTagsCondition,
811
?delete_snapshots_method: DeleteSnapshotsMethod,
912
?lease_id: LeaseId
1013
}
@@ -20,6 +23,9 @@ impl DeleteBlobBuilder {
2023
self.delete_snapshots_method
2124
.unwrap_or(DeleteSnapshotsMethod::Include),
2225
);
26+
headers.add(self.if_modified_since);
27+
headers.add(self.if_match);
28+
headers.add(self.if_tags);
2329

2430
let mut request =
2531
self.client

sdk/storage_blobs/src/blob/operations/get_blob.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ operation! {
1515
?range: Range,
1616
?blob_versioning: BlobVersioning,
1717
?lease_id: LeaseId,
18-
?chunk_size: u64
18+
?chunk_size: u64,
19+
?if_modified_since: IfModifiedSinceCondition,
20+
?if_match: IfMatchCondition,
21+
?if_tags: IfTagsCondition,
1922
}
2023

2124
impl GetBlobBuilder {
@@ -41,6 +44,9 @@ impl GetBlobBuilder {
4144
}
4245

4346
headers.add(this.lease_id);
47+
headers.add(this.if_modified_since);
48+
headers.add(this.if_match.clone());
49+
headers.add(this.if_tags.clone());
4450

4551
let mut request =
4652
this.client

sdk/storage_blobs/src/blob/operations/get_block_list.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::str::from_utf8;
99
operation! {
1010
GetBlockList,
1111
client: BlobClient,
12+
?if_tags: IfTagsCondition,
1213
?block_list_type: BlockListType,
1314
?blob_versioning: BlobVersioning,
1415
?lease_id: LeaseId
@@ -28,6 +29,7 @@ impl GetBlockListBuilder {
2829

2930
let mut headers = Headers::new();
3031
headers.add(self.lease_id);
32+
headers.add(self.if_tags);
3133

3234
let mut request =
3335
self.client

sdk/storage_blobs/src/blob/operations/get_metadata.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use std::convert::{TryFrom, TryInto};
66
operation! {
77
GetMetadata,
88
client: BlobClient,
9+
?if_modified_since: IfModifiedSinceCondition,
10+
?if_match: IfMatchCondition,
11+
?if_tags: IfTagsCondition,
912
?blob_versioning: BlobVersioning,
1013
?lease_id: LeaseId
1114
}
@@ -20,6 +23,9 @@ impl GetMetadataBuilder {
2023

2124
let mut headers = Headers::new();
2225
headers.add(self.lease_id);
26+
headers.add(self.if_modified_since);
27+
headers.add(self.if_match);
28+
headers.add(self.if_tags);
2329

2430
let mut request = self
2531
.client

sdk/storage_blobs/src/blob/operations/get_page_ranges.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use std::str::from_utf8;
66
operation! {
77
GetPageRanges,
88
client: BlobClient,
9+
?if_modified_since: IfModifiedSinceCondition,
10+
?if_match: IfMatchCondition,
11+
?if_tags: IfTagsCondition,
912
?blob_versioning: BlobVersioning,
1013
?lease_id: LeaseId
1114
}
@@ -20,6 +23,9 @@ impl GetPageRangesBuilder {
2023

2124
let mut headers = Headers::new();
2225
headers.add(self.lease_id);
26+
headers.add(self.if_modified_since);
27+
headers.add(self.if_match);
28+
headers.add(self.if_tags);
2329

2430
let mut request =
2531
self.client

0 commit comments

Comments
 (0)