From 1eacb7978d6317fc8f47aa77501b8b332afea345 Mon Sep 17 00:00:00 2001 From: microzchang Date: Tue, 2 Jul 2024 15:52:21 +0800 Subject: [PATCH 1/3] File OAuth --- sdk/storage/assets.json | 2 +- .../storage/files/shares/rest_client.hpp | 61 +++--- .../src/rest_client.cpp | 180 +++++++++++++----- .../src/share_client.cpp | 9 + .../src/share_lease_client.cpp | 5 + .../src/share_service_client.cpp | 3 + .../swagger/README.md | 4 +- .../test/ut/share_client_test.cpp | 52 ++++- .../test/ut/share_service_client_test.cpp | 22 +++ 9 files changed, 262 insertions(+), 76 deletions(-) diff --git a/sdk/storage/assets.json b/sdk/storage/assets.json index 8ff7997434..647daea5ef 100644 --- a/sdk/storage/assets.json +++ b/sdk/storage/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "cpp", "TagPrefix": "cpp/storage", - "Tag": "cpp/storage_75931731d9" + "Tag": "cpp/storage_2fa8f39801" } diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp index 4ae1343f66..55c69e8021 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp @@ -31,7 +31,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { /** * The version used for the operations to Azure storage services. */ - constexpr static const char* ApiVersion = "2024-08-04"; + constexpr static const char* ApiVersion = "2024-11-04"; } // namespace _detail namespace Models { /** @@ -138,6 +138,27 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { */ SmbSettings Settings; }; + /** + * @brief Valid value is backup. + */ + class ShareTokenIntent final { + public: + /** Constructs a new ShareTokenIntent instance */ + ShareTokenIntent() = default; + /** Constructs a new ShareTokenIntent from a string. */ + explicit ShareTokenIntent(std::string value) : m_value(std::move(value)) {} + /** Compares with another ShareTokenIntent. */ + bool operator==(const ShareTokenIntent& other) const { return m_value == other.m_value; } + /** Compares with another ShareTokenIntent. */ + bool operator!=(const ShareTokenIntent& other) const { return !(*this == other); } + /** Converts the value to a string. */ + const std::string& ToString() const { return m_value; } + /** Constant value of type ShareTokenIntent: Backup */ + AZ_STORAGE_FILES_SHARES_DLLEXPORT const static ShareTokenIntent Backup; + + private: + std::string m_value; + }; /** * @brief Response type for #Azure::Storage::Files::Shares::ShareServiceClient::SetProperties. */ @@ -747,27 +768,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { */ DateTime LastModified; }; - /** - * @brief Valid value is backup. - */ - class ShareTokenIntent final { - public: - /** Constructs a new ShareTokenIntent instance */ - ShareTokenIntent() = default; - /** Constructs a new ShareTokenIntent from a string. */ - explicit ShareTokenIntent(std::string value) : m_value(std::move(value)) {} - /** Compares with another ShareTokenIntent. */ - bool operator==(const ShareTokenIntent& other) const { return m_value == other.m_value; } - /** Compares with another ShareTokenIntent. */ - bool operator!=(const ShareTokenIntent& other) const { return !(*this == other); } - /** Converts the value to a string. */ - const std::string& ToString() const { return m_value; } - /** Constant value of type ShareTokenIntent: Backup */ - AZ_STORAGE_FILES_SHARES_DLLEXPORT const static ShareTokenIntent Backup; - - private: - std::string m_value; - }; /** * @brief Response type for #Azure::Storage::Files::Shares::ShareClient::CreatePermission. */ @@ -2061,6 +2061,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { struct SetServicePropertiesOptions final { Models::ShareServiceProperties ShareServiceProperties; + Nullable FileRequestIntent; }; static Response SetProperties( Core::Http::_internal::HttpPipeline& pipeline, @@ -2069,6 +2070,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Core::Context& context); struct GetServicePropertiesOptions final { + Nullable FileRequestIntent; }; static Response GetProperties( Core::Http::_internal::HttpPipeline& pipeline, @@ -2081,6 +2083,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable Marker; Nullable MaxResults; Nullable Include; + Nullable FileRequestIntent; }; static Response ListSharesSegment( Core::Http::_internal::HttpPipeline& pipeline, @@ -2098,6 +2101,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable EnabledProtocols; Nullable RootSquash; Nullable EnableSnapshotVirtualDirectoryAccess; + Nullable FileRequestIntent; }; static Response Create( Core::Http::_internal::HttpPipeline& pipeline, @@ -2108,6 +2112,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { Nullable Sharesnapshot; Nullable LeaseId; + Nullable FileRequestIntent; }; static Response GetProperties( Core::Http::_internal::HttpPipeline& pipeline, @@ -2119,6 +2124,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable Sharesnapshot; Nullable DeleteSnapshots; Nullable LeaseId; + Nullable FileRequestIntent; }; static Response Delete( Core::Http::_internal::HttpPipeline& pipeline, @@ -2130,6 +2136,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable Duration; Nullable ProposedLeaseId; Nullable Sharesnapshot; + Nullable FileRequestIntent; }; static Response AcquireLease( Core::Http::_internal::HttpPipeline& pipeline, @@ -2140,6 +2147,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { std::string LeaseId; Nullable Sharesnapshot; + Nullable FileRequestIntent; }; static Response ReleaseLease( Core::Http::_internal::HttpPipeline& pipeline, @@ -2151,6 +2159,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { std::string LeaseId; Nullable ProposedLeaseId; Nullable Sharesnapshot; + Nullable FileRequestIntent; }; static Response ChangeLease( Core::Http::_internal::HttpPipeline& pipeline, @@ -2161,6 +2170,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { std::string LeaseId; Nullable Sharesnapshot; + Nullable FileRequestIntent; }; static Response RenewLease( Core::Http::_internal::HttpPipeline& pipeline, @@ -2172,6 +2182,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable BreakPeriod; Nullable LeaseId; Nullable Sharesnapshot; + Nullable FileRequestIntent; }; static Response BreakLease( Core::Http::_internal::HttpPipeline& pipeline, @@ -2181,6 +2192,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { struct CreateShareSnapshotOptions final { std::map Metadata; + Nullable FileRequestIntent; }; static Response CreateSnapshot( Core::Http::_internal::HttpPipeline& pipeline, @@ -2214,6 +2226,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable LeaseId; Nullable RootSquash; Nullable EnableSnapshotVirtualDirectoryAccess; + Nullable FileRequestIntent; }; static Response SetProperties( Core::Http::_internal::HttpPipeline& pipeline, @@ -2224,6 +2237,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { std::map Metadata; Nullable LeaseId; + Nullable FileRequestIntent; }; static Response SetMetadata( Core::Http::_internal::HttpPipeline& pipeline, @@ -2233,6 +2247,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { struct GetShareAccessPolicyOptions final { Nullable LeaseId; + Nullable FileRequestIntent; }; static Response GetAccessPolicy( Core::Http::_internal::HttpPipeline& pipeline, @@ -2243,6 +2258,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { std::vector ShareAcl; Nullable LeaseId; + Nullable FileRequestIntent; }; static Response SetAccessPolicy( Core::Http::_internal::HttpPipeline& pipeline, @@ -2252,6 +2268,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { struct GetShareStatisticsOptions final { Nullable LeaseId; + Nullable FileRequestIntent; }; static Response GetStatistics( Core::Http::_internal::HttpPipeline& pipeline, diff --git a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp index d13da01884..b44a9ce69d 100644 --- a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp @@ -86,6 +86,7 @@ std::string ListFilesIncludeFlagsToString( } // namespace namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace Models { + const ShareTokenIntent ShareTokenIntent::Backup("backup"); const AccessTier AccessTier::TransactionOptimized("TransactionOptimized"); const AccessTier AccessTier::Hot("Hot"); const AccessTier AccessTier::Cool("Cool"); @@ -105,7 +106,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ShareRootSquash ShareRootSquash::RootSquash("RootSquash"); const ShareRootSquash ShareRootSquash::AllSquash("AllSquash"); const DeleteSnapshotsOption DeleteSnapshotsOption::Include("include"); - const ShareTokenIntent ShareTokenIntent::Backup("backup"); FileAttributes::FileAttributes(const std::string& value) { const std::string delimiter = " | "; @@ -317,7 +317,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.SetHeader("Content-Length", std::to_string(requestBody.Length())); request.GetUrl().AppendQueryParameter("restype", "service"); request.GetUrl().AppendQueryParameter("comp", "properties"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) @@ -337,8 +342,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); request.GetUrl().AppendQueryParameter("restype", "service"); request.GetUrl().AppendQueryParameter("comp", "properties"); - request.SetHeader("x-ms-version", "2024-08-04"); - (void)options; + request.SetHeader("x-ms-version", "2024-11-04"); + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -569,7 +578,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { _internal::UrlEncodeQueryParameter( ListSharesIncludeFlagsToString(options.Include.Value()))); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -934,7 +948,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-access-tier", options.AccessTier.Value().ToString()); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.EnabledProtocols.HasValue() && !options.EnabledProtocols.Value().ToString().empty()) { @@ -950,6 +964,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { "x-ms-enable-snapshot-virtual-directory-access", options.EnableSnapshotVirtualDirectoryAccess.Value() ? "true" : "false"); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Created) @@ -975,11 +994,16 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1083,7 +1107,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.DeleteSnapshots.HasValue() && !options.DeleteSnapshots.Value().ToString().empty()) { request.SetHeader("x-ms-delete-snapshots", options.DeleteSnapshots.Value().ToString()); @@ -1092,6 +1116,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) @@ -1119,12 +1148,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Created) @@ -1153,12 +1187,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-lease-id", options.LeaseId); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1190,12 +1229,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1224,12 +1268,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-lease-id", options.LeaseId); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1262,12 +1311,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Sharesnapshot.HasValue() && !options.Sharesnapshot.Value().empty()) { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Accepted) @@ -1295,7 +1349,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-meta-" + p.first, p.second); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Created) @@ -1329,7 +1388,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.SetHeader("Content-Length", std::to_string(requestBody.Length())); request.GetUrl().AppendQueryParameter("restype", "share"); request.GetUrl().AppendQueryParameter("comp", "filepermission"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.FileRequestIntent.HasValue() && !options.FileRequestIntent.Value().ToString().empty()) { @@ -1359,7 +1418,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-file-permission-key", options.FilePermissionKey); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.FileRequestIntent.HasValue() && !options.FileRequestIntent.Value().ToString().empty()) { @@ -1390,7 +1449,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); request.GetUrl().AppendQueryParameter("restype", "share"); request.GetUrl().AppendQueryParameter("comp", "properties"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Quota.HasValue()) { request.SetHeader("x-ms-share-quota", std::to_string(options.Quota.Value())); @@ -1413,6 +1472,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { "x-ms-enable-snapshot-virtual-directory-access", options.EnableSnapshotVirtualDirectoryAccess.Value() ? "true" : "false"); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1439,11 +1503,16 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-meta-" + p.first, p.second); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1465,11 +1534,16 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); request.GetUrl().AppendQueryParameter("restype", "share"); request.GetUrl().AppendQueryParameter("comp", "acl"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1612,11 +1686,16 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.SetHeader("Content-Length", std::to_string(requestBody.Length())); request.GetUrl().AppendQueryParameter("restype", "share"); request.GetUrl().AppendQueryParameter("comp", "acl"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1639,11 +1718,16 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); request.GetUrl().AppendQueryParameter("restype", "share"); request.GetUrl().AppendQueryParameter("comp", "stats"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } + if (options.FileRequestIntent.HasValue() + && !options.FileRequestIntent.Value().ToString().empty()) + { + request.SetHeader("x-ms-file-request-intent", options.FileRequestIntent.Value().ToString()); + } auto pRawResponse = pipeline.Send(request, context); auto httpStatusCode = pRawResponse->GetStatusCode(); if (httpStatusCode != Core::Http::HttpStatusCode::Ok) @@ -1725,7 +1809,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-meta-" + p.first, p.second); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.FilePermission.HasValue() && !options.FilePermission.Value().empty()) { request.SetHeader("x-ms-file-permission", options.FilePermission.Value()); @@ -1814,7 +1898,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.FileRequestIntent.HasValue() && !options.FileRequestIntent.Value().ToString().empty()) { @@ -1880,7 +1964,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.SetHeader( "x-ms-allow-trailing-dot", options.AllowTrailingDot.Value() ? "true" : "false"); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.FileRequestIntent.HasValue() && !options.FileRequestIntent.Value().ToString().empty()) { @@ -1904,7 +1988,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); request.GetUrl().AppendQueryParameter("restype", "directory"); request.GetUrl().AppendQueryParameter("comp", "properties"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.FilePermission.HasValue() && !options.FilePermission.Value().empty()) { request.SetHeader("x-ms-file-permission", options.FilePermission.Value()); @@ -1994,7 +2078,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-meta-" + p.first, p.second); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -2048,7 +2132,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.GetUrl().AppendQueryParameter( "maxresults", std::to_string(options.MaxResults.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Include.HasValue() && !ListFilesIncludeFlagsToString(options.Include.Value()).empty()) { @@ -2441,7 +2525,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-recursive", options.Recursive.Value() ? "true" : "false"); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -2654,7 +2738,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-recursive", options.Recursive.Value() ? "true" : "false"); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -2692,7 +2776,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); request.GetUrl().AppendQueryParameter("restype", "directory"); request.GetUrl().AppendQueryParameter("comp", "rename"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (!options.RenameSource.empty()) { request.SetHeader("x-ms-file-rename-source", options.RenameSource); @@ -2800,7 +2884,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.SetHeader( "x-ms-allow-trailing-dot", options.AllowTrailingDot.Value() ? "true" : "false"); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); request.SetHeader("x-ms-content-length", std::to_string(options.FileContentLength)); request.SetHeader("x-ms-type", "file"); if (options.FileContentType.HasValue() && !options.FileContentType.Value().empty()) @@ -2920,7 +3004,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.SetHeader( "x-ms-allow-trailing-dot", options.AllowTrailingDot.Value() ? "true" : "false"); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Range.HasValue() && !options.Range.Value().empty()) { request.SetHeader("x-ms-range", options.Range.Value()); @@ -3105,7 +3189,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); @@ -3243,7 +3327,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.SetHeader( "x-ms-allow-trailing-dot", options.AllowTrailingDot.Value() ? "true" : "false"); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); @@ -3270,7 +3354,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); request.GetUrl().AppendQueryParameter("comp", "properties"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.FileContentLength.HasValue()) { request.SetHeader("x-ms-content-length", std::to_string(options.FileContentLength.Value())); @@ -3394,7 +3478,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-meta-" + p.first, p.second); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); @@ -3438,7 +3522,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -3476,7 +3560,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-lease-id", options.LeaseId); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -3517,7 +3601,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-proposed-lease-id", options.ProposedLeaseId.Value()); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -3555,7 +3639,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -3602,7 +3686,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("Content-MD5", Core::Convert::Base64Encode(options.ContentMD5.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); @@ -3689,7 +3773,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { "x-ms-source-if-none-match-crc64", Core::Convert::Base64Encode(options.SourceIfNoneMatchCrc64.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); @@ -3765,7 +3849,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { "prevsharesnapshot", _internal::UrlEncodeQueryParameter(options.Prevsharesnapshot.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.Range.HasValue() && !options.Range.Value().empty()) { request.SetHeader("x-ms-range", options.Range.Value()); @@ -3894,7 +3978,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const Core::Context& context) { auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); for (const auto& p : options.Metadata) { request.SetHeader("x-ms-meta-" + p.first, p.second); @@ -3992,7 +4076,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { "copyid", _internal::UrlEncodeQueryParameter(options.CopyId)); } request.SetHeader("x-ms-copy-action", "abort"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.LeaseId.HasValue() && !options.LeaseId.Value().empty()) { request.SetHeader("x-ms-lease-id", options.LeaseId.Value()); @@ -4039,7 +4123,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { request.GetUrl().AppendQueryParameter( "sharesnapshot", _internal::UrlEncodeQueryParameter(options.Sharesnapshot.Value())); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -4248,7 +4332,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { request.SetHeader("x-ms-handle-id", options.HandleId); } - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (options.AllowTrailingDot.HasValue()) { request.SetHeader( @@ -4285,7 +4369,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url); request.GetUrl().AppendQueryParameter("comp", "rename"); - request.SetHeader("x-ms-version", "2024-08-04"); + request.SetHeader("x-ms-version", "2024-11-04"); if (!options.RenameSource.empty()) { request.SetHeader("x-ms-file-rename-source", options.RenameSource); diff --git a/sdk/storage/azure-storage-files-shares/src/share_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_client.cpp index 5aa5d7a070..d3f628e021 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_client.cpp @@ -151,6 +151,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { protocolLayerOptions.RootSquash = options.RootSquash; protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess = options.EnableSnapshotVirtualDirectoryAccess; + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; auto result = _detail::ShareClient::Create(*m_pipeline, m_shareUrl, protocolLayerOptions, context); Models::CreateShareResult ret; @@ -190,6 +191,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { protocolLayerOptions.DeleteSnapshots = Models::DeleteSnapshotsOption::Include; } + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; auto result = _detail::ShareClient::Delete(*m_pipeline, m_shareUrl, protocolLayerOptions, context); Models::DeleteShareResult ret; @@ -225,6 +227,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto protocolLayerOptions = _detail::ShareClient::CreateShareSnapshotOptions(); protocolLayerOptions.Metadata = std::map(options.Metadata.begin(), options.Metadata.end()); + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ShareClient::CreateSnapshot( *m_pipeline, m_shareUrl, protocolLayerOptions, context); } @@ -235,6 +238,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { (void)options; auto protocolLayerOptions = _detail::ShareClient::GetSharePropertiesOptions(); + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ShareClient::GetProperties( *m_pipeline, m_shareUrl, protocolLayerOptions, context); } @@ -249,6 +253,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { protocolLayerOptions.RootSquash = options.RootSquash; protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess = options.EnableSnapshotVirtualDirectoryAccess; + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ShareClient::SetProperties( *m_pipeline, m_shareUrl, protocolLayerOptions, context); } @@ -262,6 +267,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto protocolLayerOptions = _detail::ShareClient::SetShareMetadataOptions(); protocolLayerOptions.Metadata = std::map(metadata.begin(), metadata.end()); + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ShareClient::SetMetadata( *m_pipeline, m_shareUrl, protocolLayerOptions, context); } @@ -272,6 +278,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { (void)options; auto protocolLayerOptions = _detail::ShareClient::GetShareAccessPolicyOptions(); + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ShareClient::GetAccessPolicy( *m_pipeline, m_shareUrl, protocolLayerOptions, context); } @@ -284,6 +291,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; auto protocolLayerOptions = _detail::ShareClient::SetShareAccessPolicyOptions(); protocolLayerOptions.ShareAcl = accessPolicy; + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ShareClient::SetAccessPolicy( *m_pipeline, m_shareUrl, protocolLayerOptions, context); } @@ -294,6 +302,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { (void)options; auto protocolLayerOptions = _detail::ShareClient::GetShareStatisticsOptions(); + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ShareClient::GetStatistics( *m_pipeline, m_shareUrl, protocolLayerOptions, context); } diff --git a/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp index faaf70de25..e25a164ba1 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp @@ -47,6 +47,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { _detail::ShareClient::AcquireShareLeaseOptions protocolLayerOptions; protocolLayerOptions.ProposedLeaseId = GetLeaseId(); protocolLayerOptions.Duration = static_cast(duration.count()); + protocolLayerOptions.FileRequestIntent = m_shareClient.Value().m_shareTokenIntent; auto response = _detail::ShareClient::AcquireLease( *(m_shareClient.Value().m_pipeline), @@ -82,6 +83,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { _detail::ShareClient::RenewShareLeaseOptions protocolLayerOptions; protocolLayerOptions.LeaseId = GetLeaseId(); + protocolLayerOptions.FileRequestIntent = m_shareClient.Value().m_shareTokenIntent; auto response = _detail::ShareClient::RenewLease( *(m_shareClient.Value().m_pipeline), @@ -132,6 +134,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { _detail::ShareClient::ReleaseShareLeaseOptions protocolLayerOptions; protocolLayerOptions.LeaseId = GetLeaseId(); + protocolLayerOptions.FileRequestIntent = m_shareClient.Value().m_shareTokenIntent; auto response = _detail::ShareClient::ReleaseLease( *(m_shareClient.Value().m_pipeline), @@ -190,6 +193,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { _detail::ShareClient::ChangeShareLeaseOptions protocolLayerOptions; protocolLayerOptions.LeaseId = GetLeaseId(); protocolLayerOptions.ProposedLeaseId = proposedLeaseId; + protocolLayerOptions.FileRequestIntent = m_shareClient.Value().m_shareTokenIntent; auto response = _detail::ShareClient::ChangeLease( *(m_shareClient.Value().m_pipeline), @@ -243,6 +247,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { else if (m_shareClient.HasValue()) { _detail::ShareClient::BreakShareLeaseOptions protocolLayerOptions; + protocolLayerOptions.FileRequestIntent = m_shareClient.Value().m_shareTokenIntent; auto response = _detail::ShareClient::BreakLease( diff --git a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp index 8b4f65ea58..ea7743e287 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp @@ -133,6 +133,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { protocolLayerOptions.Marker = options.ContinuationToken; protocolLayerOptions.MaxResults = options.PageSizeHint; protocolLayerOptions.Prefix = options.Prefix; + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; auto response = _detail::ServiceClient::ListSharesSegment( *m_pipeline, m_serviceUrl, protocolLayerOptions, context); @@ -160,6 +161,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; auto protocolLayerOptions = _detail::ServiceClient::SetServicePropertiesOptions(); protocolLayerOptions.ShareServiceProperties = std::move(properties); + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; return _detail::ServiceClient::SetProperties( *m_pipeline, m_serviceUrl, protocolLayerOptions, context); } @@ -170,6 +172,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { (void)options; auto protocolLayerOptions = _detail::ServiceClient::GetServicePropertiesOptions(); + protocolLayerOptions.FileRequestIntent = m_shareTokenIntent; auto result = _detail::ServiceClient::GetProperties( *m_pipeline, m_serviceUrl, protocolLayerOptions, context); Models::ShareServiceProperties ret; diff --git a/sdk/storage/azure-storage-files-shares/swagger/README.md b/sdk/storage/azure-storage-files-shares/swagger/README.md index 345aa9350f..7246b74824 100644 --- a/sdk/storage/azure-storage-files-shares/swagger/README.md +++ b/sdk/storage/azure-storage-files-shares/swagger/README.md @@ -79,12 +79,12 @@ directive: "name": "ApiVersion", "modelAsString": false }, - "enum": ["2024-08-04"] + "enum": ["2024-11-04"] }; - from: swagger-document where: $.parameters transform: > - $.ApiVersionParameter.enum[0] = "2024-08-04"; + $.ApiVersionParameter.enum[0] = "2024-11-04"; ``` ### Rename Operations diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp index 237df6ceaa..f07614e6fe 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp @@ -647,14 +647,55 @@ namespace Azure { namespace Storage { namespace Test { auto options = InitStorageClientOptions(); options.ShareTokenIntent = Files::Shares::Models::ShareTokenIntent::Backup; + std::string shareName = LowercaseRandomString(); auto serviceClient = Files::Shares::ShareServiceClient(m_shareServiceClient->GetUrl(), credential, options); - auto shareClient = serviceClient.GetShareClient(m_shareName); + auto shareClient = serviceClient.GetShareClient(shareName); + std::string leaseId1 = RandomUUID(); + Files::Shares::ShareLeaseClient leaseClient(shareClient, leaseId1); + + // Create + EXPECT_NO_THROW(shareClient.Create()); + + // Get Properties + EXPECT_NO_THROW(shareClient.GetProperties()); + + // Set Properties + EXPECT_NO_THROW(shareClient.SetProperties()); + + // Acquire + EXPECT_NO_THROW(leaseClient.Acquire(Files::Shares::ShareLeaseClient::InfiniteLeaseDuration)); + + // Renew + EXPECT_NO_THROW(leaseClient.Renew()); + + // Change + std::string leaseId2 = RandomUUID(); + EXPECT_NO_THROW(leaseClient.Change(leaseId2)); + + // Break + EXPECT_NO_THROW(leaseClient.Break()); + // Release + EXPECT_NO_THROW(leaseClient.Release()); + + // SetMetadata + EXPECT_NO_THROW(shareClient.SetMetadata(RandomMetadata())); + + // Create Snapshot + EXPECT_NO_THROW(shareClient.CreateSnapshot()); + + // Set Access Policy + std::vector identifiers; + EXPECT_NO_THROW(shareClient.SetAccessPolicy(identifiers)); + + // Get Access Policy + EXPECT_NO_THROW(shareClient.GetAccessPolicy()); + + // Set/Get Permission std::string permission = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-" "2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;" "0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)"; - Files::Shares::Models::CreateSharePermissionResult created; EXPECT_NO_THROW(created = shareClient.CreatePermission(permission).Value); EXPECT_NO_THROW(shareClient.GetPermission(created.FilePermissionKey)); @@ -662,7 +703,12 @@ namespace Azure { namespace Storage { namespace Test { // OAuth Constructor auto shareClient1 = Files::Shares::ShareClient(m_shareClient->GetUrl(), GetTestCredential(), options); - EXPECT_NO_THROW(shareClient1.GetPermission(created.FilePermissionKey)); + EXPECT_NO_THROW(shareClient1.GetProperties()); + + // Delete + Azure::Storage::Files::Shares::DeleteShareOptions deleteOptions; + deleteOptions.DeleteSnapshots = true; + EXPECT_NO_THROW(shareClient.Delete(deleteOptions)); } TEST_F(FileShareClientTest, WithSnapshot) diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp index ff21526d1c..bd6ee5c252 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp @@ -417,4 +417,26 @@ namespace Azure { namespace Storage { namespace Test { premiumFileShareServiceClient.SetProperties(originalProperties); } + TEST_F(FileShareServiceClientTest, OAuth_PLAYBACKONLY_) + { + + // Create from client secret credential. + std::shared_ptr credential = GetTestCredential(); + auto options = InitStorageClientOptions(); + options.ShareTokenIntent = Files::Shares::Models::ShareTokenIntent::Backup; + + auto shareServiceClient + = Files::Shares::ShareServiceClient(m_shareServiceClient->GetUrl(), credential, options); + // Get Properties + Files::Shares::Models::ShareServiceProperties properties; + EXPECT_NO_THROW(properties = shareServiceClient.GetProperties().Value); + + // Set Properties + properties.Protocol.Reset(); + EXPECT_NO_THROW(shareServiceClient.SetProperties(properties)); + + // List Shares + EXPECT_NO_THROW(shareServiceClient.ListShares()); + } + }}} // namespace Azure::Storage::Test From a134bbc9934dabddccb0041dd064ffeaab4dc9f5 Mon Sep 17 00:00:00 2001 From: microzchang Date: Tue, 2 Jul 2024 16:09:30 +0800 Subject: [PATCH 2/3] Remove comment --- .../azure-storage-files-shares/test/ut/share_client_test.cpp | 1 - .../test/ut/share_service_client_test.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp index f07614e6fe..5c0dc9d457 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp @@ -642,7 +642,6 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(FileShareClientTest, OAuth_PLAYBACKONLY_) { - // Create from client secret credential. std::shared_ptr credential = GetTestCredential(); auto options = InitStorageClientOptions(); options.ShareTokenIntent = Files::Shares::Models::ShareTokenIntent::Backup; diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp index bd6ee5c252..8fcab27f3c 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp @@ -419,8 +419,6 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(FileShareServiceClientTest, OAuth_PLAYBACKONLY_) { - - // Create from client secret credential. std::shared_ptr credential = GetTestCredential(); auto options = InitStorageClientOptions(); options.ShareTokenIntent = Files::Shares::Models::ShareTokenIntent::Backup; From 2e887db6580e0ca746c556cd435b245e0bc72da6 Mon Sep 17 00:00:00 2001 From: microzchang Date: Wed, 3 Jul 2024 14:05:43 +0800 Subject: [PATCH 3/3] update test record --- sdk/storage/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/assets.json b/sdk/storage/assets.json index 647daea5ef..4ccae44ca4 100644 --- a/sdk/storage/assets.json +++ b/sdk/storage/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "cpp", "TagPrefix": "cpp/storage", - "Tag": "cpp/storage_2fa8f39801" + "Tag": "cpp/storage_8eb3907e27" }