Skip to content

Commit 94ac9ca

Browse files
committed
Storage/Stg101/Source Customer Provided Key and AccessTierConditions for Delete Blob API (#6869)
* Source CMK and Delete condition for AccessTier * Rename * Fix Cspell
1 parent 579af3e commit 94ac9ca

File tree

10 files changed

+138
-31
lines changed

10 files changed

+138
-31
lines changed

sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,42 @@ namespace Azure { namespace Storage { namespace Blobs {
8585
Azure::Nullable<std::string> TagConditions;
8686
};
8787

88+
/**
89+
* @brief Specifies HTTP options for conditional requests based on AccessTier.
90+
*/
91+
struct AccessTierAccessConditions
92+
{
93+
/**
94+
* @brief Destructor.
95+
*
96+
*/
97+
virtual ~AccessTierAccessConditions() = default;
98+
99+
/**
100+
* @brief Specify this header value to operate only on a blob if the access-tier has been
101+
* modified since the specified date/time. Note: If this is specified,
102+
* AccessTierIfUnmodifiedSince cannot be specified.
103+
* Only valid for Delete Blob API.
104+
*/
105+
Azure::Nullable<Azure::DateTime> AccessTierIfModifiedSince;
106+
107+
/**
108+
* @brief Specify this header value to operate only on a blob if the access-tier has not been
109+
* modified since the specified date/time. Note: If this is specified, AccessTierIfModifiedSince
110+
* cannot be specified.
111+
* Only valid for Delete Blob API.
112+
*/
113+
Azure::Nullable<Azure::DateTime> AccessTierIfUnmodifiedSince;
114+
};
115+
88116
/**
89117
* @brief Specifies access conditions for a blob.
90118
*/
91119
struct BlobAccessConditions : public Azure::ModifiedConditions,
92120
public Azure::MatchConditions,
93121
public LeaseAccessConditions,
94-
public TagAccessConditions
122+
public TagAccessConditions,
123+
public AccessTierAccessConditions
95124
{
96125
};
97126

@@ -1086,6 +1115,12 @@ namespace Azure { namespace Storage { namespace Blobs {
10861115
* token authentication. Used to indicate the intent of the request.
10871116
*/
10881117
Azure::Nullable<Models::FileShareTokenIntent> FileRequestIntent;
1118+
1119+
/**
1120+
* Optional. Specifies the source customer provided key to use to encrypt the source blob.
1121+
* Applicable only for service version 2026-02-06 or later.
1122+
*/
1123+
Azure::Nullable<EncryptionKey> SourceCustomerProvidedKey;
10891124
};
10901125

10911126
/**
@@ -1153,6 +1188,12 @@ namespace Azure { namespace Storage { namespace Blobs {
11531188
* token authentication. Used to indicate the intent of the request.
11541189
*/
11551190
Azure::Nullable<Models::FileShareTokenIntent> FileRequestIntent;
1191+
1192+
/**
1193+
* Optional. Specifies the source customer provided key to use to encrypt the source blob.
1194+
* Applicable only for service version 2026-02-06 or later.
1195+
*/
1196+
Azure::Nullable<EncryptionKey> SourceCustomerProvidedKey;
11561197
};
11571198

11581199
/**
@@ -1457,6 +1498,12 @@ namespace Azure { namespace Storage { namespace Blobs {
14571498
* token authentication. Used to indicate the intent of the request.
14581499
*/
14591500
Azure::Nullable<Models::FileShareTokenIntent> FileRequestIntent;
1501+
1502+
/**
1503+
* Optional. Specifies the source customer provided key to use to encrypt the source blob.
1504+
* Applicable only for service version 2026-02-06 or later.
1505+
*/
1506+
Azure::Nullable<EncryptionKey> SourceCustomerProvidedKey;
14601507
};
14611508

14621509
/**
@@ -1579,6 +1626,12 @@ namespace Azure { namespace Storage { namespace Blobs {
15791626
* token authentication. Used to indicate the intent of the request.
15801627
*/
15811628
Azure::Nullable<Models::FileShareTokenIntent> FileRequestIntent;
1629+
1630+
/**
1631+
* Optional. Specifies the source customer provided key to use to encrypt the source blob.
1632+
* Applicable only for service version 2026-02-06 or later.
1633+
*/
1634+
Azure::Nullable<EncryptionKey> SourceCustomerProvidedKey;
15821635
};
15831636

15841637
/**

sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/rest_client.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace Azure { namespace Storage { namespace Blobs {
3636
} // namespace _detail
3737
namespace Models {
3838
/**
39-
* @brief The algorithm used to produce the source encryption key hash. Currently, the only
40-
* accepted value is "AES256". Must be provided if the x-ms-source-encryption-key is provided.
39+
* @brief The algorithm used to produce the encryption key hash. Currently, the only accepted
40+
* value is "AES256". Must be provided if the x-ms-encryption-key header is provided.
4141
*/
4242
class EncryptionAlgorithmType final
4343
: public Core::_internal::ExtendableEnumeration<EncryptionAlgorithmType> {
@@ -4041,8 +4041,8 @@ namespace Azure { namespace Storage { namespace Blobs {
40414041
Nullable<std::string> CopySourceAuthorization;
40424042
Nullable<Models::FileShareTokenIntent> FileRequestIntent;
40434043
Nullable<std::string> SourceEncryptionKey;
4044-
Nullable<std::string> SourceEncryptionKeySha256;
4045-
Nullable<Models::EncryptionAlgorithmType> SourceEncryptionAlgorithm;
4044+
Nullable<std::vector<std::uint8_t>> SourceEncryptionKeySha256;
4045+
Nullable<std::string> SourceEncryptionAlgorithm;
40464046
};
40474047
static Response<Models::UploadPagesFromUriResult> UploadPagesFromUri(
40484048
Core::Http::_internal::HttpPipeline& pipeline,
@@ -4219,8 +4219,8 @@ namespace Azure { namespace Storage { namespace Blobs {
42194219
Nullable<std::string> CopySourceAuthorization;
42204220
Nullable<Models::FileShareTokenIntent> FileRequestIntent;
42214221
Nullable<std::string> SourceEncryptionKey;
4222-
Nullable<std::string> SourceEncryptionKeySha256;
4223-
Nullable<Models::EncryptionAlgorithmType> SourceEncryptionAlgorithm;
4222+
Nullable<std::vector<std::uint8_t>> SourceEncryptionKeySha256;
4223+
Nullable<std::string> SourceEncryptionAlgorithm;
42244224
};
42254225
static Response<Models::AppendBlockFromUriResult> AppendBlockFromUri(
42264226
Core::Http::_internal::HttpPipeline& pipeline,
@@ -4312,8 +4312,8 @@ namespace Azure { namespace Storage { namespace Blobs {
43124312
Nullable<Models::BlobCopySourceTagsMode> CopySourceTags;
43134313
Nullable<Models::FileShareTokenIntent> FileRequestIntent;
43144314
Nullable<std::string> SourceEncryptionKey;
4315-
Nullable<std::string> SourceEncryptionKeySha256;
4316-
Nullable<Models::EncryptionAlgorithmType> SourceEncryptionAlgorithm;
4315+
Nullable<std::vector<std::uint8_t>> SourceEncryptionKeySha256;
4316+
Nullable<std::string> SourceEncryptionAlgorithm;
43174317
Nullable<std::vector<std::uint8_t>> SourceContentcrc64;
43184318
};
43194319
static Response<Models::UploadBlockBlobFromUriResult> UploadFromUri(
@@ -4359,8 +4359,8 @@ namespace Azure { namespace Storage { namespace Blobs {
43594359
Nullable<std::string> CopySourceAuthorization;
43604360
Nullable<Models::FileShareTokenIntent> FileRequestIntent;
43614361
Nullable<std::string> SourceEncryptionKey;
4362-
Nullable<std::string> SourceEncryptionKeySha256;
4363-
Nullable<Models::EncryptionAlgorithmType> SourceEncryptionAlgorithm;
4362+
Nullable<std::vector<std::uint8_t>> SourceEncryptionKeySha256;
4363+
Nullable<std::string> SourceEncryptionAlgorithm;
43644364
};
43654365
static Response<Models::StageBlockFromUriResult> StageBlockFromUri(
43664366
Core::Http::_internal::HttpPipeline& pipeline,

sdk/storage/azure-storage-blobs/src/append_blob_client.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ namespace Azure { namespace Storage { namespace Blobs {
240240
protocolLayerOptions.CopySourceAuthorization = options.SourceAuthorization;
241241
}
242242
protocolLayerOptions.FileRequestIntent = options.FileRequestIntent;
243+
if (options.SourceCustomerProvidedKey.HasValue())
244+
{
245+
protocolLayerOptions.SourceEncryptionKey = options.SourceCustomerProvidedKey.Value().Key;
246+
protocolLayerOptions.SourceEncryptionKeySha256
247+
= options.SourceCustomerProvidedKey.Value().KeyHash;
248+
protocolLayerOptions.SourceEncryptionAlgorithm
249+
= options.SourceCustomerProvidedKey.Value().Algorithm.ToString();
250+
}
243251

244252
return _detail::AppendBlobClient::AppendBlockFromUri(
245253
*m_pipeline, m_blobUrl, protocolLayerOptions, context);

sdk/storage/azure-storage-blobs/src/blob_client.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,10 @@ namespace Azure { namespace Storage { namespace Blobs {
854854
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
855855
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
856856
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
857+
protocolLayerOptions.AccessTierIfModifiedSince
858+
= options.AccessConditions.AccessTierIfModifiedSince;
859+
protocolLayerOptions.AccessTierIfUnmodifiedSince
860+
= options.AccessConditions.AccessTierIfUnmodifiedSince;
857861
return _detail::BlobClient::Delete(*m_pipeline, m_blobUrl, protocolLayerOptions, context);
858862
}
859863

sdk/storage/azure-storage-blobs/src/block_blob_client.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ namespace Azure { namespace Storage { namespace Blobs {
408408
protocolLayerOptions.CopySourceAuthorization = options.SourceAuthorization;
409409
}
410410
protocolLayerOptions.FileRequestIntent = options.FileRequestIntent;
411+
if (options.SourceCustomerProvidedKey.HasValue())
412+
{
413+
protocolLayerOptions.SourceEncryptionKey = options.SourceCustomerProvidedKey.Value().Key;
414+
protocolLayerOptions.SourceEncryptionKeySha256
415+
= options.SourceCustomerProvidedKey.Value().KeyHash;
416+
protocolLayerOptions.SourceEncryptionAlgorithm
417+
= options.SourceCustomerProvidedKey.Value().Algorithm.ToString();
418+
}
411419

412420
return _detail::BlockBlobClient::UploadFromUri(
413421
*m_pipeline, m_blobUrl, protocolLayerOptions, context);
@@ -512,6 +520,14 @@ namespace Azure { namespace Storage { namespace Blobs {
512520
protocolLayerOptions.CopySourceAuthorization = options.SourceAuthorization;
513521
}
514522
protocolLayerOptions.FileRequestIntent = options.FileRequestIntent;
523+
if (options.SourceCustomerProvidedKey.HasValue())
524+
{
525+
protocolLayerOptions.SourceEncryptionKey = options.SourceCustomerProvidedKey.Value().Key;
526+
protocolLayerOptions.SourceEncryptionKeySha256
527+
= options.SourceCustomerProvidedKey.Value().KeyHash;
528+
protocolLayerOptions.SourceEncryptionAlgorithm
529+
= options.SourceCustomerProvidedKey.Value().Algorithm.ToString();
530+
}
515531

516532
return _detail::BlockBlobClient::StageBlockFromUri(
517533
*m_pipeline, m_blobUrl, protocolLayerOptions, context);

sdk/storage/azure-storage-blobs/src/page_blob_client.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,15 @@ namespace Azure { namespace Storage { namespace Blobs {
258258
protocolLayerOptions.CopySourceAuthorization = options.SourceAuthorization;
259259
}
260260
protocolLayerOptions.FileRequestIntent = options.FileRequestIntent;
261+
if (options.SourceCustomerProvidedKey.HasValue())
262+
{
263+
protocolLayerOptions.SourceEncryptionKey
264+
= options.SourceCustomerProvidedKey.Value().Key;
265+
protocolLayerOptions.SourceEncryptionKeySha256
266+
= options.SourceCustomerProvidedKey.Value().KeyHash;
267+
protocolLayerOptions.SourceEncryptionAlgorithm
268+
= options.SourceCustomerProvidedKey.Value().Algorithm.ToString();
269+
}
261270

262271
return _detail::PageBlobClient::UploadPagesFromUri(
263272
*m_pipeline, m_blobUrl, protocolLayerOptions, context);

sdk/storage/azure-storage-blobs/src/rest_client.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6478,17 +6478,17 @@ namespace Azure { namespace Storage { namespace Blobs {
64786478
request.SetHeader("x-ms-source-encryption-key", options.SourceEncryptionKey.Value());
64796479
}
64806480
if (options.SourceEncryptionKeySha256.HasValue()
6481-
&& !options.SourceEncryptionKeySha256.Value().empty())
6481+
&& !Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()).empty())
64826482
{
64836483
request.SetHeader(
6484-
"x-ms-source-encryption-key-sha256", options.SourceEncryptionKeySha256.Value());
6484+
"x-ms-source-encryption-key-sha256",
6485+
Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()));
64856486
}
64866487
if (options.SourceEncryptionAlgorithm.HasValue()
6487-
&& !options.SourceEncryptionAlgorithm.Value().ToString().empty())
6488+
&& !options.SourceEncryptionAlgorithm.Value().empty())
64886489
{
64896490
request.SetHeader(
6490-
"x-ms-source-encryption-algorithm",
6491-
options.SourceEncryptionAlgorithm.Value().ToString());
6491+
"x-ms-source-encryption-algorithm", options.SourceEncryptionAlgorithm.Value());
64926492
}
64936493
auto pRawResponse = pipeline.Send(request, context);
64946494
auto httpStatusCode = pRawResponse->GetStatusCode();
@@ -7490,17 +7490,17 @@ namespace Azure { namespace Storage { namespace Blobs {
74907490
request.SetHeader("x-ms-source-encryption-key", options.SourceEncryptionKey.Value());
74917491
}
74927492
if (options.SourceEncryptionKeySha256.HasValue()
7493-
&& !options.SourceEncryptionKeySha256.Value().empty())
7493+
&& !Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()).empty())
74947494
{
74957495
request.SetHeader(
7496-
"x-ms-source-encryption-key-sha256", options.SourceEncryptionKeySha256.Value());
7496+
"x-ms-source-encryption-key-sha256",
7497+
Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()));
74977498
}
74987499
if (options.SourceEncryptionAlgorithm.HasValue()
7499-
&& !options.SourceEncryptionAlgorithm.Value().ToString().empty())
7500+
&& !options.SourceEncryptionAlgorithm.Value().empty())
75007501
{
75017502
request.SetHeader(
7502-
"x-ms-source-encryption-algorithm",
7503-
options.SourceEncryptionAlgorithm.Value().ToString());
7503+
"x-ms-source-encryption-algorithm", options.SourceEncryptionAlgorithm.Value());
75047504
}
75057505
auto pRawResponse = pipeline.Send(request, context);
75067506
auto httpStatusCode = pRawResponse->GetStatusCode();
@@ -7929,17 +7929,17 @@ namespace Azure { namespace Storage { namespace Blobs {
79297929
request.SetHeader("x-ms-source-encryption-key", options.SourceEncryptionKey.Value());
79307930
}
79317931
if (options.SourceEncryptionKeySha256.HasValue()
7932-
&& !options.SourceEncryptionKeySha256.Value().empty())
7932+
&& !Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()).empty())
79337933
{
79347934
request.SetHeader(
7935-
"x-ms-source-encryption-key-sha256", options.SourceEncryptionKeySha256.Value());
7935+
"x-ms-source-encryption-key-sha256",
7936+
Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()));
79367937
}
79377938
if (options.SourceEncryptionAlgorithm.HasValue()
7938-
&& !options.SourceEncryptionAlgorithm.Value().ToString().empty())
7939+
&& !options.SourceEncryptionAlgorithm.Value().empty())
79397940
{
79407941
request.SetHeader(
7941-
"x-ms-source-encryption-algorithm",
7942-
options.SourceEncryptionAlgorithm.Value().ToString());
7942+
"x-ms-source-encryption-algorithm", options.SourceEncryptionAlgorithm.Value());
79437943
}
79447944
if (options.SourceContentcrc64.HasValue()
79457945
&& !Core::Convert::Base64Encode(options.SourceContentcrc64.Value()).empty())
@@ -8186,17 +8186,17 @@ namespace Azure { namespace Storage { namespace Blobs {
81868186
request.SetHeader("x-ms-source-encryption-key", options.SourceEncryptionKey.Value());
81878187
}
81888188
if (options.SourceEncryptionKeySha256.HasValue()
8189-
&& !options.SourceEncryptionKeySha256.Value().empty())
8189+
&& !Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()).empty())
81908190
{
81918191
request.SetHeader(
8192-
"x-ms-source-encryption-key-sha256", options.SourceEncryptionKeySha256.Value());
8192+
"x-ms-source-encryption-key-sha256",
8193+
Core::Convert::Base64Encode(options.SourceEncryptionKeySha256.Value()));
81938194
}
81948195
if (options.SourceEncryptionAlgorithm.HasValue()
8195-
&& !options.SourceEncryptionAlgorithm.Value().ToString().empty())
8196+
&& !options.SourceEncryptionAlgorithm.Value().empty())
81968197
{
81978198
request.SetHeader(
8198-
"x-ms-source-encryption-algorithm",
8199-
options.SourceEncryptionAlgorithm.Value().ToString());
8199+
"x-ms-source-encryption-algorithm", options.SourceEncryptionAlgorithm.Value());
82008200
}
82018201
auto pRawResponse = pipeline.Send(request, context);
82028202
auto httpStatusCode = pRawResponse->GetStatusCode();

sdk/storage/azure-storage-blobs/swagger/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ directive:
290290
$.SequenceNumberAction["x-ms-enum"]["name"] = "SequenceNumberAction";
291291
delete $.EncryptionAlgorithm["enum"];
292292
delete $.EncryptionAlgorithm["x-ms-enum"];
293+
delete $.SourceEncryptionAlgorithm["enum"];
294+
delete $.SourceEncryptionAlgorithm["x-ms-enum"];
293295
$.ImmutabilityPolicyMode.enum = $.ImmutabilityPolicyMode.enum.map(e => e.toLowerCase());
294296
$.CopySourceTags["x-ms-enum"]["name"] = "BlobCopySourceTagsMode";
295297
delete $.FilterBlobsInclude;
@@ -333,6 +335,16 @@ directive:
333335
},
334336
"x-ms-export": true
335337
};
338+
$.SourceEncryptionAlgorithm = {
339+
"type": "string",
340+
"enum": ["AES256"],
341+
"x-ms-enum": {
342+
"name": "EncryptionAlgorithmType",
343+
"modelAsString": false,
344+
"values": [{"value": "__placeHolder", "name": "__placeHolder"}, {"value": "AES256", "name": "Aes256"}]
345+
},
346+
"x-ms-export": true
347+
};
336348
$.BlockType = {
337349
"type": "string",
338350
"enum": ["Committed", "Uncommitted", "Latest"],
@@ -391,6 +403,7 @@ directive:
391403
where: $.parameters
392404
transform: >
393405
$.EncryptionKeySha256["format"] = "byte";
406+
$.SourceEncryptionKeySha256["format"] = "byte";
394407
$.BlobContentType["required"] = true;
395408
$.BlobContentEncoding["required"] = true;
396409
$.BlobContentLanguage["required"] = true;

sdk/storage/azure-storage-blobs/test/ut/blob_sas_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ namespace Azure { namespace Storage { namespace Test {
10261026

10271027
blobSasBuilder.SetPermissions(Sas::BlobSasPermissions::All);
10281028

1029+
// cSpell:disable
10291030
std::map<std::string, std::string> requestHeaders;
10301031
requestHeaders["x-ms-range"] = "bytes=0-1023";
10311032
requestHeaders["x-ms-range-get-content-md5"] = "true";
@@ -1057,6 +1058,7 @@ namespace Azure { namespace Storage { namespace Test {
10571058
requestQueryParameters["hello$"] = "world!";
10581059
requestQueryParameters["abra"] = "cadabra";
10591060
requestQueryParameters["firstName"] = "john,Tim";
1061+
// cSpell:enable
10601062

10611063
blobSasBuilder.RequestHeaders = requestHeaders;
10621064
blobSasBuilder.RequestQueryParameters = requestQueryParameters;

sdk/storage/azure-storage-files-datalake/test/ut/datalake_sas_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@ namespace Azure { namespace Storage { namespace Test {
10221022

10231023
fileSasBuilder.SetPermissions(Sas::DataLakeSasPermissions::All);
10241024

1025+
// cSpell:disable
10251026
std::map<std::string, std::string> requestHeaders;
10261027
requestHeaders["x-ms-range"] = "bytes=0-1023";
10271028
requestHeaders["x-ms-upn"] = "true";
@@ -1053,6 +1054,7 @@ namespace Azure { namespace Storage { namespace Test {
10531054
requestQueryParameters["hello$"] = "world!";
10541055
requestQueryParameters["abra"] = "cadabra";
10551056
requestQueryParameters["firstName"] = "john,Tim";
1057+
// cSpell:enable
10561058

10571059
fileSasBuilder.RequestHeaders = requestHeaders;
10581060
fileSasBuilder.RequestQueryParameters = requestQueryParameters;

0 commit comments

Comments
 (0)