Loading [MathJax]/extensions/tex2jax.js
azure-storage-files-shares
All Classes Functions Variables Pages
share_lease_client.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include "azure/storage/files/shares/share_client.hpp"
7#include "azure/storage/files/shares/share_file_client.hpp"
8
9#include <chrono>
10#include <mutex>
11#include <string>
12
13namespace Azure { namespace Storage { namespace Files { namespace Shares {
14
18 class ShareLeaseClient final {
19 public:
26 explicit ShareLeaseClient(ShareFileClient fileClient, std::string leaseId)
27 : m_fileClient(std::move(fileClient)), m_leaseId(std::move(leaseId))
28 {
29 }
30
37 explicit ShareLeaseClient(ShareClient shareClient, std::string leaseId)
38 : m_shareClient(std::move(shareClient)), m_leaseId(std::move(leaseId))
39 {
40 }
41
47 static std::string CreateUniqueLeaseId();
48
52 AZ_STORAGE_FILES_SHARES_DLLEXPORT static const std::chrono::seconds InfiniteLeaseDuration;
53
59 const std::string& GetLeaseId()
60 {
61 std::lock_guard<std::mutex> guard(m_mutex);
62 return m_leaseId;
63 }
64
75 Azure::Response<Models::AcquireLeaseResult> Acquire(
76 std::chrono::seconds duration,
78 const Azure::Core::Context& context = Azure::Core::Context());
79
87 Azure::Response<Models::RenewLeaseResult> Renew(
88 const RenewLeaseOptions& options = RenewLeaseOptions(),
89 const Azure::Core::Context& context = Azure::Core::Context());
90
98 Azure::Response<Models::ReleaseLeaseResult> Release(
100 const Azure::Core::Context& context = Azure::Core::Context());
101
111 Azure::Response<Models::ChangeLeaseResult> Change(
112 const std::string& proposedLeaseId,
113 const ChangeLeaseOptions& options = ChangeLeaseOptions(),
114 const Azure::Core::Context& context = Azure::Core::Context());
115
123 Azure::Response<Models::BreakLeaseResult> Break(
124 const BreakLeaseOptions& options = BreakLeaseOptions(),
125 const Azure::Core::Context& context = Azure::Core::Context());
126
127 private:
128 Azure::Nullable<ShareFileClient> m_fileClient;
129 Azure::Nullable<ShareClient> m_shareClient;
130 std::mutex m_mutex;
131 std::string m_leaseId;
132 };
133
134}}}} // namespace Azure::Storage::Files::Shares
The ShareClient allows you to manipulate Azure Storage shares and their directories and files.
Definition share_client.hpp:24
The ShareFileClient allows you to manipulate Azure Storage shares and their directories and files.
Definition share_file_client.hpp:24
ShareLeaseClient allows you to manipulate Azure Storage leases on shares and files.
Definition share_lease_client.hpp:18
const std::string & GetLeaseId()
Get lease ID of this lease client.
Definition share_lease_client.hpp:59
Azure::Response< Models::ChangeLeaseResult > Change(const std::string &proposedLeaseId, const ChangeLeaseOptions &options=ChangeLeaseOptions(), const Azure::Core::Context &context=Azure::Core::Context())
Changes the lease of an active lease.
Azure::Response< Models::RenewLeaseResult > Renew(const RenewLeaseOptions &options=RenewLeaseOptions(), const Azure::Core::Context &context=Azure::Core::Context())
Renews the share's previously-acquired lease.
Azure::Response< Models::BreakLeaseResult > Break(const BreakLeaseOptions &options=BreakLeaseOptions(), const Azure::Core::Context &context=Azure::Core::Context())
Breaks the previously-acquired lease.
ShareLeaseClient(ShareFileClient fileClient, std::string leaseId)
Initializes a new instance of the ShareLeaseClient.
Definition share_lease_client.hpp:26
Azure::Response< Models::ReleaseLeaseResult > Release(const ReleaseLeaseOptions &options=ReleaseLeaseOptions(), const Azure::Core::Context &context=Azure::Core::Context())
Releases the file or share's previously-acquired lease.
ShareLeaseClient(ShareClient shareClient, std::string leaseId)
Initializes a new instance of the ShareLeaseClient.
Definition share_lease_client.hpp:37
static std::string CreateUniqueLeaseId()
Gets a unique lease ID.
static AZ_STORAGE_FILES_SHARES_DLLEXPORT const std::chrono::seconds InfiniteLeaseDuration
A value representing infinite lease duration.
Definition share_lease_client.hpp:52
Azure::Response< Models::AcquireLeaseResult > Acquire(std::chrono::seconds duration, const AcquireLeaseOptions &options=AcquireLeaseOptions(), const Azure::Core::Context &context=Azure::Core::Context())
Acquires a lease on the file or share.
Optional parameters for Azure::Storage::Files::Shares::ShareLeaseClient::Acquire.
Definition share_options.hpp:1351
Optional parameters for Azure::Storage::Files::Shares::ShareLeaseClient::Break.
Definition share_options.hpp:1372
Optional parameters for Azure::Storage::Files::Shares::ShareLeaseClient::Change.
Definition share_options.hpp:1358
Optional parameters for Azure::Storage::Files::Shares::ShareLeaseClient::Release.
Definition share_options.hpp:1365
Optional parameters for Azure::Storage::Files::Shares::ShareLeaseClient::Renew.
Definition share_options.hpp:1387