diff --git a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md index e6355e495..b91ddc816 100644 --- a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md @@ -20,6 +20,8 @@ - Removed `ContentRange` in `PathGetPropertiesResult`. - Renamed `ContentLength` in `GetDataLakePathPropertiesResult` and `CreateDataLakePathResult` to `FileSize` to be more accurate. - Renamed `GetUri` to `GetUrl`. +- Added `DataLakeLeaseClient`, all lease related APIs are moved to `DataLakeLeaseClient`. +- Changed lease duration to be `std::chrono::seconds`. ## 12.0.0-beta.6 (2020-01-14) diff --git a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt index 07027e6c5..c7d51f725 100644 --- a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt @@ -33,6 +33,7 @@ set( inc/azure/storage/files/datalake/datalake_directory_client.hpp inc/azure/storage/files/datalake/datalake_file_client.hpp inc/azure/storage/files/datalake/datalake_file_system_client.hpp + inc/azure/storage/files/datalake/datalake_lease_client.hpp inc/azure/storage/files/datalake/datalake_options.hpp inc/azure/storage/files/datalake/datalake_path_client.hpp inc/azure/storage/files/datalake/datalake_responses.hpp @@ -49,6 +50,7 @@ set( src/datalake_directory_client.cpp src/datalake_file_client.cpp src/datalake_file_system_client.cpp + src/datalake_lease_client.cpp src/datalake_path_client.cpp src/datalake_responses.cpp src/datalake_rest_client.cpp diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp index e3d45c6fa..934faad0f 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake.hpp @@ -6,6 +6,7 @@ #include "azure/storage/files/datalake/datalake_directory_client.hpp" #include "azure/storage/files/datalake/datalake_file_client.hpp" #include "azure/storage/files/datalake/datalake_file_system_client.hpp" +#include "azure/storage/files/datalake/datalake_lease_client.hpp" #include "azure/storage/files/datalake/datalake_path_client.hpp" #include "azure/storage/files/datalake/datalake_sas_builder.hpp" #include "azure/storage/files/datalake/datalake_service_client.hpp" diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp index f1c4fa34f..9295951f6 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_system_client.hpp @@ -215,6 +215,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { m_pipeline(std::move(pipeline)) { } + friend class DataLakeLeaseClient; friend class DataLakeServiceClient; }; }}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_lease_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_lease_client.hpp new file mode 100644 index 000000000..e98cb2ef9 --- /dev/null +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_lease_client.hpp @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#include + +#include "azure/storage/files/datalake/datalake_file_system_client.hpp" +#include "azure/storage/files/datalake/datalake_path_client.hpp" + +namespace Azure { namespace Storage { namespace Files { namespace DataLake { + + /** + * @brief DataLakeLeaseClient allows you to manipulate Azure Storage leases on filesystems and + * paths. + */ + class DataLakeLeaseClient { + public: + /** + * @brief Initializes a new instance of the DataLakeLeaseClient. + * + * @param pathClient A DataLakePathClient representing the datalake path being leased. + * @param leaseId A lease ID. This is not required for break operation. + */ + explicit DataLakeLeaseClient(DataLakePathClient pathClient, std::string leaseId) + : m_blobLeaseClient(std::move(pathClient.m_blobClient), std::move(leaseId)) + { + } + + /** + * @brief Initializes a new instance of the DataLakeLeaseClient. + * + * @param fileSystemClient A DataLakeFileSystemClient representing the filesystem being leased. + * @param leaseId A lease ID. This is not required for break operation. + */ + explicit DataLakeLeaseClient(DataLakeFileSystemClient fileSystemClient, std::string leaseId) + : m_blobLeaseClient(std::move(fileSystemClient.m_blobContainerClient), std::move(leaseId)) + { + } + + /** + * @brief Gets a unique lease ID. + * + * @return A unique lease ID. + */ + static std::string CreateUniqueLeaseId() + { + return Blobs::BlobLeaseClient::CreateUniqueLeaseId(); + }; + + /** + * @brief A value representing infinite lease duration. + */ + AZ_STORAGE_FILES_DATALAKE_DLLEXPORT const static std::chrono::seconds InfiniteLeaseDuration; + + /** + * @brief Get lease id of this lease client. + * + * @return Lease id of this lease client. + */ + std::string GetLeaseId() const { return m_blobLeaseClient.GetLeaseId(); } + + /** + * @brief Acquires a lease on the datalake path or datalake path container. + * + * @param proposedLeaseId Proposed lease ID, in a GUID string format. + * @param duration Specifies the duration of + * the lease, in seconds, or InfiniteLeaseDuration for a lease that never + * expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be + * changed using renew or change. + * @param options Optional parameters to execute this function. + * @return A AcquireDataLakeLeaseResult describing the lease. + */ + Azure::Core::Response Acquire( + std::chrono::seconds duration, + const AcquireDataLakeLeaseOptions& options = AcquireDataLakeLeaseOptions()) + { + return m_blobLeaseClient.Acquire(duration, options); + } + + /** + * @brief Renews the datalake path or datalake path container's previously-acquired lease. + * + * @param leaseId ID of the previously-acquired lease. + * @param options Optional parameters to execute this function. + * @return A RenewDataLakeLeaseResult describing the lease. + */ + Azure::Core::Response Renew( + const RenewDataLakeLeaseOptions& options = RenewDataLakeLeaseOptions()) + { + return m_blobLeaseClient.Renew(options); + } + + /** + * @brief Releases the datalake path or datalake path container's previously-acquired lease. + * + * @param leaseId ID of the previously-acquired lease. + * @param options Optional parameters to execute this function. + * @return A ReleaseDataLakeLeaseResult describing the updated container. + */ + Azure::Core::Response Release( + const ReleaseDataLakeLeaseOptions& options = ReleaseDataLakeLeaseOptions()) + { + return m_blobLeaseClient.Release(options); + } + + /** + * @brief Changes the lease of an active lease. + * + * @param leaseId ID of the previously-acquired lease. + * @param proposedLeaseId Proposed lease ID, in a GUID string format. + * @param options Optional parameters to execute this function. + * @return A ChangeDataLakeLeaseResult describing the lease. + */ + Azure::Core::Response Change( + const std::string& proposedLeaseId, + const ChangeDataLakeLeaseOptions& options = ChangeDataLakeLeaseOptions()) + { + return m_blobLeaseClient.Change(proposedLeaseId, options); + } + + /** + * @brief Breaks the previously-acquired lease. + * + * @param options Optional parameters to execute this function. + * @return A BreakDataLakeLeaseResult describing the broken lease. + */ + Azure::Core::Response Break( + const BreakDataLakeLeaseOptions& options = BreakDataLakeLeaseOptions()) + { + return m_blobLeaseClient.Break(options); + } + + private: + Blobs::BlobLeaseClient m_blobLeaseClient; + }; + +}}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp index 76ff928c0..15955ac09 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp @@ -788,10 +788,10 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { Azure::Core::Nullable ExpiresOn; }; - using AcquireDataLakePathLeaseOptions = Blobs::AcquireBlobLeaseOptions; - using BreakDataLakePathLeaseOptions = Blobs::BreakBlobLeaseOptions; - using RenewDataLakePathLeaseOptions = Blobs::RenewBlobLeaseOptions; - using ReleaseDataLakePathLeaseOptions = Blobs::ReleaseBlobLeaseOptions; - using ChangeDataLakePathLeaseOptions = Blobs::ChangeBlobLeaseOptions; + using AcquireDataLakeLeaseOptions = Blobs::AcquireBlobLeaseOptions; + using BreakDataLakeLeaseOptions = Blobs::BreakBlobLeaseOptions; + using RenewDataLakeLeaseOptions = Blobs::RenewBlobLeaseOptions; + using ReleaseDataLakeLeaseOptions = Blobs::ReleaseBlobLeaseOptions; + using ChangeDataLakeLeaseOptions = Blobs::ChangeBlobLeaseOptions; }}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp index 75ae89982..9f3636447 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_path_client.hpp @@ -219,5 +219,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { } friend class DataLakeFileSystemClient; + friend class DataLakeLeaseClient; }; }}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp index 812c81899..45a096a6f 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp @@ -63,11 +63,11 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam Azure::Core::Nullable ContinuationToken; }; - using AcquireDataLakePathLeaseResult = Blobs::Models::AcquireBlobLeaseResult; - using RenewDataLakePathLeaseResult = Blobs::Models::RenewBlobLeaseResult; - using ReleaseDataLakePathLeaseResult = Blobs::Models::ReleaseBlobLeaseResult; - using ChangeDataLakePathLeaseResult = Blobs::Models::ChangeBlobLeaseResult; - using BreakDataLakePathLeaseResult = Blobs::Models::BreakBlobLeaseResult; + using AcquireDataLakeLeaseResult = Blobs::Models::AcquireBlobLeaseResult; + using RenewDataLakeLeaseResult = Blobs::Models::RenewBlobLeaseResult; + using ReleaseDataLakeLeaseResult = Blobs::Models::ReleaseBlobLeaseResult; + using ChangeDataLakeLeaseResult = Blobs::Models::ChangeBlobLeaseResult; + using BreakDataLakeLeaseResult = Blobs::Models::BreakBlobLeaseResult; struct Acl { diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_lease_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_lease_client.cpp new file mode 100644 index 000000000..34904a1a7 --- /dev/null +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_lease_client.cpp @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "azure/storage/files/datalake/datalake_lease_client.hpp" + +namespace Azure { namespace Storage { namespace Files { namespace DataLake { + + const std::chrono::seconds DataLakeLeaseClient::InfiniteLeaseDuration{-1}; + +}}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-files-shares/CHANGELOG.md b/sdk/storage/azure-storage-files-shares/CHANGELOG.md index 251063eb1..9e0873d02 100644 --- a/sdk/storage/azure-storage-files-shares/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-shares/CHANGELOG.md @@ -11,6 +11,8 @@ - Moved all protocol layer generated result types to `Details` namespace. - Renamed `ShareItems` in `ListSharesResponse` to `Items`. - Renamed `ShareItems` in `ServiceListSharesSinglePageResult` to `Items`. +- Added `ShareLeaseClient`, all lease related APIs are moved to `ShareLeaseClient`. +- Changed lease duration to be `std::chrono::seconds`. ## 12.0.0-beta.6 (2020-01-14) diff --git a/sdk/storage/azure-storage-files-shares/CMakeLists.txt b/sdk/storage/azure-storage-files-shares/CMakeLists.txt index a15666eb2..de2e5add7 100644 --- a/sdk/storage/azure-storage-files-shares/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-shares/CMakeLists.txt @@ -35,6 +35,7 @@ set( inc/azure/storage/files/shares/share_directory_client.hpp inc/azure/storage/files/shares/share_file_attribute.hpp inc/azure/storage/files/shares/share_file_client.hpp + inc/azure/storage/files/shares/share_lease_client.hpp inc/azure/storage/files/shares/share_options.hpp inc/azure/storage/files/shares/share_responses.hpp inc/azure/storage/files/shares/share_sas_builder.hpp @@ -48,6 +49,7 @@ set( src/share_client.cpp src/share_directory_client.cpp src/share_file_client.cpp + src/share_lease_client.cpp src/share_rest_client.cpp src/share_sas_builder.cpp src/share_service_client.cpp diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp index d48c1e835..39dbc7d29 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares.hpp @@ -7,5 +7,6 @@ #include "azure/storage/files/shares/share_client.hpp" #include "azure/storage/files/shares/share_directory_client.hpp" #include "azure/storage/files/shares/share_file_client.hpp" +#include "azure/storage/files/shares/share_lease_client.hpp" #include "azure/storage/files/shares/share_sas_builder.hpp" #include "azure/storage/files/shares/share_service_client.hpp" diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp index a22d0c4e0..2288855fb 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_client.hpp @@ -229,6 +229,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { : m_shareUrl(std::move(shareUri)), m_pipeline(std::move(pipeline)) { } + friend class ShareLeaseClient; friend class ShareServiceClient; }; }}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp index 07314a263..6ac6854fa 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp @@ -297,52 +297,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ForceCloseAllShareFileHandlesOptions& options = ForceCloseAllShareFileHandlesOptions()) const; - /** - * @brief Acquires an infinite lease on the file. - * - * @param proposedLeaseId Proposed lease ID, in a GUID string format. - * @param options Optional parameters to execute this function. - * @return Azure::Core::Response describing the lease. - */ - Azure::Core::Response AcquireLease( - const std::string& proposedLeaseId, - const AcquireShareFileLeaseOptions& options = AcquireShareFileLeaseOptions()) const; - - /** - * @brief Releases the file's previously-acquired lease. - * - * @param leaseId ID of the previously-acquired lease. - * @param options Optional parameters to execute this function. - * @return Azure::Core::Response describing the updated - * container. - */ - Azure::Core::Response ReleaseLease( - const std::string& leaseId, - const ReleaseShareFileLeaseOptions& options = ReleaseShareFileLeaseOptions()) const; - - /** - * @brief Changes the lease of an active lease. - * - * @param leaseId ID of the previously-acquired lease. - * @param proposedLeaseId Proposed lease ID, in a GUID string format. - * @param options Optional parameters to execute this function. - * @return Azure::Core::Response describing the changed - * lease. - */ - Azure::Core::Response ChangeLease( - const std::string& leaseId, - const std::string& proposedLeaseId, - const ChangeShareFileLeaseOptions& options = ChangeShareFileLeaseOptions()) const; - - /** - * @brief Breaks the previously-acquired lease. - * - * @param options Optional parameters to execute this function. - * @return Azure::Core::Response describing the broken lease. - */ - Azure::Core::Response BreakLease( - const BreakShareFileLeaseOptions& options = BreakShareFileLeaseOptions()) const; - private: Azure::Core::Http::Url m_shareFileUrl; std::shared_ptr m_pipeline; @@ -356,5 +310,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { friend class ShareClient; friend class ShareDirectoryClient; + friend class ShareLeaseClient; }; }}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_lease_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_lease_client.hpp new file mode 100644 index 000000000..95040dddd --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_lease_client.hpp @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#include "azure/storage/files/shares/share_client.hpp" +#include "azure/storage/files/shares/share_file_client.hpp" + +namespace Azure { namespace Storage { namespace Files { namespace Shares { + + /** + * @brief ShareLeaseClient allows you to manipulate Azure Storage leases on shares and files. + */ + class ShareLeaseClient { + public: + /** + * @brief Initializes a new instance of the ShareLeaseClient. + * + * @param fileClient A ShareFileClient representing the file being leased. + * @param leaseId A lease ID. This is not required for break operation. + */ + explicit ShareLeaseClient(ShareFileClient fileClient, std::string leaseId) + : m_fileClient(std::move(fileClient)), m_leaseId(std::move(leaseId)) + { + } + + /** + * @brief Gets a unique lease ID. + * + * @return A unique lease ID. + */ + static std::string CreateUniqueLeaseId(); + + /** + * @brief A value representing infinite lease duration. + */ + AZ_STORAGE_FILES_SHARES_DLLEXPORT static const std::chrono::seconds InfiniteLeaseDuration; + + /** + * @brief Get lease id of this lease client. + * + * @return Lease id of this lease client. + */ + std::string GetLeaseId() const { return m_leaseId; } + + /** + * @brief Acquires a lease on the file or share. + * + * @param proposedLeaseId Proposed lease ID, in a GUID string format. + * @param duration Specifies the duration of the lease, in seconds, or InfiniteLeaseDuration for + * a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease + * duration cannot be changed using renew or change. + * @param options Optional parameters to execute this function. + * @return A AcquireShareLeaseResult describing the lease. + */ + Azure::Core::Response Acquire( + std::chrono::seconds duration, + const AcquireShareLeaseOptions& options = AcquireShareLeaseOptions()); + + /** + * @brief Releases the file or share's previously-acquired lease. + * + * @param leaseId ID of the previously-acquired lease. + * @param options Optional parameters to execute this function. + * @return A ReleaseShareLeaseResult describing the updated container. + */ + Azure::Core::Response Release( + const ReleaseShareLeaseOptions& options = ReleaseShareLeaseOptions()); + + /** + * @brief Changes the lease of an active lease. + * + * @param leaseId ID of the previously-acquired lease. + * @param proposedLeaseId Proposed lease ID, in a GUID string format. + * @param options Optional parameters to execute this function. + * @return A ChangeShareLeaseResult describing the lease. + */ + Azure::Core::Response Change( + const std::string& proposedLeaseId, + const ChangeShareLeaseOptions& options = ChangeShareLeaseOptions()); + + /** + * @brief Breaks the previously-acquired lease. + * + * @param options Optional parameters to execute this function. + * @return A BreakShareLeaseResult describing the broken lease. + */ + Azure::Core::Response Break( + const BreakShareLeaseOptions& options = BreakShareLeaseOptions()); + + private: + /** + * @brief Initializes a new instance of the ShareLeaseClient. + * + * @param shareClient A ShareClient representing the share being leased. + * @param leaseId A lease ID. This is not required for break operation. + */ + explicit ShareLeaseClient(ShareClient shareClient, std::string leaseId) + : m_shareClient(std::move(shareClient)), m_leaseId(std::move(leaseId)) + { + } + + /** + * @brief Renews the file or share's previously-acquired lease. + * + * @param leaseId ID of the previously-acquired lease. + * @param options Optional parameters to execute this function. + * @return A RenewShareLeaseResult describing the lease. + */ + Azure::Core::Response Renew( + const RenewShareLeaseOptions& options = RenewShareLeaseOptions()); + + Azure::Core::Nullable m_fileClient; + Azure::Core::Nullable m_shareClient; + std::string m_leaseId; + }; + +}}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp index a0490fd89..5259ba8b5 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp @@ -768,50 +768,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { int Concurrency = 5; }; - /** - * @brief Optional parameters for FileClient::AcquireLease. - */ - struct AcquireShareFileLeaseOptions - { - /** - * @brief Context for cancelling long running operations. - */ - Azure::Core::Context Context; - }; - - /** - * @brief Optional parameters for FileClient::ChangeLease. - */ - struct ChangeShareFileLeaseOptions - { - /** - * @brief Context for cancelling long running operations. - */ - Azure::Core::Context Context; - }; - - /** - * @brief Optional parameters for FileClient::ReleaseLease. - */ - struct ReleaseShareFileLeaseOptions - { - /** - * @brief Context for cancelling long running operations. - */ - Azure::Core::Context Context; - }; - - /** - * @brief Optional parameters for FileClient::BreakLease. - */ - struct BreakShareFileLeaseOptions - { - /** - * @brief Context for cancelling long running operations. - */ - Azure::Core::Context Context; - }; - /** * @brief Optional parameters for FileClient::UploadFrom. */ diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp index 73445cef7..5f3ed11a5 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp @@ -151,10 +151,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { names using GetShareFileRangeListResult = Details::FileGetRangeListResult; using ListShareFileHandlesSinglePageResult = ListShareDirectoryHandlesSinglePageResult; using ForceCloseAllShareFileHandlesResult = Details::FileForceCloseHandlesResult; - using AcquireShareFileLeaseResult = Details::FileAcquireLeaseResult; - using ReleaseShareFileLeaseResult = Details::FileReleaseLeaseResult; - using BreakShareFileLeaseResult = Details::FileBreakLeaseResult; - using ChangeShareFileLeaseResult = Details::FileChangeLeaseResult; struct DownloadShareFileToResult { diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index 1e022bb80..b9ae71c1f 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -567,47 +567,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); } - Azure::Core::Response ShareFileClient::AcquireLease( - const std::string& proposedLeaseId, - const AcquireShareFileLeaseOptions& options) const - { - Details::ShareRestClient::File::AcquireLeaseOptions protocolLayerOptions; - protocolLayerOptions.ProposedLeaseIdOptional = proposedLeaseId; - protocolLayerOptions.LeaseDuration = -1; - return Details::ShareRestClient::File::AcquireLease( - m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); - } - - Azure::Core::Response ShareFileClient::ChangeLease( - const std::string& leaseId, - const std::string& proposedLeaseId, - const ChangeShareFileLeaseOptions& options) const - { - Details::ShareRestClient::File::ChangeLeaseOptions protocolLayerOptions; - protocolLayerOptions.LeaseIdRequired = leaseId; - protocolLayerOptions.ProposedLeaseIdOptional = proposedLeaseId; - return Details::ShareRestClient::File::ChangeLease( - m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); - } - - Azure::Core::Response ShareFileClient::ReleaseLease( - const std::string& leaseId, - const ReleaseShareFileLeaseOptions& options) const - { - Details::ShareRestClient::File::ReleaseLeaseOptions protocolLayerOptions; - protocolLayerOptions.LeaseIdRequired = leaseId; - return Details::ShareRestClient::File::ReleaseLease( - m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); - } - - Azure::Core::Response ShareFileClient::BreakLease( - const BreakShareFileLeaseOptions& options) const - { - Details::ShareRestClient::File::BreakLeaseOptions protocolLayerOptions; - return Details::ShareRestClient::File::BreakLease( - m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); - } - Azure::Core::Response ShareFileClient::DownloadTo( uint8_t* buffer, std::size_t bufferSize, 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 new file mode 100644 index 000000000..719ab66e4 --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp @@ -0,0 +1,244 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#include "azure/storage/files/shares/share_lease_client.hpp" + +#include + +namespace Azure { namespace Storage { namespace Files { namespace Shares { + + const std::chrono::seconds ShareLeaseClient::InfiniteLeaseDuration{-1}; + + std::string ShareLeaseClient::CreateUniqueLeaseId() + { + return Azure::Core::Uuid::CreateUuid().GetUuidString(); + } + + Azure::Core::Response ShareLeaseClient::Acquire( + std::chrono::seconds duration, + const AcquireShareLeaseOptions& options) + { + if (m_fileClient.HasValue()) + { + Details::ShareRestClient::File::AcquireLeaseOptions protocolLayerOptions; + protocolLayerOptions.ProposedLeaseIdOptional = m_leaseId; + protocolLayerOptions.LeaseDuration = static_cast(duration.count()); + + auto response = Details::ShareRestClient::File::AcquireLease( + m_fileClient.GetValue().m_shareFileUrl, + *(m_fileClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::AcquireShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + ret.LeaseId = std::move(response->LeaseId); + m_leaseId = ret.LeaseId; + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else if (m_shareClient.HasValue()) + { + Details::ShareRestClient::Share::AcquireLeaseOptions protocolLayerOptions; + protocolLayerOptions.ProposedLeaseIdOptional = m_leaseId; + protocolLayerOptions.LeaseDuration = static_cast(duration.count()); + + auto response = Details::ShareRestClient::Share::AcquireLease( + m_shareClient.GetValue().m_shareUrl, + *(m_shareClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::AcquireShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + ret.LeaseId = std::move(response->LeaseId); + m_leaseId = ret.LeaseId; + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else + { + std::abort(); + } + } + + Azure::Core::Response ShareLeaseClient::Renew( + const RenewShareLeaseOptions& options) + { + if (m_fileClient.HasValue()) + { + // Renew only support share level lease. + std::abort(); + } + else if (m_shareClient.HasValue()) + { + Details::ShareRestClient::Share::RenewLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseIdRequired = m_leaseId; + + auto response = Details::ShareRestClient::Share::RenewLease( + m_shareClient.GetValue().m_shareUrl, + *(m_shareClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::RenewShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + ret.LeaseId = std::move(response->LeaseId); + m_leaseId = ret.LeaseId; + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else + { + std::abort(); + } + } + + Azure::Core::Response ShareLeaseClient::Release( + const ReleaseShareLeaseOptions& options) + { + if (m_fileClient.HasValue()) + { + Details::ShareRestClient::File::ReleaseLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseIdRequired = m_leaseId; + + auto response = Details::ShareRestClient::File::ReleaseLease( + m_fileClient.GetValue().m_shareFileUrl, + *(m_fileClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::ReleaseShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else if (m_shareClient.HasValue()) + { + Details::ShareRestClient::Share::ReleaseLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseIdRequired = m_leaseId; + + auto response = Details::ShareRestClient::Share::ReleaseLease( + m_shareClient.GetValue().m_shareUrl, + *(m_shareClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::ReleaseShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else + { + std::abort(); + } + } + + Azure::Core::Response ShareLeaseClient::Change( + const std::string& proposedLeaseId, + const ChangeShareLeaseOptions& options) + { + if (m_fileClient.HasValue()) + { + Details::ShareRestClient::File::ChangeLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseIdRequired = m_leaseId; + protocolLayerOptions.ProposedLeaseIdOptional = proposedLeaseId; + + auto response = Details::ShareRestClient::File::ChangeLease( + m_fileClient.GetValue().m_shareFileUrl, + *(m_fileClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::ChangeShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + ret.LeaseId = std::move(response->LeaseId); + m_leaseId = ret.LeaseId; + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else if (m_shareClient.HasValue()) + { + Details::ShareRestClient::Share::ChangeLeaseOptions protocolLayerOptions; + protocolLayerOptions.LeaseIdRequired = m_leaseId; + protocolLayerOptions.ProposedLeaseIdOptional = proposedLeaseId; + + auto response = Details::ShareRestClient::Share::ChangeLease( + m_shareClient.GetValue().m_shareUrl, + *(m_shareClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::ChangeShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + ret.LeaseId = std::move(response->LeaseId); + m_leaseId = ret.LeaseId; + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else + { + std::abort(); + } + } + + Azure::Core::Response ShareLeaseClient::Break( + const BreakShareLeaseOptions& options) + { + if (m_fileClient.HasValue()) + { + Details::ShareRestClient::File::BreakLeaseOptions protocolLayerOptions; + + auto response = Details::ShareRestClient::File::BreakLease( + m_fileClient.GetValue().m_shareFileUrl, + *(m_fileClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::BreakShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + ret.LeaseTime = 0; // File lease always have immediate breaks. + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else if (m_shareClient.HasValue()) + { + Details::ShareRestClient::Share::BreakLeaseOptions protocolLayerOptions; + + auto response = Details::ShareRestClient::Share::BreakLease( + m_shareClient.GetValue().m_shareUrl, + *(m_shareClient.GetValue().m_pipeline), + options.Context, + protocolLayerOptions); + + Models::BreakShareLeaseResult ret; + ret.ETag = std::move(response->ETag); + ret.LastModified = std::move(response->LastModified); + ret.LeaseTime = response->LeaseTime; + + return Azure::Core::Response( + std::move(ret), response.ExtractRawResponse()); + } + else + { + std::abort(); + } + } +}}}} // namespace Azure::Storage::Files::Shares diff --git a/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp index d0be10267..ba6cace8d 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp @@ -230,109 +230,109 @@ namespace Azure { namespace Storage { namespace Test { // TEST_F(FileShareClientTest, Lease) //{ // std::string leaseId1 = CreateUniqueLeaseId(); - // int32_t leaseDuration = 20; - // auto aLease = *m_shareClient->AcquireLease(leaseId1, leaseDuration); + // std::chrono::seconds leaseDuration(20); + // auto leaseClient = Files::Shares::ShareLeaseClient(*m_shareClient, leaseId1); + + // auto aLease = *leaseClient.Acquire(leaseDuration); // EXPECT_FALSE(aLease.ETag.empty()); - // EXPECT_FALSE(aLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), aLease.LastModified); // EXPECT_EQ(aLease.LeaseId, leaseId1); - // aLease = *m_shareClient->AcquireLease(leaseId1, leaseDuration); + // aLease = *leaseClient.Acquire(leaseDuration); // EXPECT_FALSE(aLease.ETag.empty()); - // EXPECT_FALSE(aLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), aLease.LastModified); // EXPECT_EQ(aLease.LeaseId, leaseId1); // auto properties = *m_shareClient->GetProperties(); - // EXPECT_EQ(properties.LeaseState.GetValue(), Files::Shares::LeaseStateType::Leased); - // EXPECT_EQ(properties.LeaseStatus.GetValue(), Files::Shares::LeaseStatusType::Locked); - // EXPECT_EQ(Files::Shares::LeaseDurationType::Fixed, properties.LeaseDuration.GetValue()); + // EXPECT_EQ(properties.LeaseState.GetValue(), Files::Shares::Models::LeaseStateType::Leased); + // EXPECT_EQ(properties.LeaseStatus.GetValue(), Files::Shares::Models::LeaseStatusType::Locked); + // EXPECT_EQ(Files::Shares::Models::LeaseDurationType::Fixed, + // properties.LeaseDuration.GetValue()); - // auto rLease = *m_shareClient->RenewLease(leaseId1); + // auto rLease = *leaseClient.Renew(); // EXPECT_FALSE(rLease.ETag.empty()); - // EXPECT_FALSE(rLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), rLease.LastModified); // EXPECT_EQ(rLease.LeaseId, leaseId1); // std::string leaseId2 = CreateUniqueLeaseId(); // EXPECT_NE(leaseId1, leaseId2); - // auto cLease = *m_shareClient->ChangeLease(leaseId1, leaseId2); + // auto cLease = *leaseClient.Change(leaseId2); // EXPECT_FALSE(cLease.ETag.empty()); - // EXPECT_FALSE(cLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), cLease.LastModified); // EXPECT_EQ(cLease.LeaseId, leaseId2); - // auto blobInfo = *m_shareClient->ReleaseLease(leaseId2); - // EXPECT_FALSE(blobInfo.ETag.empty()); - // EXPECT_FALSE(blobInfo.LastModified.empty()); + // auto relLease = *leaseClient.Release(); + // EXPECT_FALSE(relLease.ETag.empty()); + // EXPECT_NE(Azure::Core::DateTime(), relLease.LastModified); - // aLease = *m_shareClient->AcquireLease(CreateUniqueLeaseId(), InfiniteLeaseDuration); + // leaseClient = Files::Shares::ShareLeaseClient(*m_shareClient, CreateUniqueLeaseId()); + // aLease = *leaseClient.Acquire(Files::Shares::ShareLeaseClient::InfiniteLeaseDuration); // properties = *m_shareClient->GetProperties(); - // EXPECT_EQ(Files::Shares::LeaseDurationType::Infinite, properties.LeaseDuration.GetValue()); - // auto brokenLease = *m_shareClient->BreakLease(); + // EXPECT_EQ( + // Files::Shares::Models::LeaseDurationType::Infinite, properties.LeaseDuration.GetValue()); + // auto brokenLease = *leaseClient.Break(); // EXPECT_FALSE(brokenLease.ETag.empty()); - // EXPECT_FALSE(brokenLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), brokenLease.LastModified); // EXPECT_EQ(brokenLease.LeaseTime, 0); - // aLease = *m_shareClient->AcquireLease(CreateUniqueLeaseId(), leaseDuration); - // brokenLease = *m_shareClient->BreakLease(); - // EXPECT_FALSE(brokenLease.ETag.empty()); - // EXPECT_FALSE(brokenLease.LastModified.empty()); - // EXPECT_NE(brokenLease.LeaseTime, 0); - // Files::Shares::BreakShareLeaseOptions options; // options.BreakPeriod = 0; - // m_shareClient->BreakLease(options); + // leaseClient.Break(options); //} // TEST_F(FileShareClientTest, SnapshotLease) //{ // std::string leaseId1 = CreateUniqueLeaseId(); - // int32_t leaseDuration = 20; + // std::chrono::seconds leaseDuration(20); // auto snapshotResult = m_shareClient->CreateSnapshot(); // auto shareSnapshot = m_shareClient->WithSnapshot(snapshotResult->Snapshot); - // auto aLease = *shareSnapshot.AcquireLease(leaseId1, leaseDuration); + // auto shareSnapshotLeaseClient = Files::Shares::ShareLeaseClient(shareSnapshot, leaseId1); + // auto aLease = *shareSnapshotLeaseClient.Acquire(leaseDuration); // EXPECT_FALSE(aLease.ETag.empty()); - // EXPECT_FALSE(aLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), aLease.LastModified); // EXPECT_EQ(aLease.LeaseId, leaseId1); - // aLease = *shareSnapshot.AcquireLease(leaseId1, leaseDuration); + // aLease = *shareSnapshotLeaseClient.Acquire(leaseDuration); // EXPECT_FALSE(aLease.ETag.empty()); - // EXPECT_FALSE(aLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), aLease.LastModified); // EXPECT_EQ(aLease.LeaseId, leaseId1); // auto properties = *shareSnapshot.GetProperties(); - // EXPECT_EQ(properties.LeaseState.GetValue(), Files::Shares::LeaseStateType::Leased); - // EXPECT_EQ(properties.LeaseStatus.GetValue(), Files::Shares::LeaseStatusType::Locked); - // EXPECT_EQ(Files::Shares::LeaseDurationType::Fixed, properties.LeaseDuration.GetValue()); + // EXPECT_EQ(properties.LeaseState.GetValue(), Files::Shares::Models::LeaseStateType::Leased); + // EXPECT_EQ(properties.LeaseStatus.GetValue(), Files::Shares::Models::LeaseStatusType::Locked); + // EXPECT_EQ(Files::Shares::Models::LeaseDurationType::Fixed, + // properties.LeaseDuration.GetValue()); - // auto rLease = *shareSnapshot.RenewLease(leaseId1); + // auto rLease = *shareSnapshotLeaseClient.Renew(); // EXPECT_FALSE(rLease.ETag.empty()); - // EXPECT_FALSE(rLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), rLease.LastModified); // EXPECT_EQ(rLease.LeaseId, leaseId1); // std::string leaseId2 = CreateUniqueLeaseId(); // EXPECT_NE(leaseId1, leaseId2); - // auto cLease = *shareSnapshot.ChangeLease(leaseId1, leaseId2); + // auto cLease = *shareSnapshotLeaseClient.Change(leaseId2); // EXPECT_FALSE(cLease.ETag.empty()); - // EXPECT_FALSE(cLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), cLease.LastModified); // EXPECT_EQ(cLease.LeaseId, leaseId2); - // auto blobInfo = *shareSnapshot.ReleaseLease(leaseId2); - // EXPECT_FALSE(blobInfo.ETag.empty()); - // EXPECT_FALSE(blobInfo.LastModified.empty()); + // auto relLease = *shareSnapshotLeaseClient.Release(); + // EXPECT_FALSE(relLease.ETag.empty()); + // EXPECT_NE(Azure::Core::DateTime(), relLease.LastModified); - // aLease = *shareSnapshot.AcquireLease(CreateUniqueLeaseId(), InfiniteLeaseDuration); + // shareSnapshotLeaseClient + // = Files::Shares::ShareLeaseClient(shareSnapshot, CreateUniqueLeaseId()); + // aLease + // = + // *shareSnapshotLeaseClient.Acquire(Files::Shares::ShareLeaseClient::InfiniteLeaseDuration); // properties = *shareSnapshot.GetProperties(); - // EXPECT_EQ(Files::Shares::LeaseDurationType::Infinite, properties.LeaseDuration.GetValue()); - // auto brokenLease = *shareSnapshot.BreakLease(); + // EXPECT_EQ( + // Files::Shares::Models::LeaseDurationType::Infinite, properties.LeaseDuration.GetValue()); + // auto brokenLease = *shareSnapshotLeaseClient.Break(); // EXPECT_FALSE(brokenLease.ETag.empty()); - // EXPECT_FALSE(brokenLease.LastModified.empty()); + // EXPECT_NE(Azure::Core::DateTime(), brokenLease.LastModified); // EXPECT_EQ(brokenLease.LeaseTime, 0); - // aLease = *shareSnapshot.AcquireLease(CreateUniqueLeaseId(), leaseDuration); - // brokenLease = *shareSnapshot.BreakLease(); - // EXPECT_FALSE(brokenLease.ETag.empty()); - // EXPECT_FALSE(brokenLease.LastModified.empty()); - // EXPECT_NE(brokenLease.LeaseTime, 0); - // Files::Shares::BreakShareLeaseOptions options; // options.BreakPeriod = 0; - // shareSnapshot.BreakLease(options); + // shareSnapshotLeaseClient.Break(options); // EXPECT_THROW(m_shareClient->Delete(), StorageException); //} diff --git a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp index 94187d447..1e339d689 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp @@ -250,12 +250,13 @@ namespace Azure { namespace Storage { namespace Test { { std::string leaseId1 = CreateUniqueLeaseId(); auto lastModified = m_fileClient->GetProperties()->LastModified; - auto aLease = *m_fileClient->AcquireLease(leaseId1); + auto leaseClient = Files::Shares::ShareLeaseClient(*m_fileClient, leaseId1); + auto aLease = *leaseClient.Acquire(Files::Shares::ShareLeaseClient::InfiniteLeaseDuration); EXPECT_FALSE(aLease.ETag.empty()); EXPECT_TRUE(aLease.LastModified >= lastModified); EXPECT_EQ(aLease.LeaseId, leaseId1); lastModified = m_fileClient->GetProperties()->LastModified; - aLease = *m_fileClient->AcquireLease(leaseId1); + aLease = *leaseClient.Acquire(Files::Shares::ShareLeaseClient::InfiniteLeaseDuration); EXPECT_FALSE(aLease.ETag.empty()); EXPECT_TRUE(aLease.LastModified >= lastModified); EXPECT_EQ(aLease.LeaseId, leaseId1); @@ -267,28 +268,22 @@ namespace Azure { namespace Storage { namespace Test { std::string leaseId2 = CreateUniqueLeaseId(); EXPECT_NE(leaseId1, leaseId2); lastModified = m_fileClient->GetProperties()->LastModified; - auto cLease = *m_fileClient->ChangeLease(leaseId1, leaseId2); + auto cLease = *leaseClient.Change(leaseId2); EXPECT_FALSE(cLease.ETag.empty()); EXPECT_TRUE(cLease.LastModified >= lastModified); EXPECT_EQ(cLease.LeaseId, leaseId2); lastModified = m_fileClient->GetProperties()->LastModified; - auto fileInfo = *m_fileClient->ReleaseLease(leaseId2); + auto fileInfo = *leaseClient.Release(); EXPECT_FALSE(fileInfo.ETag.empty()); EXPECT_TRUE(fileInfo.LastModified >= lastModified); - aLease = *m_fileClient->AcquireLease(CreateUniqueLeaseId()); + leaseClient = Files::Shares::ShareLeaseClient(*m_fileClient, CreateUniqueLeaseId()); + aLease = *leaseClient.Acquire(Files::Shares::ShareLeaseClient::InfiniteLeaseDuration); lastModified = m_fileClient->GetProperties()->LastModified; - auto brokenLease = *m_fileClient->BreakLease(); + auto brokenLease = *leaseClient.Break(); EXPECT_FALSE(brokenLease.ETag.empty()); EXPECT_TRUE(brokenLease.LastModified >= lastModified); - - aLease = *m_fileClient->AcquireLease(CreateUniqueLeaseId()); - lastModified = m_fileClient->GetProperties()->LastModified; - brokenLease = *m_fileClient->BreakLease(); - EXPECT_FALSE(brokenLease.ETag.empty()); - EXPECT_TRUE(brokenLease.LastModified >= lastModified); - m_fileClient->BreakLease(); } TEST_F(FileShareFileClientTest, ConcurrentUpload)