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

Add creation expiry time #3961

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,60 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
using SignedIdentifier = Blobs::Models::SignedIdentifier;
using FileQueryArrowField = Blobs::Models::BlobQueryArrowField;
using FileQueryArrowFieldType = Blobs::Models::BlobQueryArrowFieldType;

/**
* @brief An access control object.
*/
struct Acl final
{
/**
* The scope of the ACL.
*/
std::string Scope;

/**
* The type of the ACL.
*/
std::string Type;

/**
* The ID of the ACL.
*/
std::string Id;

/**
* The permissions of the ACL.
*/
std::string Permissions;

/**
* @brief Creates an Acl based on acl input string.
* @param aclString the string to be parsed to Acl.
* @return Acl
*/
static Acl FromString(const std::string& aclString);

/**
* @brief Creates a string from an Acl.
* @param acl the acl object to be serialized to a string.
* @return std::string
*/
static std::string ToString(const Acl& acl);

/**
* @brief Creates a vector of Acl from a string that indicates multiple acls.
* @param aclsString the string that contains multiple acls.
* @return std::vector<Acl>
*/
static std::vector<Acl> DeserializeAcls(const std::string& aclsString);

/**
* @brief Creates a string that contains several Acls.
* @param aclsArray the acls to be serialized into a string.
* @return std::string
*/
static std::string SerializeAcls(const std::vector<Acl>& aclsArray);
};
} // namespace Models

using DownloadFileToOptions = Blobs::DownloadBlobToOptions;
Expand Down Expand Up @@ -378,6 +432,27 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
PathAccessConditions AccessConditions;
};

using ScheduleFileExpiryOriginType = Blobs::Models::ScheduleBlobExpiryOriginType;

/**
* @brief Optional parameters for #Azure::Storage::Files::DataLake::FileClient::UploadFrom.
*/
struct ScheduleFileDeletionOptions final
{
/**
* The expiry time from the specified origin. Only work if ExpiryOrigin is
* ScheduleFileExpiryOriginType::RelativeToCreation or
* ScheduleFileExpiryOriginType::RelativeToNow.
*/
Azure::Nullable<std::chrono::milliseconds> TimeToExpire;

/**
* The expiry time in RFC1123 format. Only work if ExpiryOrigin is
* ScheduleFileExpiryOriginType::Absolute.
*/
Azure::Nullable<DateTime> ExpiresOn;
};

using SchedulePathDeletionOptions = ScheduleFileDeletionOptions;

/**
Expand Down Expand Up @@ -653,27 +728,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
} TransferOptions;
};

using ScheduleFileExpiryOriginType = Blobs::Models::ScheduleBlobExpiryOriginType;

/**
* @brief Optional parameters for #Azure::Storage::Files::DataLake::FileClient::UploadFrom.
*/
struct ScheduleFileDeletionOptions final
{
/**
* The expiry time from the specified origin. Only work if ExpiryOrigin is
* ScheduleFileExpiryOriginType::RelativeToCreation or
* ScheduleFileExpiryOriginType::RelativeToNow.
*/
Azure::Nullable<std::chrono::milliseconds> TimeToExpire;

/**
* The expiry time in RFC1123 format. Only work if ExpiryOrigin is
* ScheduleFileExpiryOriginType::Absolute.
*/
Azure::Nullable<DateTime> ExpiresOn;
};

using AcquireLeaseOptions = Blobs::AcquireLeaseOptions;
using BreakLeaseOptions = Blobs::BreakLeaseOptions;
using RenewLeaseOptions = Blobs::RenewLeaseOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,60 +193,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
using RehydratePriority = Blobs::Models::RehydratePriority;
using ArchiveStatus = Blobs::Models::ArchiveStatus;

/**
* @brief An access control object.
*/
struct Acl final
{
/**
* The scope of the ACL.
*/
std::string Scope;

/**
* The type of the ACL.
*/
std::string Type;

/**
* The ID of the ACL.
*/
std::string Id;

/**
* The permissions of the ACL.
*/
std::string Permissions;

/**
* @brief Creates an Acl based on acl input string.
* @param aclString the string to be parsed to Acl.
* @return Acl
*/
static Acl FromString(const std::string& aclString);

/**
* @brief Creates a string from an Acl.
* @param acl the acl object to be serialized to a string.
* @return std::string
*/
static std::string ToString(const Acl& acl);

/**
* @brief Creates a vector of Acl from a string that indicates multiple acls.
* @param aclsString the string that contains multiple acls.
* @return std::vector<Acl>
*/
static std::vector<Acl> DeserializeAcls(const std::string& aclsString);

/**
* @brief Creates a string that contains several Acls.
* @param aclsArray the acls to be serialized into a string.
* @return std::string
*/
static std::string SerializeAcls(const std::vector<Acl>& aclsArray);
};

