Skip to content

Commit

Permalink
Storage/STG95 Premium Files Paid Burst (#5795)
Browse files Browse the repository at this point in the history
* paid burst

* update record
  • Loading branch information
microzchang authored Jul 16, 2024
1 parent 8b8b522 commit 6ced010
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/storage",
"Tag": "cpp/storage_8eb3907e27"
"Tag": "cpp/storage_f113099cfb"
}
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,20 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
/**
* Optional. Boolean. Default if not specified is false. This property enables paid bursting.
*/
Nullable<bool> PaidBurstingEnabled;
/**
* Optional. Integer. Default if not specified is the maximum IOPS the file share can support.
* Current maximum for a file share is 102,400 IOPS.
*/
Nullable<int64_t> PaidBurstingMaxIops;
/**
* Optional. Integer. Default if not specified is the maximum throughput the file share can
* support. Current maximum for a file share is 10,340 MiB/sec.
*/
Nullable<int64_t> PaidBurstingMaxBandwidthMibps;
};
/**
* @brief A listed Azure Storage share item.
Expand Down Expand Up @@ -603,6 +617,20 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
/**
* Optional. Boolean. Default if not specified is false. This property enables paid bursting.
*/
Nullable<bool> PaidBurstingEnabled;
/**
* Optional. Integer. Default if not specified is the maximum IOPS the file share can support.
* Current maximum for a file share is 102,400 IOPS.
*/
Nullable<int64_t> PaidBurstingMaxIops;
/**
* Optional. Integer. Default if not specified is the maximum throughput the file share can
* support. Current maximum for a file share is 10,340 MiB/sec.
*/
Nullable<int64_t> PaidBurstingMaxBandwidthMibps;
};
/**
* @brief Specifies the option include to delete the base share and all of its snapshots.
Expand Down Expand Up @@ -2101,6 +2129,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Nullable<Models::ShareProtocols> EnabledProtocols;
Nullable<Models::ShareRootSquash> RootSquash;
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
Nullable<bool> PaidBurstingEnabled;
Nullable<int64_t> PaidBurstingMaxBandwidthMibps;
Nullable<int64_t> PaidBurstingMaxIops;
Nullable<Models::ShareTokenIntent> FileRequestIntent;
};
static Response<Models::CreateShareResult> Create(
Expand Down Expand Up @@ -2226,6 +2257,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Nullable<std::string> LeaseId;
Nullable<Models::ShareRootSquash> RootSquash;
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
Nullable<bool> PaidBurstingEnabled;
Nullable<int64_t> PaidBurstingMaxBandwidthMibps;
Nullable<int64_t> PaidBurstingMaxIops;
Nullable<Models::ShareTokenIntent> FileRequestIntent;
};
static Response<Models::SetSharePropertiesResult> SetProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;

/**
* Optional. Boolean. Version 2023-11-03 and newer. Default if not specified is false. This
* property enables paid bursting.
*/
Nullable<bool> EnablePaidBursting;

/**
* Optional. Integer. Version 2023-11-03 and newer. Default if not specified is the maximum IOPS
* the file share can support. Current maximum for a file share is 102,400 IOPS.
*/
Nullable<int64_t> PaidBurstingMaxIops;

/**
* Optional. Integer. Version 2023-11-03 and newer. Default if not specified is the maximum
* throughput the file share can support. Current maximum for a file share is 10,340 MiB/sec.
*/
Nullable<int64_t> PaidBurstingMaxBandwidthMibps;
};

/**
Expand Down Expand Up @@ -240,6 +258,24 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;

/**
* Optional. Boolean. Version 2023-11-03 and newer. Default if not specified is false. This
* property enables paid bursting.
*/
Nullable<bool> EnablePaidBursting;

/**
* Optional. Integer. Version 2023-11-03 and newer. Default if not specified is the maximum IOPS
* the file share can support. Current maximum for a file share is 102,400 IOPS.
*/
Nullable<int64_t> PaidBurstingMaxIops;

/**
* Optional. Integer. Version 2023-11-03 and newer. Default if not specified is the maximum
* throughput the file share can support. Current maximum for a file share is 10,340 MiB/sec.
*/
Nullable<int64_t> PaidBurstingMaxBandwidthMibps;
};

