Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hns soft delete #3963

Merged
merged 7 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ namespace Azure { namespace Storage { namespace Blobs {
friend class BlobServiceClient;
friend class BlobLeaseClient;
friend class BlobContainerBatch;
friend class Files::DataLake::DataLakeFileSystemClient;
};

}}} // namespace Azure::Storage::Blobs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,10 @@ namespace Azure { namespace Storage { namespace Blobs {
* Type of the blob.
*/
Models::BlobType BlobType;
/**
* The deletion ID associated with the deleted path.
*/
Nullable<std::string> DeletionId;
};
} // namespace _detail
/**
Expand Down Expand Up @@ -3447,6 +3451,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Nullable<std::string> Marker;
Nullable<int32_t> MaxResults;
Nullable<Models::ListBlobsIncludeFlags> Include;
Nullable<std::string> ShowOnly;
};
static Response<Models::_detail::ListBlobsByHierarchyResult> ListBlobsByHierarchy(
Core::Http::_internal::HttpPipeline& pipeline,
Expand Down
23 changes: 23 additions & 0 deletions sdk/storage/azure-storage-blobs/src/rest_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,7 @@ namespace Azure { namespace Storage { namespace Blobs {
kHasVersionsOnly,
kContentLength,
kBlobType,
kDeletionId,
};
const std::unordered_map<std::string, XmlTagEnum> XmlTagEnumMap{
{"EnumerationResults", XmlTagEnum::kEnumerationResults},
Expand Down Expand Up @@ -2370,6 +2371,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{"HasVersionsOnly", XmlTagEnum::kHasVersionsOnly},
{"Content-Length", XmlTagEnum::kContentLength},
{"BlobType", XmlTagEnum::kBlobType},
{"DeletionId", XmlTagEnum::kDeletionId},
};
std::vector<XmlTagEnum> xmlPath;
Models::_detail::BlobItem vectorElement1;
Expand Down Expand Up @@ -2807,6 +2809,13 @@ namespace Azure { namespace Storage { namespace Blobs {
{
vectorElement1.BlobType = Models::BlobType(node.Value);
}
else if (
xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults
&& xmlPath[1] == XmlTagEnum::kBlobs && xmlPath[2] == XmlTagEnum::kBlob
&& xmlPath[3] == XmlTagEnum::kDeletionId)
{
vectorElement1.DeletionId = node.Value;
}
}
else if (node.Type == _internal::XmlNodeType::Attribute)
{
Expand Down Expand Up @@ -2908,6 +2917,11 @@ namespace Azure { namespace Storage { namespace Blobs {
ListBlobsIncludeFlagsToString(options.Include.Value())));
}
request.SetHeader("x-ms-version", "2021-04-10");
if (options.ShowOnly.HasValue() && !options.ShowOnly.Value().empty())
{
request.GetUrl().AppendQueryParameter(
"showonly", _internal::UrlEncodeQueryParameter(options.ShowOnly.Value()));
}
auto pRawResponse = pipeline.Send(request, context);
auto httpStatusCode = pRawResponse->GetStatusCode();
if (httpStatusCode != Core::Http::HttpStatusCode::Ok)
Expand Down Expand Up @@ -2981,6 +2995,7 @@ namespace Azure { namespace Storage { namespace Blobs {
kHasVersionsOnly,
kContentLength,
kBlobType,
kDeletionId,
kBlobPrefix,
};
const std::unordered_map<std::string, XmlTagEnum> XmlTagEnumMap{
Expand Down Expand Up @@ -3043,6 +3058,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{"HasVersionsOnly", XmlTagEnum::kHasVersionsOnly},
{"Content-Length", XmlTagEnum::kContentLength},
{"BlobType", XmlTagEnum::kBlobType},
{"DeletionId", XmlTagEnum::kDeletionId},
{"BlobPrefix", XmlTagEnum::kBlobPrefix},
};
std::vector<XmlTagEnum> xmlPath;
Expand Down Expand Up @@ -3488,6 +3504,13 @@ namespace Azure { namespace Storage { namespace Blobs {
{
vectorElement1.BlobType = Models::BlobType(node.Value);
}
else if (
xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults
&& xmlPath[1] == XmlTagEnum::kBlobs && xmlPath[2] == XmlTagEnum::kBlob
&& xmlPath[3] == XmlTagEnum::kDeletionId)
{
vectorElement1.DeletionId = node.Value;
}
else if (
xmlPath.size() == 4 && xmlPath[0] == XmlTagEnum::kEnumerationResults
&& xmlPath[1] == XmlTagEnum::kBlobs && xmlPath[2] == XmlTagEnum::kBlobPrefix
Expand Down
15 changes: 15 additions & 0 deletions sdk/storage/azure-storage-blobs/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ directive:
{"value": "legalhold", "name": "LegalHold"},
{"value": "deletedwithversions", "name": "DeletedWithVersions"}
];
$["ListBlobsShowOnly"]= {
"name": "showonly",
"x-ms-client-name": "ShowOnly",
"in": "query",
"required": false,
"type": "string",
"x-ms-parameter-location": "method",
"description": "Include this parameter to specify one or more datasets to include in the response."
};
$.DeleteSnapshots["x-ms-enum"]["name"] = "DeleteSnapshotsOption";
$.DeleteSnapshots["x-ms-enum"]["values"] = [{"value": "include", "name": "IncludeSnapshots"},{"value":"only", "name": "OnlySnapshots"}];
$.BlobExpiryOptions["x-ms-enum"]["name"] = "ScheduleBlobExpiryOriginType";
Expand Down Expand Up @@ -829,6 +838,7 @@ directive:
$.BlobItemInternal.properties["BlobType"] = $.BlobPropertiesInternal.properties["BlobType"];
$.BlobItemInternal.properties["BlobType"]["x-ms-xml"] = {"name": "Properties/BlobType"};
delete $.BlobPropertiesInternal.properties["BlobType"];
$.BlobItemInternal.properties["DeletionId"] = {"type": "string"};
$.BlobItemInternal.required.push("BlobType", "BlobSize");
$.BlobItemInternal.properties["Name"].description = "Blob name.";
$.BlobItemInternal.properties["Deleted"].description = "Indicates whether this blob was deleted.";
Expand All @@ -837,6 +847,7 @@ directive:
$.BlobItemInternal.properties["IsCurrentVersion"].description = "Indicates if this is the current version of the blob.";
$.BlobItemInternal.properties["BlobType"].description = "Type of the blob.";
$.BlobItemInternal.properties["HasVersionsOnly"].description = "Indicates that this root blob has been deleted, but it has versions that are active.";
$.BlobItemInternal.properties["DeletionId"].description = "The deletion ID associated with the deleted path.";

$.BlobPropertiesInternal.properties["Etag"]["x-ms-client-name"] = "ETag";
$.BlobPropertiesInternal["x-ms-client-name"] = "BlobItemDetails";
Expand Down Expand Up @@ -916,6 +927,10 @@ directive:
delete $.ListBlobsHierarchySegmentResponse.properties["Segment"];
delete $.ListBlobsHierarchySegmentResponse.required;
$.ListBlobsHierarchySegmentResponse.properties["NextMarker"]["x-nullable"] = true;
- from: swagger-document
where: $["x-ms-paths"]["/{containerName}?restype=container&comp=list&hierarchy"].get.parameters
transform: >
$.push({"$ref": "#/parameters/ListBlobsShowOnly"});
```

### DownloadBlob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,32 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
const RenameDirectoryOptions& options = RenameDirectoryOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

/**
* @brief Gets the paths that have recently been soft deleted in this file system.
* @param options Optional parameters to list deleted paths.
* @param context Context for cancelling long running operations.
* @return Azure::Response<DataLakePathClient> The client targets the restored path.
* @remark This request is sent to Blob endpoint.
*/
ListDeletedPathsPagedResponse ListDeletedPaths(
const ListDeletedPathsOptions& options = ListDeletedPathsOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

/**
* @brief Restores a soft deleted path.
* @param deletedPath The path of the deleted path.
* @param deletionId The deletion ID associated with the soft deleted path. You can get soft
* deleted paths and their associated deletion IDs with ListDeletedPaths.
* @param context Context for cancelling long running operations.
* @return Azure::Response<DataLakePathClient> The client targets the restored path.
* @remark This request is sent to Blob endpoint.
*/
Azure::Response<DataLakePathClient> UndeletePath(
const std::string& deletedPath,
const std::string& deletionId,
const UndeletePathOptions& options = UndeletePathOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const;

private:
Azure::Core::Url m_fileSystemUrl;
Blobs::BlobContainerClient m_blobContainerClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {

using DownloadFileToOptions = Blobs::DownloadBlobToOptions;
using GetUserDelegationKeyOptions = Blobs::GetUserDelegationKeyOptions;
using GetServicePropertiesOptions = Blobs::GetServicePropertiesOptions;
using SetServicePropertiesOptions = Blobs::SetServicePropertiesOptions;
using EncryptionKey = Blobs::EncryptionKey;

/**
Expand Down Expand Up @@ -191,6 +193,39 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
Azure::Nullable<int32_t> PageSizeHint;
};

/**
* @brief Optional parameters for #Azure::Storage::Files::DataLake::FileSystemClient::ListPaths.
*/
struct ListDeletedPathsOptions final
{
/**
* Gets the paths that have recently been soft deleted in this file system.
*/
Azure::Nullable<std::string> Prefix;

/**
* The number of paths returned with each invocation is limited. If the number of paths to be
* returned exceeds this limit, a continuation token is returned in the response header
* x-ms-continuation. When a continuation token is returned in the response, it must be
* specified in a subsequent invocation of the list operation to continue listing the paths.
*/
Azure::Nullable<std::string> ContinuationToken;

/**
* An optional value that specifies the maximum number of items to return. If omitted or greater
* than 5,000, the response will include up to 5,000 items.
*/
Azure::Nullable<int32_t> PageSizeHint;
};

/**
* @brief Optional parameters for
* #Azure::Storage::Files::DataLake::FileSystemClient::UndeletePath.
*/
struct UndeletePathOptions final
{
};

/**
* @brief Optional parameters for
* #Azure::Storage::Files::DataLake::FileSystemClient::GetAccessPolicy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Azure { namespace Storage { namespace Files { namespace DataLake {

class DataLakeServiceClient;
class DataLakeFileSystemClient;
class DataLakePathClient;

namespace Models {
Expand All @@ -26,6 +27,13 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
// ServiceClient models:

using UserDelegationKey = Blobs::Models::UserDelegationKey;
using RetentionPolicy = Blobs::Models::RetentionPolicy;
using AnalyticsLogging = Blobs::Models::AnalyticsLogging;
using Metrics = Blobs::Models::Metrics;
using CorsRule = Blobs::Models::CorsRule;
using StaticWebsite = Blobs::Models::StaticWebsite;
using DataLakeServiceProperties = Blobs::Models::BlobServiceProperties;
using SetServicePropertiesResult = Blobs::Models::SetServicePropertiesResult;

/**
* @brief The detailed information of a file system.
Expand Down Expand Up @@ -443,6 +451,32 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {

using SetPathPermissionsResult = SetPathAccessControlListResult;

/**
* @brief A path that has been soft deleted.
*/
struct PathDeletedItem final
{
/**
* The name of the path.
*/
std::string Name;

/**
* The deletion ID associated with the deleted path.
*/
std::string DeletionId;

/**
* When the path was deleted.
*/
DateTime DeletedOn;

/**
* The number of days left before the soft deleted path will be permanently deleted.
*/
int64_t RemainingRetentionDays = int64_t();
};

// FileClient models:

using UploadFileFromResult = Blobs::Models::UploadBlockBlobResult;
Expand Down Expand Up @@ -712,6 +746,28 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
friend class Azure::Core::PagedResponse<ListPathsPagedResponse>;
};

/**
* @brief Response type for
* #Azure::Storage::Files::DataLake::DataLakeFileSystemClient::ListDeletedPaths.
*/
class ListDeletedPathsPagedResponse final
: public Azure::Core::PagedResponse<ListDeletedPathsPagedResponse> {
public:
/**
* Path items.
*/
std::vector<Models::PathDeletedItem> DeletedPaths;

private:
void OnNextPage(const Azure::Core::Context& context);

std::shared_ptr<DataLakeFileSystemClient> m_fileSystemClient;
ListDeletedPathsOptions m_operationOptions;

friend class DataLakeFileSystemClient;
friend class Azure::Core::PagedResponse<ListDeletedPathsPagedResponse>;
};

/**
* @brief Response type for
* #Azure::Storage::Files::DataLake::DataLakePathClient::SetAccessControlListRecursive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
return m_blobServiceClient.GetUserDelegationKey(expiresOn, options, context);
}

/**
* @brief Sets properties for a storage account's Blob service endpoint, including
* properties for Storage Analytics, CORS (Cross-Origin Resource Sharing) rules and soft delete
* settings. You can also use this operation to set the default request version for all incoming
* requests to the DataLake service that do not have a version specified.
*
* @param properties The DataLake service properties.
* @param options Optional parameters to execute this function.
* @param context Context for cancelling long running operations.
* @return A SetServicePropertiesResult on successfully setting the properties.
*/
Azure::Response<Models::SetServicePropertiesResult> SetProperties(
Models::DataLakeServiceProperties properties,
const SetServicePropertiesOptions& options = SetServicePropertiesOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const
{
return m_blobServiceClient.SetProperties(properties, options, context);
}

/**
* @brief Gets the properties of a storage account's datalake service, including properties
* for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules.
*
* @param options Optional parameters to execute this function.
* @param context Context for cancelling long running operations.
* @return A DataLakeServiceProperties describing the service properties.
*/
Azure::Response<Models::DataLakeServiceProperties> GetProperties(
const GetServicePropertiesOptions& options = GetServicePropertiesOptions(),
const Azure::Core::Context& context = Azure::Core::Context()) const
{
return m_blobServiceClient.GetProperties(options, context);
}

private:
Azure::Core::Url m_serviceUrl;
Blobs::BlobServiceClient m_blobServiceClient;
Expand Down
Loading