From 0fd902b58a1a10087e0e54b3424c2c7886d78915 Mon Sep 17 00:00:00 2001 From: Zhendong Chang Date: Tue, 13 Sep 2022 16:29:20 +0800 Subject: [PATCH] fix conversation --- .../storage/files/datalake/rest_client.hpp | 162 +---- .../src/rest_client.cpp | 593 +----------------- .../swagger/README.md | 48 +- 3 files changed, 52 insertions(+), 751 deletions(-) diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp index 8b01692b30..f64978c407 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/rest_client.hpp @@ -8,7 +8,6 @@ #include #include -#include #include #include @@ -97,8 +96,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { * The name of the encryption scope under which the blob is encrypted. */ Nullable EncryptionScope; - std::string CreatedOn; - Nullable ExpiresOn; std::string ETag; }; namespace _detail { @@ -120,130 +117,9 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { Nullable ContinuationToken; }; } // namespace _detail - struct BlobPrefix final - { - std::string Name; - }; - /** - * @brief Properties of a blob. - */ - struct BlobPropertiesInternal final - { - Nullable CreationTime; - DateTime LastModified; - ETag Etag; - /** - * Size in bytes. - */ - Nullable ContentLength; - Nullable ContentType; - Nullable ContentEncoding; - Nullable ContentLanguage; - Nullable> ContentMD5; - Nullable ContentDisposition; - Nullable CacheControl; - Nullable BlobSequenceNumber; - Nullable CopyId; - Nullable CopySource; - Nullable CopyProgress; - Nullable CopyCompletionTime; - Nullable CopyStatusDescription; - Nullable ServerEncrypted; - Nullable IncrementalCopy; - Nullable DestinationSnapshot; - Nullable DeletedTime; - Nullable RemainingRetentionDays; - Nullable AccessTierInferred; - Nullable CustomerProvidedKeySha256; - /** - * The name of the encryption scope under which the blob is encrypted. - */ - Nullable EncryptionScope; - Nullable AccessTierChangeTime; - Nullable TagCount; - Nullable ExpiresOn; - Nullable IsSealed; - Nullable LastAccessedOn; - Nullable DeleteTime; - }; - /** - * @brief An Azure Storage blob. - */ - struct BlobItemInternal final - { - std::string Name; - bool Deleted = bool(); - std::string Snapshot; - Nullable VersionId; - Nullable IsCurrentVersion; - /** - * Properties of a blob. - */ - BlobPropertiesInternal Properties; - Nullable DeletionId; - }; - struct BlobHierarchyListSegment final - { - /** - * Array of BlobPrefix. - */ - std::vector BlobPrefixes; - /** - * Array of BlobItemInternal. - */ - std::vector BlobItems; - }; /** - * @brief Include this parameter to specify one or more datasets to include in the response. - */ - enum class ListBlobsIncludeFlags - { - None = 0, - Copy = 1, - Deleted = 2, - Metadata = 4, - Snapshots = 8, - Uncommittedblobs = 16, - Versions = 32, - Tags = 64, - }; - inline ListBlobsIncludeFlags operator|(ListBlobsIncludeFlags lhs, ListBlobsIncludeFlags rhs) - { - using type = std::underlying_type_t; - return static_cast(static_cast(lhs) | static_cast(rhs)); - } - inline ListBlobsIncludeFlags& operator|=(ListBlobsIncludeFlags& lhs, ListBlobsIncludeFlags rhs) - { - lhs = lhs | rhs; - return lhs; - } - inline ListBlobsIncludeFlags operator&(ListBlobsIncludeFlags lhs, ListBlobsIncludeFlags rhs) - { - using type = std::underlying_type_t; - return static_cast(static_cast(lhs) & static_cast(rhs)); - } - inline ListBlobsIncludeFlags& operator&=(ListBlobsIncludeFlags& lhs, ListBlobsIncludeFlags rhs) - { - lhs = lhs & rhs; - return lhs; - } - /** - * @brief An enumeration of blobs. - */ - struct ListBlobsHierarchySegmentResponse final - { - std::string ServiceEndpoint; - std::string ContainerName; - Nullable Prefix; - Nullable Marker; - Nullable MaxResults; - Nullable Delimiter; - BlobHierarchyListSegment Segment; - Nullable NextMarker; - }; - /** - * @brief Required only for Create File and Create Directory. The value must be "file" or - * "directory". + * @brief The type of the resource. The value may be "file" or "directory". If not set, the + * value is "file". */ class PathResourceType final { public: @@ -255,24 +131,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { AZ_STORAGE_FILES_DATALAKE_DLLEXPORT const static PathResourceType Directory; AZ_STORAGE_FILES_DATALAKE_DLLEXPORT const static PathResourceType File; - private: - std::string m_value; - }; - /** - * @brief Required. Indicates mode of the expiry time. - */ - class PathExpiryOptions final { - public: - PathExpiryOptions() = default; - explicit PathExpiryOptions(std::string value) : m_value(std::move(value)) {} - bool operator==(const PathExpiryOptions& other) const { return m_value == other.m_value; } - bool operator!=(const PathExpiryOptions& other) const { return !(*this == other); } - const std::string& ToString() const { return m_value; } - AZ_STORAGE_FILES_DATALAKE_DLLEXPORT const static PathExpiryOptions NeverExpire; - AZ_STORAGE_FILES_DATALAKE_DLLEXPORT const static PathExpiryOptions RelativeToCreation; - AZ_STORAGE_FILES_DATALAKE_DLLEXPORT const static PathExpiryOptions RelativeToNow; - AZ_STORAGE_FILES_DATALAKE_DLLEXPORT const static PathExpiryOptions Absolute; - private: std::string m_value; }; @@ -386,7 +244,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { * The type of the resource. The value may be "file" or "directory". If not set, the value * is "file". */ - std::string ResourceType; + Nullable ResourceType; }; namespace _detail { /** @@ -487,19 +345,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { const Core::Url& url, const ListFileSystemPathsOptions& options, const Core::Context& context); - struct ListFileSystemBlobHierarchySegmentOptions final - { - Nullable Prefix; - Nullable Delimiter; - Nullable Marker; - Nullable MaxResults; - Nullable Include; - }; - static Response ListBlobHierarchySegment( - Core::Http::_internal::HttpPipeline& pipeline, - const Core::Url& url, - const ListFileSystemBlobHierarchySegmentOptions& options, - const Core::Context& context); }; class PathClient final { public: @@ -536,7 +381,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { Nullable Acl; Nullable ProposedLeaseId; Nullable LeaseDuration; - Nullable ExpiryOptions; Nullable ExpiresOn; }; static Response Create( diff --git a/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp b/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp index 627f901ba7..94fef688cf 100644 --- a/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/rest_client.cpp @@ -8,8 +8,6 @@ #include #include -#include -#include #include #include @@ -23,47 +21,9 @@ #include #include #include -#include #include #include -namespace { -std::string ListBlobsIncludeFlagsToString( - const Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags& val) -{ - const Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags valueList[] = { - Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags::Copy, - Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags::Deleted, - Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags::Metadata, - Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags::Snapshots, - Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags::Uncommittedblobs, - Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags::Versions, - Azure::Storage::Files::DataLake::Models::ListBlobsIncludeFlags::Tags, - }; - const char* stringList[] = { - "copy", - "deleted", - "metadata", - "snapshots", - "uncommittedblobs", - "versions", - "tags", - }; - std::string ret; - for (size_t i = 0; i < 7; ++i) - { - if ((val & valueList[i]) == valueList[i]) - { - if (!ret.empty()) - { - ret += ","; - } - ret += stringList[i]; - } - } - return ret; -} -} // namespace namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace Models { namespace _detail { @@ -80,10 +40,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { const PublicAccessType PublicAccessType::Path("blob"); const PathResourceType PathResourceType::Directory("directory"); const PathResourceType PathResourceType::File("file"); - const PathExpiryOptions PathExpiryOptions::NeverExpire("NeverExpire"); - const PathExpiryOptions PathExpiryOptions::RelativeToCreation("RelativeToCreation"); - const PathExpiryOptions PathExpiryOptions::RelativeToNow("RelativeToNow"); - const PathExpiryOptions PathExpiryOptions::Absolute("Absolute"); } // namespace Models namespace _detail { Response FileSystemClient::ListPaths( @@ -158,11 +114,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { vectorElement2.EncryptionScope = var0["EncryptionScope"].get(); } - vectorElement2.CreatedOn = var0["creationTime"].get(); - if (var0.count("expiryTime") != 0) - { - vectorElement2.ExpiresOn = var0["expiryTime"].get(); - } if (var0.count("etag") != 0) { vectorElement2.ETag = var0["etag"].get(); @@ -176,540 +127,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { } return Response(std::move(response), std::move(pRawResponse)); } - Response FileSystemClient::ListBlobHierarchySegment( - Core::Http::_internal::HttpPipeline& pipeline, - const Core::Url& url, - const ListFileSystemBlobHierarchySegmentOptions& options, - const Core::Context& context) - { - auto request = Core::Http::Request(Core::Http::HttpMethod::Get, url); - request.GetUrl().AppendQueryParameter("restype", "container"); - request.GetUrl().AppendQueryParameter("comp", "list"); - if (options.Prefix.HasValue() && !options.Prefix.Value().empty()) - { - request.GetUrl().AppendQueryParameter( - "prefix", _internal::UrlEncodeQueryParameter(options.Prefix.Value())); - } - if (options.Delimiter.HasValue() && !options.Delimiter.Value().empty()) - { - request.GetUrl().AppendQueryParameter( - "delimiter", _internal::UrlEncodeQueryParameter(options.Delimiter.Value())); - } - if (options.Marker.HasValue() && !options.Marker.Value().empty()) - { - request.GetUrl().AppendQueryParameter( - "marker", _internal::UrlEncodeQueryParameter(options.Marker.Value())); - } - if (options.MaxResults.HasValue()) - { - request.GetUrl().AppendQueryParameter( - "maxResults", std::to_string(options.MaxResults.Value())); - } - if (options.Include.HasValue() - && !ListBlobsIncludeFlagsToString(options.Include.Value()).empty()) - { - request.GetUrl().AppendQueryParameter( - "include", - _internal::UrlEncodeQueryParameter( - ListBlobsIncludeFlagsToString(options.Include.Value()))); - } - request.GetUrl().AppendQueryParameter("showonly", "deleted"); - request.SetHeader("x-ms-version", "2021-06-08"); - auto pRawResponse = pipeline.Send(request, context); - auto httpStatusCode = pRawResponse->GetStatusCode(); - if (httpStatusCode != Core::Http::HttpStatusCode::Ok) - { - throw StorageException::CreateFromResponse(std::move(pRawResponse)); - } - Models::ListBlobsHierarchySegmentResponse response; - { - const auto& responseBody = pRawResponse->GetBody(); - _internal::XmlReader reader( - reinterpret_cast(responseBody.data()), responseBody.size()); - enum class XmlTagEnum - { - kUnknown, - kEnumerationResults, - kPrefix, - kMarker, - kMaxResults, - kDelimiter, - kSegment, - kBlobPrefixes, - kBlobPrefix, - kName, - kBlobItems, - kBlob, - kDeleted, - kSnapshot, - kVersionId, - kIsCurrentVersion, - kProperties, - kCreationTime, - kLastModified, - kEtag, - kContentLength, - kContentType, - kContentEncoding, - kContentLanguage, - kContentMD5, - kContentDisposition, - kCacheControl, - kXMsBlobSequenceNumber, - kCopyId, - kCopySource, - kCopyProgress, - kCopyCompletionTime, - kCopyStatusDescription, - kServerEncrypted, - kIncrementalCopy, - kDestinationSnapshot, - kDeletedTime, - kRemainingRetentionDays, - kAccessTierInferred, - kCustomerProvidedKeySha256, - kEncryptionScope, - kAccessTierChangeTime, - kTagCount, - kExpiryTime, - kSealed, - kLastAccessTime, - kDeleteTime, - kDeletionId, - kNextMarker, - }; - const std::unordered_map XmlTagEnumMap{ - {"EnumerationResults", XmlTagEnum::kEnumerationResults}, - {"Prefix", XmlTagEnum::kPrefix}, - {"Marker", XmlTagEnum::kMarker}, - {"MaxResults", XmlTagEnum::kMaxResults}, - {"Delimiter", XmlTagEnum::kDelimiter}, - {"Segment", XmlTagEnum::kSegment}, - {"BlobPrefixes", XmlTagEnum::kBlobPrefixes}, - {"BlobPrefix", XmlTagEnum::kBlobPrefix}, - {"Name", XmlTagEnum::kName}, - {"BlobItems", XmlTagEnum::kBlobItems}, - {"Blob", XmlTagEnum::kBlob}, - {"Deleted", XmlTagEnum::kDeleted}, - {"Snapshot", XmlTagEnum::kSnapshot}, - {"VersionId", XmlTagEnum::kVersionId}, - {"IsCurrentVersion", XmlTagEnum::kIsCurrentVersion}, - {"Properties", XmlTagEnum::kProperties}, - {"Creation-Time", XmlTagEnum::kCreationTime}, - {"Last-Modified", XmlTagEnum::kLastModified}, - {"Etag", XmlTagEnum::kEtag}, - {"Content-Length", XmlTagEnum::kContentLength}, - {"Content-Type", XmlTagEnum::kContentType}, - {"Content-Encoding", XmlTagEnum::kContentEncoding}, - {"Content-Language", XmlTagEnum::kContentLanguage}, - {"Content-MD5", XmlTagEnum::kContentMD5}, - {"Content-Disposition", XmlTagEnum::kContentDisposition}, - {"Cache-Control", XmlTagEnum::kCacheControl}, - {"x-ms-blob-sequence-number", XmlTagEnum::kXMsBlobSequenceNumber}, - {"CopyId", XmlTagEnum::kCopyId}, - {"CopySource", XmlTagEnum::kCopySource}, - {"CopyProgress", XmlTagEnum::kCopyProgress}, - {"CopyCompletionTime", XmlTagEnum::kCopyCompletionTime}, - {"CopyStatusDescription", XmlTagEnum::kCopyStatusDescription}, - {"ServerEncrypted", XmlTagEnum::kServerEncrypted}, - {"IncrementalCopy", XmlTagEnum::kIncrementalCopy}, - {"DestinationSnapshot", XmlTagEnum::kDestinationSnapshot}, - {"DeletedTime", XmlTagEnum::kDeletedTime}, - {"RemainingRetentionDays", XmlTagEnum::kRemainingRetentionDays}, - {"AccessTierInferred", XmlTagEnum::kAccessTierInferred}, - {"CustomerProvidedKeySha256", XmlTagEnum::kCustomerProvidedKeySha256}, - {"EncryptionScope", XmlTagEnum::kEncryptionScope}, - {"AccessTierChangeTime", XmlTagEnum::kAccessTierChangeTime}, - {"TagCount", XmlTagEnum::kTagCount}, - {"Expiry-Time", XmlTagEnum::kExpiryTime}, - {"Sealed", XmlTagEnum::kSealed}, - {"LastAccessTime", XmlTagEnum::kLastAccessTime}, - {"DeleteTime", XmlTagEnum::kDeleteTime}, - {"DeletionId", XmlTagEnum::kDeletionId}, - {"NextMarker", XmlTagEnum::kNextMarker}, - }; - std::vector xmlPath; - Models::BlobPrefix vectorElement1; - Models::BlobItemInternal vectorElement2; - while (true) - { - auto node = reader.Read(); - if (node.Type == _internal::XmlNodeType::End) - { - break; - } - else if (node.Type == _internal::XmlNodeType::StartTag) - { - auto ite = XmlTagEnumMap.find(node.Name); - xmlPath.push_back(ite == XmlTagEnumMap.end() ? XmlTagEnum::kUnknown : ite->second); - } - else if (node.Type == _internal::XmlNodeType::Text) - { - if (xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kPrefix) - { - response.Prefix = node.Value; - } - else if ( - xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kMarker) - { - response.Marker = node.Value; - } - else if ( - xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kMaxResults) - { - response.MaxResults = std::stoi(node.Value); - } - else if ( - xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kDelimiter) - { - response.Delimiter = node.Value; - } - else if ( - xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobPrefixes - && xmlPath[3] == XmlTagEnum::kBlobPrefix && xmlPath[4] == XmlTagEnum::kName) - { - vectorElement1.Name = node.Value; - } - else if ( - xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kName) - { - vectorElement2.Name = node.Value; - } - else if ( - xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kDeleted) - { - vectorElement2.Deleted = node.Value == std::string("true"); - } - else if ( - xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kSnapshot) - { - vectorElement2.Snapshot = node.Value; - } - else if ( - xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kVersionId) - { - vectorElement2.VersionId = node.Value; - } - else if ( - xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kIsCurrentVersion) - { - vectorElement2.IsCurrentVersion = node.Value == std::string("true"); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCreationTime) - { - vectorElement2.Properties.CreationTime - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kLastModified) - { - vectorElement2.Properties.LastModified - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kEtag) - { - vectorElement2.Properties.Etag = ETag(node.Value); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kContentLength) - { - vectorElement2.Properties.ContentLength = std::stoll(node.Value); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kContentType) - { - vectorElement2.Properties.ContentType = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kContentEncoding) - { - vectorElement2.Properties.ContentEncoding = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kContentLanguage) - { - vectorElement2.Properties.ContentLanguage = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kContentMD5) - { - vectorElement2.Properties.ContentMD5 = Core::Convert::Base64Decode(node.Value); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kContentDisposition) - { - vectorElement2.Properties.ContentDisposition = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCacheControl) - { - vectorElement2.Properties.CacheControl = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kXMsBlobSequenceNumber) - { - vectorElement2.Properties.BlobSequenceNumber = std::stoll(node.Value); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCopyId) - { - vectorElement2.Properties.CopyId = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCopySource) - { - vectorElement2.Properties.CopySource = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCopyProgress) - { - vectorElement2.Properties.CopyProgress = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCopyCompletionTime) - { - vectorElement2.Properties.CopyCompletionTime - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCopyStatusDescription) - { - vectorElement2.Properties.CopyStatusDescription = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kServerEncrypted) - { - vectorElement2.Properties.ServerEncrypted = node.Value == std::string("true"); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kIncrementalCopy) - { - vectorElement2.Properties.IncrementalCopy = node.Value == std::string("true"); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kDestinationSnapshot) - { - vectorElement2.Properties.DestinationSnapshot = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kDeletedTime) - { - vectorElement2.Properties.DeletedTime - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kRemainingRetentionDays) - { - vectorElement2.Properties.RemainingRetentionDays = std::stoi(node.Value); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kAccessTierInferred) - { - vectorElement2.Properties.AccessTierInferred = node.Value == std::string("true"); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kCustomerProvidedKeySha256) - { - vectorElement2.Properties.CustomerProvidedKeySha256 = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kEncryptionScope) - { - vectorElement2.Properties.EncryptionScope = node.Value; - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kAccessTierChangeTime) - { - vectorElement2.Properties.AccessTierChangeTime - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kTagCount) - { - vectorElement2.Properties.TagCount = std::stoi(node.Value); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kExpiryTime) - { - vectorElement2.Properties.ExpiresOn - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kSealed) - { - vectorElement2.Properties.IsSealed = node.Value == std::string("true"); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kLastAccessTime) - { - vectorElement2.Properties.LastAccessedOn - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 6 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kProperties - && xmlPath[5] == XmlTagEnum::kDeleteTime) - { - vectorElement2.Properties.DeleteTime - = DateTime::Parse(node.Value, Azure::DateTime::DateFormat::Rfc1123); - } - else if ( - xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob && xmlPath[4] == XmlTagEnum::kDeletionId) - { - vectorElement2.DeletionId = node.Value; - } - else if ( - xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kNextMarker) - { - response.NextMarker = node.Value; - } - } - else if (node.Type == _internal::XmlNodeType::Attribute) - { - if (xmlPath.size() == 1 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && node.Name == "ServiceEndpoint") - { - response.ServiceEndpoint = node.Value; - } - else if ( - xmlPath.size() == 1 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && node.Name == "ContainerName") - { - response.ContainerName = node.Value; - } - } - else if (node.Type == _internal::XmlNodeType::EndTag) - { - if (xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobPrefixes - && xmlPath[3] == XmlTagEnum::kBlobPrefix) - { - response.Segment.BlobPrefixes.push_back(std::move(vectorElement1)); - vectorElement1 = Models::BlobPrefix(); - } - else if ( - xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults - && xmlPath[1] == XmlTagEnum::kSegment && xmlPath[2] == XmlTagEnum::kBlobItems - && xmlPath[3] == XmlTagEnum::kBlob) - { - response.Segment.BlobItems.push_back(std::move(vectorElement2)); - vectorElement2 = Models::BlobItemInternal(); - } - xmlPath.pop_back(); - } - } - } - return Response( - std::move(response), std::move(pRawResponse)); - } Response PathClient::Create( Core::Http::_internal::HttpPipeline& pipeline, const Core::Url& url, @@ -857,10 +274,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { request.SetHeader("x-ms-lease-duration", std::to_string(options.LeaseDuration.Value())); } - if (options.ExpiryOptions.HasValue() && !options.ExpiryOptions.Value().ToString().empty()) - { - request.SetHeader("x-ms-expiry-option", options.ExpiryOptions.Value().ToString()); - } if (options.ExpiresOn.HasValue() && !options.ExpiresOn.Value().empty()) { request.SetHeader("x-ms-expiry-time", options.ExpiresOn.Value()); @@ -1106,7 +519,11 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { throw StorageException::CreateFromResponse(std::move(pRawResponse)); } Models::UndeletePathResult response; - response.ResourceType = pRawResponse->GetHeaders().at("x-ms-resource-type"); + if (pRawResponse->GetHeaders().count("x-ms-resource-type") != 0) + { + response.ResourceType + = Models::PathResourceType(pRawResponse->GetHeaders().at("x-ms-resource-type")); + } return Response(std::move(response), std::move(pRawResponse)); } Response PathClient::GetAccessControlList( diff --git a/sdk/storage/azure-storage-files-datalake/swagger/README.md b/sdk/storage/azure-storage-files-datalake/swagger/README.md index 8bc9e92e05..d7a1f3babe 100644 --- a/sdk/storage/azure-storage-files-datalake/swagger/README.md +++ b/sdk/storage/azure-storage-files-datalake/swagger/README.md @@ -70,6 +70,7 @@ directive: delete $["/{filesystem}/{path}"].get; delete $["/{filesystem}/{path}"].patch; delete $["/{filesystem}/{path}?comp=expiry"]; + delete $["/{filesystem}?restype=container&comp=list&hierarchy"]; ``` ### API Version @@ -132,7 +133,6 @@ directive: where: $.parameters transform: > $.Continuation["x-ms-client-name"] = "ContinuationToken"; - $.ListBlobsInclude.items["x-ms-enum"]["name"] = "ListBlobsIncludeFlags"; $.EncryptionKeySha256["format"] = "byte"; - from: swagger-document where: $.definitions @@ -184,9 +184,8 @@ directive: $.Path.properties["contentLength"]["x-ms-client-name"] = "FileSize"; $.Path.properties["isDirectory"]["x-ms-client-default"] = false; $.Path.properties["EncryptionScope"]["x-nullable"] = true; - $.Path.properties["creationTime"]["x-ms-client-name"] = "CreatedOn"; - $.Path.properties["expiryTime"]["x-ms-client-name"] = "ExpiresOn"; - $.Path.properties["expiryTime"]["x-nullable"] = true; + delete $.Path.properties["creationTime"]; + delete $.Path.properties["expiryTime"]; $.Path.properties["etag"] = {"type": "string", "x-ms-format": "string", "x-ms-client-default": "", "x-ms-client-name": "ETag"}; delete $.Path.properties["eTag"]; $.PathList["x-namespace"] = "_detail"; @@ -200,10 +199,24 @@ directive: delete $["Last-Modified"]; ``` +### ListBlobsByHierarchy + +```yaml +directive: + - from: swagger-document + where: $.parameters + transform: > + $.ListBlobsInclude.items["x-ms-enum"]["name"] = "ListBlobsIncludeFlags"; +``` + ### CreatePath ```yaml directive: + - from: swagger-document + where: $["x-ms-paths"]["/{filesystem}/{path}"].put.parameters + transform: > + $ = $.filter(p => !(p["$ref"] && (p["$ref"].endsWith("#/parameters/PathExpiryOptionsOptional")))); - from: swagger-document where: $["x-ms-paths"]["/{filesystem}/{path}"].put.responses transform: > @@ -222,6 +235,18 @@ directive: }; ``` + +### SetExpiry + +```yaml +directive: + - from: swagger-document + where: $.parameters + transform: > + delete $["PathExpiryOptions"]; + delete $["PathExpiryOptionsOptional"]; +``` + ### DeletePath ```yaml @@ -267,6 +292,21 @@ directive: } ``` +### UndeletePath + +```yaml +directive: + - from: swagger-document + where: $["x-ms-paths"]["/{filesystem}/{path}?comp=undelete"].put.responses + transform: > + $["200"].headers["x-ms-resource-type"]["enum"] = ["directory", "file"]; + $["200"].headers["x-ms-resource-type"]["x-ms-enum"] = { + "name": "PathResourceType", + "modelAsString": false + }; + $["200"].headers["x-ms-resource-type"]["x-nullable"] = true; +``` + ### GetPathAccessControlList ```yaml