/**
* @brief The properties of the path.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,22 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_EQ(buffer, downloaded);
}

TEST_F(DataLakeFileClientTest, AppendFileWithFlush)
{
const int32_t bufferSize = 4 * 1024; // 4KB data size
std::vector<uint8_t> buffer(bufferSize, 'x');
auto bufferStream = std::make_unique<Azure::Core::IO::MemoryBodyStream>(
Azure::Core::IO::MemoryBodyStream(buffer));
auto properties1 = m_fileClient->GetProperties();

// Append with flush option
Files::DataLake::AppendFileOptions options;
options.Flush = true;
m_fileClient->Append(*bufferStream, 0, options);
auto properties2 = m_fileClient->GetProperties();
EXPECT_NE(properties1.Value.ETag, properties2.Value.ETag);
}

TEST_F(DataLakeFileClientTest, FileReadReturns)
{
const int32_t bufferSize = 4 * 1024; // 4KB data size
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"networkCallRecords": [
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.7.0-beta.1 (Windows 10 Enterprise 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "aa58933d-3f62-48d4-521c-b4a6402b0800",
"x-ms-version": "2021-04-10"
},
"Method": "PUT",
"Response": {
"BODY": "",
"REASON_PHRASE": "Created",
"STATUS_CODE": "201",
"content-length": "0",
"date": "Thu, 22 Sep 2022 06:23:12 GMT",
"etag": "\"0x8DA9C62ED0BEB25\"",
"last-modified": "Thu, 22 Sep 2022 06:23:12 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "aa58933d-3f62-48d4-521c-b4a6402b0800",
"x-ms-request-id": "b34a3186-e01e-0055-644b-cec224000000",
"x-ms-version": "2021-04-10"
},
"Url": "https://REDACTED.blob.core.windows.net/datalakefileclienttestappendfilewithflush?restype=container"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-files-datalake/12.4.0-beta.1 (Windows 10 Enterprise 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "29b5eac1-eb3e-477f-47a9-0756f1565632",
"x-ms-version": "2021-06-08"
},
"Method": "PUT",
"Response": {
"BODY": "",
"REASON_PHRASE": "Created",
"STATUS_CODE": "201",
"content-length": "0",
"date": "Thu, 22 Sep 2022 06:23:13 GMT",
"etag": "\"0x8DA9C62EDD4DA1A\"",
"last-modified": "Thu, 22 Sep 2022 06:23:13 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "29b5eac1-eb3e-477f-47a9-0756f1565632",
"x-ms-request-id": "0d674b39-301f-000b-534b-ce29c4000000",
"x-ms-request-server-encrypted": "true",
"x-ms-version": "2021-06-08"
},
"Url": "https://REDACTED.dfs.core.windows.net/datalakefileclienttestappendfilewithflush/datalakefileclienttestappendfilewithflush?resource=file"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.7.0-beta.1 (Windows 10 Enterprise 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "c123b10c-b02a-4d1a-482b-412e935f7169",
"x-ms-version": "2021-04-10"
},
"Method": "HEAD",
"Response": {
"BODY": "",
"REASON_PHRASE": "OK",
"STATUS_CODE": "200",
"accept-ranges": "bytes",
"content-length": "0",
"content-type": "application/octet-stream",
"date": "Thu, 22 Sep 2022 06:23:13 GMT",
"etag": "\"0x8DA9C62EDD4DA1A\"",
"last-modified": "Thu, 22 Sep 2022 06:23:13 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-access-tier": "Hot",
"x-ms-access-tier-inferred": "true",
"x-ms-blob-type": "BlockBlob",
"x-ms-client-request-id": "c123b10c-b02a-4d1a-482b-412e935f7169",
"x-ms-creation-time": "Thu, 22 Sep 2022 06:23:13 GMT",
"x-ms-group": "$superuser",
"x-ms-lease-state": "available",
"x-ms-lease-status": "unlocked",
"x-ms-owner": "$superuser",
"x-ms-permissions": "rw-r-----",
"x-ms-request-id": "b34a342d-e01e-0055-444b-cec224000000",
"x-ms-resource-type": "file",
"x-ms-server-encrypted": "true",
"x-ms-version": "2021-04-10"
},
"Url": "https://REDACTED.blob.core.windows.net/datalakefileclienttestappendfilewithflush/datalakefileclienttestappendfilewithflush"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-files-datalake/12.4.0-beta.1 (Windows 10 Enterprise 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "90b96b7c-73f8-4e1b-4951-fd5c2847eecc",
"x-ms-version": "2021-06-08"
},
"Method": "PATCH",
"Response": {
"BODY": "",
"REASON_PHRASE": "Accepted",
"STATUS_CODE": "202",
"content-length": "0",
"date": "Thu, 22 Sep 2022 06:23:14 GMT",
"etag": "\"0x8DA9C62EE33A993\"",
"last-modified": "Thu, 22 Sep 2022 06:23:14 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "90b96b7c-73f8-4e1b-4951-fd5c2847eecc",
"x-ms-request-id": "0d674b51-301f-000b-6a4b-ce29c4000000",
"x-ms-request-server-encrypted": "true",
"x-ms-version": "2021-06-08"
},
"Url": "https://REDACTED.dfs.core.windows.net/datalakefileclienttestappendfilewithflush/datalakefileclienttestappendfilewithflush?action=append&flush=true&position=0"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.7.0-beta.1 (Windows 10 Enterprise 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "14ce5112-d71f-44dd-7120-e89e7a4903c2",
"x-ms-version": "2021-04-10"
},
"Method": "HEAD",
"Response": {
"BODY": "",
"REASON_PHRASE": "OK",
"STATUS_CODE": "200",
"accept-ranges": "bytes",
"content-length": "4096",
"content-type": "application/octet-stream",
"date": "Thu, 22 Sep 2022 06:23:14 GMT",
"etag": "\"0x8DA9C62EE33A993\"",
"last-modified": "Thu, 22 Sep 2022 06:23:14 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-access-tier": "Hot",
"x-ms-access-tier-inferred": "true",
"x-ms-blob-type": "BlockBlob",
"x-ms-client-request-id": "14ce5112-d71f-44dd-7120-e89e7a4903c2",
"x-ms-creation-time": "Thu, 22 Sep 2022 06:23:13 GMT",
"x-ms-group": "$superuser",
"x-ms-lease-state": "available",
"x-ms-lease-status": "unlocked",
"x-ms-owner": "$superuser",
"x-ms-permissions": "rw-r-----",
"x-ms-request-id": "b34a3531-e01e-0055-324b-cec224000000",
"x-ms-resource-type": "file",
"x-ms-server-encrypted": "true",
"x-ms-version": "2021-04-10"
},
"Url": "https://REDACTED.blob.core.windows.net/datalakefileclienttestappendfilewithflush/datalakefileclienttestappendfilewithflush"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-files-datalake/12.4.0-beta.1 (Windows 10 Enterprise 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "51f29ec1-298b-462c-7dca-b510f2d61611",
"x-ms-version": "2021-06-08"
},
"Method": "DELETE",
"Response": {
"BODY": "",
"REASON_PHRASE": "OK",
"STATUS_CODE": "200",
"content-length": "0",
"date": "Thu, 22 Sep 2022 06:23:14 GMT",
"server": "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "51f29ec1-298b-462c-7dca-b510f2d61611",
"x-ms-delete-type-permanent": "false",
"x-ms-deletion-id": "133083013949561537",
"x-ms-request-id": "0d674b69-301f-000b-024b-ce29c4000000",
"x-ms-version": "2021-06-08"
},
"Url": "https://REDACTED.dfs.core.windows.net/datalakefileclienttestappendfilewithflush/datalakefileclienttestappendfilewithflush"
},
{
"Headers": {
"user-agent": "azsdk-cpp-storage-blobs/12.7.0-beta.1 (Windows 10 Enterprise 6.3 22000 22000.1.amd64fre.co_release.210604-1628)",
"x-ms-client-request-id": "21c7f2e4-f23f-4371-61fc-248c7577c236",
"x-ms-version": "2021-04-10"
},
"Method": "DELETE",
"Response": {
"BODY": "",
"REASON_PHRASE": "Accepted",
"STATUS_CODE": "202",
"content-length": "0",
"date": "Thu, 22 Sep 2022 06:23:15 GMT",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-client-request-id": "21c7f2e4-f23f-4371-61fc-248c7577c236",
"x-ms-request-id": "b34a3666-e01e-0055-504b-cec224000000",
"x-ms-version": "2021-04-10"
},
"Url": "https://REDACTED.blob.core.windows.net/datalakefileclienttestappendfilewithflush?restype=container"
}
]
}