Skip to content

Commit 9a25292

Browse files
authored
Storage/STG93 ACL response header support and UPN request headers (Azure#5245)
* add acl response support * add user principal name * test record * fix comments
1 parent 743d269 commit 9a25292

File tree

18 files changed

+268
-94
lines changed

18 files changed

+268
-94
lines changed

sdk/storage/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "cpp",
44
"TagPrefix": "cpp/storage",
5-
"Tag": "cpp/storage_67aff8fa0e"
5+
"Tag": "cpp/storage_d89dcd9127"
66
}

sdk/storage/azure-storage-blobs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Features Added
66

7+
- Bumped up API version to `2023-11-03`.
8+
79
### Breaking Changes
810

911
### Bugs Fixed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "azure/storage/blobs/blob_options.hpp"
77
#include "azure/storage/blobs/blob_responses.hpp"
8+
#include "azure/storage/blobs/dll_import_export.hpp"
89

910
#include <azure/core/credentials/credentials.hpp>
1011
#include <azure/storage/common/storage_credential.hpp>
@@ -22,6 +23,11 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
2223

2324
namespace Azure { namespace Storage { namespace Blobs {
2425

26+
namespace _detail {
27+
AZ_STORAGE_BLOBS_DLLEXPORT extern const Azure::Core::Context::Key
28+
DataLakeInteroperabilityExtraOptionsKey;
29+
} // namespace _detail
30+
2531
class BlockBlobClient;
2632
class AppendBlobClient;
2733
class PageBlobClient;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Azure { namespace Storage { namespace Blobs {
3131
/**
3232
* The version used for the operations to Azure storage services.
3333
*/
34-
constexpr static const char* ApiVersion = "2022-11-02";
34+
constexpr static const char* ApiVersion = "2023-11-03";
3535
} // namespace _detail
3636
namespace Models {
3737
/**
@@ -3675,6 +3675,7 @@ namespace Azure { namespace Storage { namespace Blobs {
36753675
Nullable<std::string> LeaseId;
36763676
Nullable<bool> RangeGetContentMD5;
36773677
Nullable<bool> RangeGetContentCRC64;
3678+
Nullable<bool> UserPrincipalName;
36783679
Nullable<std::string> EncryptionKey;
36793680
Nullable<std::vector<uint8_t>> EncryptionKeySha256;
36803681
Nullable<std::string> EncryptionAlgorithm;
@@ -3697,6 +3698,7 @@ namespace Azure { namespace Storage { namespace Blobs {
36973698
Nullable<std::string> EncryptionKey;
36983699
Nullable<std::vector<uint8_t>> EncryptionKeySha256;
36993700
Nullable<std::string> EncryptionAlgorithm;
3701+
Nullable<bool> UserPrincipalName;
37003702
Nullable<DateTime> IfModifiedSince;
37013703
Nullable<DateTime> IfUnmodifiedSince;
37023704
ETag IfMatch;

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
namespace Azure { namespace Storage { namespace Blobs {
2929

30+
namespace _detail {
31+
Azure::Core::Context::Key const DataLakeInteroperabilityExtraOptionsKey;
32+
}
33+
3034
BlobClient BlobClient::CreateFromConnectionString(
3135
const std::string& connectionString,
3236
const std::string& blobContainerName,
@@ -191,6 +195,13 @@ namespace Azure { namespace Storage { namespace Blobs {
191195
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
192196
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
193197
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
198+
{
199+
bool userPrincipalName = false;
200+
if (context.TryGetValue(_detail::DataLakeInteroperabilityExtraOptionsKey, userPrincipalName))
201+
{
202+
protocolLayerOptions.UserPrincipalName = userPrincipalName;
203+
}
204+
}
194205
if (m_customerProvidedKey.HasValue())
195206
{
196207
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;
@@ -535,6 +546,13 @@ namespace Azure { namespace Storage { namespace Blobs {
535546
protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch;
536547
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
537548
protocolLayerOptions.IfTags = options.AccessConditions.TagConditions;
549+
{
550+
bool userPrincipalName = false;
551+
if (context.TryGetValue(_detail::DataLakeInteroperabilityExtraOptionsKey, userPrincipalName))
552+
{
553+
protocolLayerOptions.UserPrincipalName = userPrincipalName;
554+
}
555+
}
538556
if (m_customerProvidedKey.HasValue())
539557
{
540558
protocolLayerOptions.EncryptionKey = m_customerProvidedKey.Value().Key;

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

Lines changed: 75 additions & 67 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package-name: azure-storage-blobs
99
namespace: Azure::Storage::Blobs
1010
output-folder: generated
1111
clear-output-folder: true
12-
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.BlobStorage/preview/2021-12-02/blob.json
12+
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.BlobStorage/preview/2024-05-04/blob.json
1313
```
1414
1515
## ModelFour Options
@@ -102,12 +102,12 @@ directive:
102102
"name": "ApiVersion",
103103
"modelAsString": false
104104
},
105-
"enum": ["2022-11-02"]
105+
"enum": ["2023-11-03"]
106106
};
107107
- from: swagger-document
108108
where: $.parameters
109109
transform: >
110-
$.ApiVersionParameter.enum[0] = "2022-11-02";
110+
$.ApiVersionParameter.enum[0] = "2023-11-03";
111111
```
112112
113113
### Rename Operations

sdk/storage/azure-storage-files-datalake/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
### Features Added
66

7+
- Bumped up API version to `2023-11-03`.
8+
- Added new field `UserPrincipalName` in `GetPathPropertiesOptions` and `DownloadFileOptions`.
9+
- Added new field `Acls` in `PathProperties` and `DownloadFileDetails`.
10+
711
### Breaking Changes
812

913
### Bugs Fixed

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,15 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
766766
* Specify the access condition for the path.
767767
*/
768768
PathAccessConditions AccessConditions;
769+
770+
/**
771+
* Valid only when Hierarchical Namespace is enabled for the account. If "true", the user
772+
* identity values returned in the owner and group fields of each list entry will be transformed
773+
* from Azure Active Directory Object IDs to User Principal Names. If "false", the values will
774+
* be returned as Azure Active Directory Object IDs. The default value is false. Note that group
775+
* and application Object IDs are not translated because they do not have unique friendly names.
776+
*/
777+
Nullable<bool> UserPrincipalName;
769778
};
770779

771780
/**
@@ -802,6 +811,15 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
802811
* Specify the access condition for the path.
803812
*/
804813
PathAccessConditions AccessConditions;
814+
815+
/**
816+
* Valid only when Hierarchical Namespace is enabled for the account. If "true", the user
817+
* identity values returned in the owner and group fields of each list entry will be transformed
818+
* from Azure Active Directory Object IDs to User Principal Names. If "false", the values will
819+
* be returned as Azure Active Directory Object IDs. The default value is false. Note that group
820+
* and application Object IDs are not translated because they do not have unique friendly names.
821+
*/
822+
Nullable<bool> UserPrincipalName;
805823
};
806824

807825
/**

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
441441
*/
442442
Azure::Nullable<bool> IsCurrentVersion;
443443

444+
/**
445+
* The acls of the path.
446+
*/
447+
Azure::Nullable<std::vector<Acl>> Acls;
448+
444449
/**
445450
* The owner of the path.
446451
*/
@@ -707,6 +712,11 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
707712
*/
708713
Nullable<std::string> EncryptionContext;
709714

715+
/**
716+
* The acls of the file.
717+
*/
718+
Azure::Nullable<std::vector<Acl>> Acls;
719+
710720
/**
711721
* The owner of the file.
712722
*/

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
2626
/**
2727
* The version used for the operations to Azure storage services.
2828
*/
29-
constexpr static const char* ApiVersion = "2023-08-03";
29+
constexpr static const char* ApiVersion = "2023-11-03";
3030
} // namespace _detail
3131
namespace Models {
3232
namespace _detail {

sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
182182
blobOptions.AccessConditions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
183183
blobOptions.AccessConditions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
184184
blobOptions.AccessConditions.LeaseId = options.AccessConditions.LeaseId;
185-
auto response = m_blobClient.Download(blobOptions, context);
185+
auto response = m_blobClient.Download(
186+
blobOptions,
187+
options.UserPrincipalName.HasValue() ? context.WithValue(
188+
Blobs::_detail::DataLakeInteroperabilityExtraOptionsKey,
189+
options.UserPrincipalName.Value())
190+
: context);
186191
Models::DownloadFileResult ret;
187192
ret.Body = std::move(response.Value.BodyStream);
188193
ret.Details.HttpHeaders = std::move(response.Value.Details.HttpHeaders);
@@ -221,6 +226,11 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
221226
{
222227
ret.Details.EncryptionContext = encryptionContext->second;
223228
}
229+
auto acl = headers.find(_detail::AclHeaderName);
230+
if (acl != headers.end())
231+
{
232+
ret.Details.Acls = Models::Acl::DeserializeAcls(acl->second);
233+
}
224234
auto owner = headers.find(_detail::OwnerHeaderName);
225235
if (owner != headers.end())
226236
{

sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,12 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
347347
blobOptions.AccessConditions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
348348
blobOptions.AccessConditions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
349349
blobOptions.AccessConditions.LeaseId = options.AccessConditions.LeaseId;
350-
auto response = m_blobClient.GetProperties(blobOptions, context);
350+
auto response = m_blobClient.GetProperties(
351+
blobOptions,
352+
options.UserPrincipalName.HasValue() ? context.WithValue(
353+
Blobs::_detail::DataLakeInteroperabilityExtraOptionsKey,
354+
options.UserPrincipalName.Value())
355+
: context);
351356
Models::PathProperties ret;
352357
ret.ETag = std::move(response.Value.ETag);
353358
ret.LastModified = std::move(response.Value.LastModified);
@@ -383,6 +388,11 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
383388
{
384389
ret.EncryptionContext = encryptionContext->second;
385390
}
391+
auto acl = headers.find(_detail::AclHeaderName);
392+
if (acl != headers.end())
393+
{
394+
ret.Acls = Models::Acl::DeserializeAcls(acl->second);
395+
}
386396
auto owner = headers.find(_detail::OwnerHeaderName);
387397
if (owner != headers.end())
388398
{

sdk/storage/azure-storage-files-datalake/src/private/datalake_constants.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
1212
constexpr static const char* DataLakePathAlreadyExists = "PathAlreadyExists";
1313
constexpr static const char* DataLakeIsDirectoryKey = "hdi_isFolder";
1414
constexpr static const char* EncryptionContextHeaderName = "x-ms-encryption-context";
15+
constexpr static const char* AclHeaderName = "x-ms-acl";
1516
constexpr static const char* OwnerHeaderName = "x-ms-owner";
1617
constexpr static const char* GroupHeaderName = "x-ms-group";
1718
constexpr static const char* PermissionsHeaderName = "x-ms-permissions";

sdk/storage/azure-storage-files-datalake/src/rest_client.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
6161
{
6262
request.GetUrl().AppendQueryParameter("timeout", std::to_string(options.Timeout.Value()));
6363
}
64-
request.SetHeader("x-ms-version", "2023-08-03");
64+
request.SetHeader("x-ms-version", "2023-11-03");
6565
if (options.ContinuationToken.HasValue() && !options.ContinuationToken.Value().empty())
6666
{
6767
request.GetUrl().AppendQueryParameter(
@@ -157,7 +157,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
157157
{
158158
request.GetUrl().AppendQueryParameter("timeout", std::to_string(options.Timeout.Value()));
159159
}
160-
request.SetHeader("x-ms-version", "2023-08-03");
160+
request.SetHeader("x-ms-version", "2023-11-03");
161161
if (options.Resource.HasValue() && !options.Resource.Value().ToString().empty())
162162
{
163163
request.GetUrl().AppendQueryParameter(
@@ -345,7 +345,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
345345
{
346346
request.GetUrl().AppendQueryParameter("timeout", std::to_string(options.Timeout.Value()));
347347
}
348-
request.SetHeader("x-ms-version", "2023-08-03");
348+
request.SetHeader("x-ms-version", "2023-11-03");
349349
if (options.Recursive.HasValue())
350350
{
351351
request.GetUrl().AppendQueryParameter(
@@ -443,7 +443,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
443443
"If-Unmodified-Since",
444444
options.IfUnmodifiedSince.Value().ToString(Azure::DateTime::DateFormat::Rfc1123));
445445
}
446-
request.SetHeader("x-ms-version", "2023-08-03");
446+
request.SetHeader("x-ms-version", "2023-11-03");
447447
auto pRawResponse = pipeline.Send(request, context);
448448
auto httpStatusCode = pRawResponse->GetStatusCode();
449449
if (httpStatusCode != Core::Http::HttpStatusCode::Ok)
@@ -490,7 +490,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
490490
{
491491
request.SetHeader("x-ms-acl", options.Acl.Value());
492492
}
493-
request.SetHeader("x-ms-version", "2023-08-03");
493+
request.SetHeader("x-ms-version", "2023-11-03");
494494
auto pRawResponse = pipeline.Send(request, context);
495495
auto httpStatusCode = pRawResponse->GetStatusCode();
496496
if (httpStatusCode != Core::Http::HttpStatusCode::Ok)
@@ -543,7 +543,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
543543
{
544544
request.SetHeader("x-ms-undelete-source", options.UndeleteSource.Value());
545545
}
546-
request.SetHeader("x-ms-version", "2023-08-03");
546+
request.SetHeader("x-ms-version", "2023-11-03");
547547
auto pRawResponse = pipeline.Send(request, context);
548548
auto httpStatusCode = pRawResponse->GetStatusCode();
549549
if (httpStatusCode != Core::Http::HttpStatusCode::Ok)
@@ -594,7 +594,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
594594
"If-Unmodified-Since",
595595
options.IfUnmodifiedSince.Value().ToString(Azure::DateTime::DateFormat::Rfc1123));
596596
}
597-
request.SetHeader("x-ms-version", "2023-08-03");
597+
request.SetHeader("x-ms-version", "2023-11-03");
598598
auto pRawResponse = pipeline.Send(request, context);
599599
auto httpStatusCode = pRawResponse->GetStatusCode();
600600
if (httpStatusCode != Core::Http::HttpStatusCode::Ok)
@@ -693,7 +693,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
693693
"If-Unmodified-Since",
694694
options.IfUnmodifiedSince.Value().ToString(Azure::DateTime::DateFormat::Rfc1123));
695695
}
696-
request.SetHeader("x-ms-version", "2023-08-03");
696+
request.SetHeader("x-ms-version", "2023-11-03");
697697
if (options.EncryptionKey.HasValue() && !options.EncryptionKey.Value().empty())
698698
{
699699
request.SetHeader("x-ms-encryption-key", options.EncryptionKey.Value());
@@ -777,7 +777,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
777777
{
778778
request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value());
779779
}
780-
request.SetHeader("x-ms-version", "2023-08-03");
780+
request.SetHeader("x-ms-version", "2023-11-03");
781781
if (options.EncryptionKey.HasValue() && !options.EncryptionKey.Value().empty())
782782
{
783783
request.SetHeader("x-ms-encryption-key", options.EncryptionKey.Value());

sdk/storage/azure-storage-files-datalake/swagger/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ directive:
8888
"name": "ApiVersion",
8989
"modelAsString": false
9090
},
91-
"enum": ["2023-08-03"]
91+
"enum": ["2023-11-03"]
9292
};
9393
- from: swagger-document
9494
where: $.parameters
9595
transform: >
96-
$.ApiVersionParameter.enum[0] = "2023-08-03";
96+
$.ApiVersionParameter.enum[0] = "2023-11-03";
9797
```
9898
9999
### Rename Operations

0 commit comments

Comments
 (0)