/**
Expand Down
82 changes: 82 additions & 0 deletions sdk/storage/azure-storage-files-shares/src/rest_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
kEnabledProtocols,
kRootSquash,
kEnableSnapshotVirtualDirectoryAccess,
kPaidBurstingEnabled,
kPaidBurstingMaxIops,
kPaidBurstingMaxBandwidthMibps,
kNextMarker,
};
const std::unordered_map<std::string, XmlTagEnum> XmlTagEnumMap{
Expand Down Expand Up @@ -664,6 +667,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{"RootSquash", XmlTagEnum::kRootSquash},
{"EnableSnapshotVirtualDirectoryAccess",
XmlTagEnum::kEnableSnapshotVirtualDirectoryAccess},
{"PaidBurstingEnabled", XmlTagEnum::kPaidBurstingEnabled},
{"PaidBurstingMaxIops", XmlTagEnum::kPaidBurstingMaxIops},
{"PaidBurstingMaxBandwidthMibps", XmlTagEnum::kPaidBurstingMaxBandwidthMibps},
{"NextMarker", XmlTagEnum::kNextMarker},
};
std::vector<XmlTagEnum> xmlPath;
Expand Down Expand Up @@ -891,6 +897,30 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
vectorElement1.Details.EnableSnapshotVirtualDirectoryAccess
= node.Value == std::string("true");
}
else if (
xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults
&& xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare
&& xmlPath[3] == XmlTagEnum::kProperties
&& xmlPath[4] == XmlTagEnum::kPaidBurstingEnabled)
{
vectorElement1.Details.PaidBurstingEnabled = node.Value == std::string("true");
}
else if (
xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults
&& xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare
&& xmlPath[3] == XmlTagEnum::kProperties
&& xmlPath[4] == XmlTagEnum::kPaidBurstingMaxIops)
{
vectorElement1.Details.PaidBurstingMaxIops = std::stoll(node.Value);
}
else if (
xmlPath.size() == 5 && xmlPath[0] == XmlTagEnum::kEnumerationResults
&& xmlPath[1] == XmlTagEnum::kShares && xmlPath[2] == XmlTagEnum::kShare
&& xmlPath[3] == XmlTagEnum::kProperties
&& xmlPath[4] == XmlTagEnum::kPaidBurstingMaxBandwidthMibps)
{
vectorElement1.Details.PaidBurstingMaxBandwidthMibps = std::stoll(node.Value);
}
else if (
xmlPath.size() == 2 && xmlPath[0] == XmlTagEnum::kEnumerationResults
&& xmlPath[1] == XmlTagEnum::kNextMarker)
Expand Down Expand Up @@ -964,6 +994,24 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
"x-ms-enable-snapshot-virtual-directory-access",
options.EnableSnapshotVirtualDirectoryAccess.Value() ? "true" : "false");
}
if (options.PaidBurstingEnabled.HasValue())
{
request.SetHeader(
"x-ms-share-paid-bursting-enabled",
options.PaidBurstingEnabled.Value() ? "true" : "false");
}
if (options.PaidBurstingMaxBandwidthMibps.HasValue())
{
request.SetHeader(
"x-ms-share-paid-bursting-max-bandwidth-mibps",
std::to_string(options.PaidBurstingMaxBandwidthMibps.Value()));
}
if (options.PaidBurstingMaxIops.HasValue())
{
request.SetHeader(
"x-ms-share-paid-bursting-max-iops",
std::to_string(options.PaidBurstingMaxIops.Value()));
}
if (options.FileRequestIntent.HasValue()
&& !options.FileRequestIntent.Value().ToString().empty())
{
Expand Down Expand Up @@ -1092,6 +1140,22 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
= pRawResponse->GetHeaders().at("x-ms-enable-snapshot-virtual-directory-access")
== std::string("true");
}
if (pRawResponse->GetHeaders().count("x-ms-share-paid-bursting-enabled") != 0)
{
response.PaidBurstingEnabled
= pRawResponse->GetHeaders().at("x-ms-share-paid-bursting-enabled")
== std::string("true");
}
if (pRawResponse->GetHeaders().count("x-ms-share-paid-bursting-max-iops") != 0)
{
response.PaidBurstingMaxIops
= std::stoll(pRawResponse->GetHeaders().at("x-ms-share-paid-bursting-max-iops"));
}
if (pRawResponse->GetHeaders().count("x-ms-share-paid-bursting-max-bandwidth-mibps") != 0)
{
response.PaidBurstingMaxBandwidthMibps = std::stoll(
pRawResponse->GetHeaders().at("x-ms-share-paid-bursting-max-bandwidth-mibps"));
}
return Response<Models::ShareProperties>(std::move(response), std::move(pRawResponse));
}
Response<Models::DeleteShareResult> ShareClient::Delete(
Expand Down Expand Up @@ -1472,6 +1536,24 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
"x-ms-enable-snapshot-virtual-directory-access",
options.EnableSnapshotVirtualDirectoryAccess.Value() ? "true" : "false");
}
if (options.PaidBurstingEnabled.HasValue())
{
request.SetHeader(
"x-ms-share-paid-bursting-enabled",
options.PaidBurstingEnabled.Value() ? "true" : "false");
}
if (options.PaidBurstingMaxBandwidthMibps.HasValue())
{
request.SetHeader(
"x-ms-share-paid-bursting-max-bandwidth-mibps",
std::to_string(options.PaidBurstingMaxBandwidthMibps.Value()));
}
if (options.PaidBurstingMaxIops.HasValue())
{
request.SetHeader(
"x-ms-share-paid-bursting-max-iops",
std::to_string(options.PaidBurstingMaxIops.Value()));
}
if (options.FileRequestIntent.HasValue()
&& !options.FileRequestIntent.Value().ToString().empty())
{
Expand Down
6 changes: 6 additions & 0 deletions sdk/storage/azure-storage-files-shares/src/share_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess
= options.EnableSnapshotVirtualDirectoryAccess;
protocolLayerOptions.FileRequestIntent = m_shareTokenIntent;
protocolLayerOptions.PaidBurstingEnabled = options.EnablePaidBursting;
protocolLayerOptions.PaidBurstingMaxIops = options.PaidBurstingMaxIops;
protocolLayerOptions.PaidBurstingMaxBandwidthMibps = options.PaidBurstingMaxBandwidthMibps;
auto result
= _detail::ShareClient::Create(*m_pipeline, m_shareUrl, protocolLayerOptions, context);
Models::CreateShareResult ret;
Expand Down Expand Up @@ -254,6 +257,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess
= options.EnableSnapshotVirtualDirectoryAccess;
protocolLayerOptions.FileRequestIntent = m_shareTokenIntent;
protocolLayerOptions.PaidBurstingEnabled = options.EnablePaidBursting;
protocolLayerOptions.PaidBurstingMaxIops = options.PaidBurstingMaxIops;
protocolLayerOptions.PaidBurstingMaxBandwidthMibps = options.PaidBurstingMaxBandwidthMibps;
return _detail::ShareClient::SetProperties(
*m_pipeline, m_shareUrl, protocolLayerOptions, context);
}
Expand Down
8 changes: 7 additions & 1 deletion sdk/storage/azure-storage-files-shares/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package-name: azure-storage-files-shares
namespace: Azure::Storage::Files::Shares
output-folder: generated
clear-output-folder: true
input-file: https://raw.github.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.FileStorage/stable/2024-08-04/file.json
input-file: https://raw.github.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.FileStorage/stable/2024-11-04/file.json
```
## ModelFour Options
Expand Down Expand Up @@ -470,6 +470,9 @@ directive:
$["x-ms-enabled-protocols"]["x-ms-enum"] = {"name": "ShareProtocols", "modelAsString": false};
$["x-ms-enabled-protocols"]["x-ms-enum"]["values"] = [{"value": "SMB", "name": "Smb"},{"value": "NFS", "name": "Nfs"}];
$["x-ms-enable-snapshot-virtual-directory-access"]["x-nullable"] = true;
$["x-ms-share-paid-bursting-enabled"]["x-nullable"] = true;
$["x-ms-share-paid-bursting-max-iops"]["x-nullable"] = true;
$["x-ms-share-paid-bursting-max-bandwidth-mibps"]["x-nullable"] = true;
- from: swagger-document
where: $["x-ms-paths"]["/{shareName}?restype=share"].get.responses["200"]
transform: >
Expand Down Expand Up @@ -1069,6 +1072,9 @@ directive:
$.ShareItemDetails.properties["RootSquash"].description = "Root squash to set on the share. Only valid for NFS shares.";
$.ShareItemDetails.properties["Last-Modified"].description = "The date and time the share was last modified.";
$.ShareItemDetails.properties["EnableSnapshotVirtualDirectoryAccess"].description = "Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled. This header is only returned for shares, not for snapshots.";
$.ShareItemDetails.properties["PaidBurstingEnabled"].description = "Optional. Boolean. Default if not specified is false. This property enables paid bursting.";
$.ShareItemDetails.properties["PaidBurstingMaxIops"].description = "Optional. Integer. Default if not specified is the maximum IOPS the file share can support. Current maximum for a file share is 102,400 IOPS.";
$.ShareItemDetails.properties["PaidBurstingMaxBandwidthMibps"].description = "Optional. Integer. Default if not specified is the maximum throughput the file share can support. Current maximum for a file share is 10,340 MiB/sec.";
$.ShareItemInternal.properties["Name"].description = "The name of the share.";
$.ShareItemInternal.properties["Snapshot"].description = "The snapshot of the share.";
$.ShareItemInternal.properties["Deleted"].description = "True if the share is deleted.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,64 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NO_THROW(shareServiceClient.ListShares());
}

TEST_F(FileShareServiceClientTest, PremiumSharePaidBurst_PLAYBACKONLY_)
{
auto shareServiceClient = *m_premiumShareServiceClient;
auto shareName = LowercaseRandomString();
auto shareClient = shareServiceClient.GetShareClient(shareName);

// Create
Files::Shares::CreateShareOptions createOptions;
createOptions.EnablePaidBursting = true;
createOptions.PaidBurstingMaxIops = 1000;
createOptions.PaidBurstingMaxBandwidthMibps = 5000;
shareClient.Create(createOptions);

// Get Properties
auto properties = shareClient.GetProperties().Value;
EXPECT_TRUE(properties.PaidBurstingEnabled.HasValue());
EXPECT_TRUE(properties.PaidBurstingEnabled.Value());
EXPECT_TRUE(properties.PaidBurstingMaxIops.HasValue());
EXPECT_EQ(properties.PaidBurstingMaxIops.Value(), 1000);
EXPECT_TRUE(properties.PaidBurstingMaxBandwidthMibps.HasValue());
EXPECT_EQ(properties.PaidBurstingMaxBandwidthMibps.Value(), 5000);

// Set Properties
Files::Shares::SetSharePropertiesOptions setPropertiesOptions;
setPropertiesOptions.EnablePaidBursting = true;
setPropertiesOptions.PaidBurstingMaxIops = 500;
setPropertiesOptions.PaidBurstingMaxBandwidthMibps = 1000;
shareClient.SetProperties(setPropertiesOptions);

// List Shares
Azure::Nullable<Files::Shares::Models::ShareItem> shareItem;
for (auto page = shareServiceClient.ListShares(); page.HasPage(); page.MoveToNextPage())
{
for (const auto& share : page.Shares)
{
if (share.Name == shareName)
{
shareItem = share;
}
}
}
ASSERT_TRUE(shareItem.HasValue());
EXPECT_TRUE(shareItem.Value().Details.PaidBurstingEnabled.HasValue());
EXPECT_TRUE(shareItem.Value().Details.PaidBurstingEnabled.Value());
EXPECT_TRUE(shareItem.Value().Details.PaidBurstingMaxIops.HasValue());
EXPECT_EQ(shareItem.Value().Details.PaidBurstingMaxIops.Value(), 500);
EXPECT_TRUE(shareItem.Value().Details.PaidBurstingMaxBandwidthMibps.HasValue());
EXPECT_EQ(shareItem.Value().Details.PaidBurstingMaxBandwidthMibps.Value(), 1000);

// Set Properties EnablePaidBursting = false
setPropertiesOptions.EnablePaidBursting = false;
setPropertiesOptions.PaidBurstingMaxIops.Reset();
setPropertiesOptions.PaidBurstingMaxBandwidthMibps.Reset();
shareClient.SetProperties(setPropertiesOptions);
properties = shareClient.GetProperties().Value;
EXPECT_TRUE(properties.PaidBurstingEnabled.HasValue());
EXPECT_FALSE(properties.PaidBurstingEnabled.Value());

shareClient.DeleteIfExists();
}
}}} // namespace Azure::Storage::Test

0 comments on commit 6ced010

Please sign in to comment.