case-insensitive metadata (#1050)

* case-insensitive metadata

* Added support for case insensitive metadata for file/datalake service

Co-authored-by: Tank Tang <kat@microsoft.com>
This commit is contained in:
JinmingHu 2020-12-03 09:49:33 +08:00 committed by GitHub
parent 8d1450b855
commit 46ce66d150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 178 additions and 246 deletions

View File

@ -170,7 +170,7 @@ namespace Azure { namespace Storage { namespace Blobs {
* @return A SetBlobMetadataResult describing the updated blob.
*/
Azure::Core::Response<Models::SetBlobMetadataResult> SetMetadata(
std::map<std::string, std::string> metadata,
Metadata metadata,
const SetBlobMetadataOptions& options = SetBlobMetadataOptions()) const;
/**

View File

@ -181,7 +181,7 @@ namespace Azure { namespace Storage { namespace Blobs {
* @return A SetBlobContainerMetadataResult if successful.
*/
Azure::Core::Response<Models::SetBlobContainerMetadataResult> SetMetadata(
std::map<std::string, std::string> metadata,
Metadata metadata,
SetBlobContainerMetadataOptions options = SetBlobContainerMetadataOptions()) const;
/**

View File

@ -289,7 +289,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Name-value pairs to associate with the container as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief The encryption scope to use as the default on the container.
@ -615,7 +615,7 @@ namespace Azure { namespace Storage { namespace Blobs {
* blob is created with the specified metadata, and metadata is not copied from the source blob
* or file.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Optional conditions that must be met to perform this operation.
@ -743,7 +743,7 @@ namespace Azure { namespace Storage { namespace Blobs {
* snapshot. If one or more name-value pairs are specified, the snapshot is created with the
* specified metadata, and metadata is not copied from the base blob.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Optional conditions that must be met to perform this operation.
@ -938,7 +938,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Name-value pairs associated with the blob as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Indicates the tier to be set on blob.
@ -969,7 +969,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Name-value pairs associated with the blob as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Indicates the tier to be set on blob.
@ -1083,7 +1083,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Name-value pairs associated with the blob as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Indicates the tier to be set on blob.
@ -1138,7 +1138,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Name-value pairs associated with the blob as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Optional conditions that must be met to perform this operation.
@ -1257,7 +1257,7 @@ namespace Azure { namespace Storage { namespace Blobs {
/**
* @brief Name-value pairs associated with the blob as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Indicates the tier to be set on blob.

View File

@ -20,7 +20,7 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Models {
std::string LastModified;
int64_t ContentLength = 0;
BlobHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Models::BlobType BlobType = Models::BlobType::Unknown;
Azure::Core::Nullable<bool> ServerEncrypted;
Azure::Core::Nullable<std::string> EncryptionKeySha256;

View File

@ -642,7 +642,7 @@ namespace Azure { namespace Storage { namespace Blobs {
std::string Name;
std::string ETag;
std::string LastModified;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
PublicAccessType AccessType = PublicAccessType::Private;
bool HasImmutabilityPolicy = false;
bool HasLegalHold = false;
@ -697,7 +697,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
std::string ETag;
std::string LastModified;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
PublicAccessType AccessType = PublicAccessType::Private;
bool HasImmutabilityPolicy = false;
bool HasLegalHold = false;
@ -792,7 +792,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> VersionId;
Azure::Core::Nullable<bool> IsCurrentVersion;
BlobHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
std::string CreationTime;
Azure::Core::Nullable<std::string> ExpiryTime;
Azure::Core::Nullable<std::string> LastAccessTime;
@ -824,7 +824,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> LastAccessTime;
Azure::Core::Nullable<std::string> ContentRange;
BlobHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<int64_t> SequenceNumber; // only for page blob
Azure::Core::Nullable<int64_t> CommittedBlockCount; // only for append blob
Azure::Core::Nullable<bool> IsSealed; // only for append blob
@ -851,7 +851,7 @@ namespace Azure { namespace Storage { namespace Blobs {
std::string CreationTime;
Azure::Core::Nullable<std::string> ExpiryTime;
Azure::Core::Nullable<std::string> LastAccessTime;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Blobs::Models::BlobType BlobType = Blobs::Models::BlobType::Unknown;
Azure::Core::Nullable<std::string> LeaseDuration;
Azure::Core::Nullable<BlobLeaseState> LeaseState;
@ -3273,10 +3273,9 @@ namespace Azure { namespace Storage { namespace Blobs {
return ret;
}
static std::map<std::string, std::string> MetadataFromXml(
Storage::Details::XmlReader& reader)
static Metadata MetadataFromXml(Storage::Details::XmlReader& reader)
{
std::map<std::string, std::string> ret;
Metadata ret;
int depth = 0;
std::string key;
while (true)
@ -3542,7 +3541,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
Azure::Core::Nullable<int32_t> Timeout;
Azure::Core::Nullable<PublicAccessType> AccessType;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> DefaultEncryptionScope;
Azure::Core::Nullable<bool> PreventEncryptionScopeOverride;
}; // struct CreateBlobContainerOptions
@ -3563,16 +3562,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.GetUrl().AppendQueryParameter(
"timeout", std::to_string(options.Timeout.GetValue()));
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.AccessType.HasValue())
{
request.AddHeader(
@ -3767,7 +3760,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct SetBlobContainerMetadataOptions
{
Azure::Core::Nullable<int32_t> Timeout;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> IfModifiedSince;
}; // struct SetBlobContainerMetadataOptions
@ -3789,16 +3782,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.GetUrl().AppendQueryParameter(
"timeout", std::to_string(options.Timeout.GetValue()));
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
@ -5136,41 +5123,6 @@ namespace Azure { namespace Storage { namespace Blobs {
return ret;
}
static std::map<std::string, std::string> MetadataFromXml(
Storage::Details::XmlReader& reader)
{
std::map<std::string, std::string> ret;
int depth = 0;
std::string key;
while (true)
{
auto node = reader.Read();
if (node.Type == Storage::Details::XmlNodeType::End)
{
break;
}
else if (node.Type == Storage::Details::XmlNodeType::StartTag)
{
if (depth++ == 0)
{
key = node.Name;
}
}
else if (node.Type == Storage::Details::XmlNodeType::EndTag)
{
if (depth-- == 0)
{
break;
}
}
else if (depth == 1 && node.Type == Storage::Details::XmlNodeType::Text)
{
ret.emplace(std::move(key), std::string(node.Value));
}
}
return ret;
}
static std::vector<ObjectReplicationPolicy> ObjectReplicationSourcePropertiesFromXml(
Storage::Details::XmlReader& reader)
{
@ -5223,6 +5175,40 @@ namespace Azure { namespace Storage { namespace Blobs {
return ret;
}
static Metadata MetadataFromXml(Storage::Details::XmlReader& reader)
{
Metadata ret;
int depth = 0;
std::string key;
while (true)
{
auto node = reader.Read();
if (node.Type == Storage::Details::XmlNodeType::End)
{
break;
}
else if (node.Type == Storage::Details::XmlNodeType::StartTag)
{
if (depth++ == 0)
{
key = node.Name;
}
}
else if (node.Type == Storage::Details::XmlNodeType::EndTag)
{
if (depth-- == 0)
{
break;
}
}
else if (depth == 1 && node.Type == Storage::Details::XmlNodeType::Text)
{
ret.emplace(std::move(key), std::string(node.Value));
}
}
return ret;
}
static void SetBlobContainerAccessPolicyOptionsToXml(
Storage::Details::XmlWriter& writer,
const SetBlobContainerAccessPolicyOptions& options)
@ -6107,7 +6093,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct SetBlobMetadataOptions
{
Azure::Core::Nullable<int32_t> Timeout;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySha256;
Azure::Core::Nullable<EncryptionAlgorithmType> EncryptionAlgorithm;
@ -6136,16 +6122,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.GetUrl().AppendQueryParameter(
"timeout", std::to_string(options.Timeout.GetValue()));
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.EncryptionKey.HasValue())
{
request.AddHeader("x-ms-encryption-key", options.EncryptionKey.GetValue());
@ -6272,7 +6252,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct StartCopyBlobFromUriOptions
{
Azure::Core::Nullable<int32_t> Timeout;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
std::string SourceUri;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> SourceLeaseId;
@ -6306,16 +6286,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.GetUrl().AppendQueryParameter(
"timeout", std::to_string(options.Timeout.GetValue()));
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
request.AddHeader("x-ms-copy-source", options.SourceUri);
if (options.LeaseId.HasValue())
{
@ -6453,7 +6427,7 @@ namespace Azure { namespace Storage { namespace Blobs {
struct CreateBlobSnapshotOptions
{
Azure::Core::Nullable<int32_t> Timeout;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySha256;
@ -6500,16 +6474,10 @@ namespace Azure { namespace Storage { namespace Blobs {
{
request.AddHeader("x-ms-encryption-scope", options.EncryptionScope.GetValue());
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
@ -7159,7 +7127,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<std::string> TransactionalContentMd5;
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
BlobHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<AccessTier> Tier;
Azure::Core::Nullable<std::string> EncryptionKey;
@ -7241,16 +7209,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.AddHeader(
"x-ms-blob-content-disposition", options.HttpHeaders.ContentDisposition);
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
@ -7593,7 +7555,7 @@ namespace Azure { namespace Storage { namespace Blobs {
Azure::Core::Nullable<int32_t> Timeout;
std::vector<std::pair<BlockType, std::string>> BlockList;
BlobHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySha256;
@ -7658,16 +7620,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.AddHeader(
"x-ms-blob-content-disposition", options.HttpHeaders.ContentDisposition);
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
@ -7974,7 +7930,7 @@ namespace Azure { namespace Storage { namespace Blobs {
int64_t BlobContentLength = -1;
Azure::Core::Nullable<int64_t> SequenceNumber;
BlobHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<AccessTier> Tier;
Azure::Core::Nullable<std::string> EncryptionKey;
@ -8028,16 +7984,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.AddHeader(
"x-ms-blob-content-disposition", options.HttpHeaders.ContentDisposition);
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());
@ -9065,7 +9015,7 @@ namespace Azure { namespace Storage { namespace Blobs {
{
Azure::Core::Nullable<int32_t> Timeout;
BlobHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> LeaseId;
Azure::Core::Nullable<std::string> EncryptionKey;
Azure::Core::Nullable<std::string> EncryptionKeySha256;
@ -9118,16 +9068,10 @@ namespace Azure { namespace Storage { namespace Blobs {
request.AddHeader(
"x-ms-blob-content-disposition", options.HttpHeaders.ContentDisposition);
}
std::set<std::string> metadataKeys;
for (const auto& pair : options.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader("x-ms-meta-" + pair.first, pair.second);
}
metadataKeys.clear();
if (options.LeaseId.HasValue())
{
request.AddHeader("x-ms-lease-id", options.LeaseId.GetValue());

View File

@ -31,7 +31,7 @@ void BlobsGettingStarted()
blobClient.UploadFrom(reinterpret_cast<const uint8_t*>(blobContent.data()), blobContent.size());
std::map<std::string, std::string> blobMetadata = {{"key1", "value1"}, {"key2", "value2"}};
Azure::Storage::Metadata blobMetadata = {{"key1", "value1"}, {"key2", "value2"}};
blobClient.SetMetadata(blobMetadata);
auto properties = *blobClient.GetProperties();

View File

@ -523,7 +523,7 @@ namespace Azure { namespace Storage { namespace Blobs {
}
Azure::Core::Response<Models::SetBlobMetadataResult> BlobClient::SetMetadata(
std::map<std::string, std::string> metadata,
Metadata metadata,
const SetBlobMetadataOptions& options) const
{
Details::BlobRestClient::Blob::SetBlobMetadataOptions protocolLayerOptions;

View File

@ -184,7 +184,7 @@ namespace Azure { namespace Storage { namespace Blobs {
}
Azure::Core::Response<Models::SetBlobContainerMetadataResult> BlobContainerClient::SetMetadata(
std::map<std::string, std::string> metadata,
Metadata metadata,
SetBlobContainerMetadataOptions options) const
{
Details::BlobRestClient::BlobContainer::SetBlobContainerMetadataOptions protocolLayerOptions;

View File

@ -54,7 +54,7 @@ namespace Azure { namespace Storage { namespace Test {
auto container_client = Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString(
StandardStorageConnectionString(), LowercaseRandomString());
Azure::Storage::Blobs::CreateBlobContainerOptions options;
std::map<std::string, std::string> metadata;
Azure::Storage::Metadata metadata;
metadata["key1"] = "one";
metadata["key2"] = "TWO";
options.Metadata = metadata;
@ -74,7 +74,7 @@ namespace Azure { namespace Storage { namespace Test {
TEST_F(BlobContainerClientTest, Metadata)
{
std::map<std::string, std::string> metadata;
Azure::Storage::Metadata metadata;
metadata["key1"] = "one";
metadata["key2"] = "TWO";
auto res = m_blobContainerClient->SetMetadata(metadata);

View File

@ -69,6 +69,7 @@ target_sources(
PRIVATE
test/bearer_token_test.cpp
test/crypt_functions_test.cpp
test/metadata_test.cpp
test/storage_credential_test.cpp
test/test_base.cpp
test/test_base.hpp

View File

@ -3,9 +3,13 @@
#pragma once
#include <algorithm>
#include <cstdint>
#include <map>
#include <string>
#include "azure/core/strings.hpp"
namespace Azure { namespace Storage {
template <class... T> void unused(T&&...) {}
@ -16,4 +20,18 @@ namespace Azure { namespace Storage {
std::string CreateUniqueLeaseId();
namespace Details {
struct CaseInsensitiveComparator
{
bool operator()(const std::string& lhs, const std::string& rhs) const
{
return std::lexicographical_compare(
lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), [](char c1, char c2) {
return Core::Strings::ToLower(c1) < Core::Strings::ToLower(c2);
});
}
};
} // namespace Details
using Metadata = std::map<std::string, std::string, Details::CaseInsensitiveComparator>;
}} // namespace Azure::Storage

View File

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/storage/common/storage_common.hpp"
#include "test_base.hpp"
namespace Azure { namespace Storage { namespace Test {
TEST(MetadataTest, CaseInsensitive)
{
const std::string value1 = "vAlUe1";
const std::string value2 = "vaLue2";
Metadata metadata;
metadata["KEY"] = value1;
EXPECT_EQ(metadata["KEY"], value1);
EXPECT_EQ(metadata["key"], value1);
metadata["key"] = value2;
EXPECT_EQ(metadata["KEY"], value2);
EXPECT_EQ(metadata["key"], value2);
EXPECT_EQ(metadata["KeY"], value2);
EXPECT_EQ(metadata["kEy"], value2);
}
}}} // namespace Azure::Storage::Test

View File

@ -167,9 +167,9 @@ namespace Azure { namespace Storage { namespace Test {
return Azure::Core::Strings::ToLower(RandomString(size));
}
std::map<std::string, std::string> RandomMetadata(size_t size)
Storage::Metadata RandomMetadata(size_t size)
{
std::map<std::string, std::string> result;
Storage::Metadata result;
for (size_t i = 0; i < size; ++i)
{
// TODO: Use mixed casing after Azure::Core lower cases the headers.

View File

@ -5,6 +5,7 @@
#include "azure/core/http/body_stream.hpp"
#include "azure/storage/common/constants.hpp"
#include "azure/storage/common/storage_common.hpp"
#include <gtest/gtest.h>
@ -51,7 +52,7 @@ namespace Azure { namespace Storage { namespace Test {
std::string LowercaseRandomString(size_t size = 10);
std::map<std::string, std::string> RandomMetadata(size_t size = 5);
Storage::Metadata RandomMetadata(size_t size = 5);
void RandomBuffer(char* buffer, std::size_t length);
std::vector<uint8_t> RandomBuffer(std::size_t length);

View File

@ -134,7 +134,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
* @remark This request is sent to blob endpoint.
*/
Azure::Core::Response<Models::SetFileSystemMetadataResult> SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetFileSystemMetadataOptions& options = SetFileSystemMetadataOptions()) const;
/**

View File

@ -111,7 +111,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
* Note that the string may only contain ASCII characters in the
* ISO-8859-1 character set.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
};
/**
@ -375,7 +375,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
* existing metadata and the current E-Tag, then make a conditional request with the
* E-Tag and include values for all metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Only valid if Hierarchical Namespace is enabled for the account. When creating
@ -692,7 +692,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
/**
* @brief Name-value pairs associated with the blob as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief The maximum number of bytes in a single request.

View File

@ -167,7 +167,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
* @remark This request is sent to blob endpoint.
*/
Azure::Core::Response<Models::SetPathMetadataResult> SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetPathMetadataOptions& options = SetPathMetadataOptions()) const;
/**

View File

@ -23,7 +23,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
{
std::string ETag;
std::string LastModified;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
};
using CreateFileSystemResult = FileSystemCreateResult;
@ -80,7 +80,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
std::string LastModified;
std::string CreationTime;
int64_t ContentLength;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<std::string> LeaseDuration;
Azure::Core::Nullable<LeaseStateType> LeaseState;
Azure::Core::Nullable<LeaseStatusType> LeaseStatus;
@ -146,7 +146,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
LeaseStateType LeaseState = LeaseStateType::Unknown;
LeaseStatusType LeaseStatus = LeaseStatusType::Unknown;
Azure::Core::Nullable<std::string> ContentMd5;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
std::string CreationTime;
Azure::Core::Nullable<std::string> ExpiryTime;
Azure::Core::Nullable<std::string> LastAccessTime;
@ -166,7 +166,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
std::string LastModified;
int64_t ContentLength = 0;
DataLakeHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<bool> ServerEncrypted;
Azure::Core::Nullable<std::string> EncryptionKeySha256;
};

View File

@ -3,14 +3,17 @@
#pragma once
#include "azure/storage/common/storage_common.hpp"
#include <map>
#include <string>
namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace Details {
namespace Azure { namespace Storage{ namespace Files { namespace DataLake { namespace Details {
std::string GetBlobUriFromUri(const std::string& uri);
std::string GetDfsUriFromUri(const std::string& uri);
std::string SerializeMetadata(const std::map<std::string, std::string>& dataLakePropertiesMap);
std::string SerializeMetadata(const Storage::Metadata& dataLakePropertiesMap);
std::string GetSubstringTillDelimiter(
char delimiter,

View File

@ -228,14 +228,14 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
}
Azure::Core::Response<Models::SetFileSystemMetadataResult> FileSystemClient::SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetFileSystemMetadataOptions& options) const
{
Blobs::SetBlobContainerMetadataOptions blobOptions;
blobOptions.Context = options.Context;
blobOptions.AccessConditions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
blobOptions.AccessConditions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
auto result = m_blobContainerClient.SetMetadata(metadata, blobOptions);
auto result = m_blobContainerClient.SetMetadata(std::move(metadata), blobOptions);
Models::SetFileSystemMetadataResult ret;
ret.ETag = std::move(result->ETag);
ret.LastModified = std::move(result->LastModified);

View File

@ -355,7 +355,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
}
Azure::Core::Response<Models::SetPathMetadataResult> PathClient::SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetPathMetadataOptions& options) const
{
Blobs::SetBlobMetadataOptions blobOptions;
@ -365,7 +365,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
blobOptions.AccessConditions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
blobOptions.AccessConditions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
blobOptions.AccessConditions.LeaseId = options.AccessConditions.LeaseId;
auto result = m_blobClient.SetMetadata(metadata, blobOptions);
auto result = m_blobClient.SetMetadata(std::move(metadata), blobOptions);
Models::SetPathMetadataResult ret;
ret.ETag = std::move(result->ETag);
ret.LastModified = std::move(result->LastModified);

View File

@ -33,7 +33,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam
return result;
}
std::string SerializeMetadata(const std::map<std::string, std::string>& dataLakePropertiesMap)
std::string SerializeMetadata(const Storage::Metadata& dataLakePropertiesMap)
{
std::string result;
for (const auto& pair : dataLakePropertiesMap)

View File

@ -14,11 +14,11 @@
#include "azure/storage/common/storage_exception.hpp"
#include "azure/storage/common/xml_wrapper.hpp"
#include <nlohmann/json.hpp>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <nlohmann/json.hpp>
#include <stdexcept>
#include <string>
#include <vector>
@ -291,13 +291,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Azure::Core::Nullable<std::string> NextAllowedQuotaDowngradeTime;
std::string DeletedTime;
int32_t RemainingRetentionDays = int32_t();
Models::LeaseStatusType LeaseStatus;
Models::LeaseStateType LeaseState;
Models::LeaseDurationType LeaseDuration;
Models::LeaseStatusType LeaseStatus = Models::LeaseStatusType::Unknown;
Models::LeaseStateType LeaseState = Models::LeaseStateType::Unknown;
Models::LeaseDurationType LeaseDuration = Models::LeaseDurationType::Unknown;
};
typedef std::map<std::string, std::string> Metadata;
// A listed Azure Storage share item.
struct ShareItem
{
@ -306,7 +304,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
bool Deleted = bool();
std::string Version;
Models::ShareProperties Properties;
Models::Metadata ShareMetadata;
Storage::Metadata ShareMetadata;
};
// An enumeration of shares.
@ -477,7 +475,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
struct ShareGetPropertiesResult
{
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
std::string ETag;
std::string LastModified;
int64_t Quota = int64_t();
@ -604,7 +602,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
struct DirectoryGetPropertiesResult
{
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
std::string ETag;
std::string LastModified;
bool IsServerEncrypted = bool();
@ -687,7 +685,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
std::unique_ptr<Azure::Core::Http::BodyStream> BodyStream;
std::string LastModified;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
int64_t ContentLength = int64_t();
FileShareHttpHeaders HttpHeaders;
Azure::Core::Nullable<std::string> ContentRange;
@ -716,7 +714,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
struct FileGetPropertiesResult
{
std::string LastModified;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
std::string FileType;
int64_t ContentLength = int64_t();
FileShareHttpHeaders HttpHeaders;
@ -2366,10 +2364,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
return result;
}
static std::map<std::string, std::string> MetadataFromXml(
Storage::Details::XmlReader& reader)
static Metadata MetadataFromXml(Storage::Details::XmlReader& reader)
{
std::map<std::string, std::string> result;
Metadata result;
int depth = 0;
std::string key;
while (true)
@ -2639,8 +2636,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
// For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
// Timeouts for File Service Operations.</a>
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
Azure::Core::Nullable<int64_t>
ShareQuota; // Specifies the maximum size of the share, in gigabytes.
std::string ApiVersionParameter
@ -2664,16 +2660,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::UrlEncodeQueryParameter(
std::to_string(createOptions.Timeout.GetValue())));
}
std::set<std::string> metadataKeys;
for (const auto& pair : createOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
if (createOptions.ShareQuota.HasValue())
{
request.AddHeader(
@ -3120,8 +3110,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
// For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
// Timeouts for File Service Operations.</a>
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
std::string ApiVersionParameter
= Details::DefaultServiceApiVersion; // Specifies the version of the operation to use
// for this request.
@ -3144,16 +3133,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::UrlEncodeQueryParameter(
std::to_string(createSnapshotOptions.Timeout.GetValue())));
}
std::set<std::string> metadataKeys;
for (const auto& pair : createSnapshotOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
request.AddHeader(Details::HeaderVersion, createSnapshotOptions.ApiVersionParameter);
return CreateSnapshotParseResult(context, pipeline.Send(context, request));
}
@ -3292,8 +3275,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
// For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
// Timeouts for File Service Operations.</a>
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
std::string ApiVersionParameter
= Details::DefaultServiceApiVersion; // Specifies the version of the operation to use
// for this request.
@ -3319,16 +3301,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::UrlEncodeQueryParameter(
std::to_string(setMetadataOptions.Timeout.GetValue())));
}
std::set<std::string> metadataKeys;
for (const auto& pair : setMetadataOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
request.AddHeader(Details::HeaderVersion, setMetadataOptions.ApiVersionParameter);
if (setMetadataOptions.LeaseIdOptional.HasValue())
{
@ -4317,8 +4293,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
// For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
// Timeouts for File Service Operations.</a>
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
std::string ApiVersionParameter
= Details::DefaultServiceApiVersion; // Specifies the version of the operation to use
// for this request.
@ -4357,16 +4332,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::UrlEncodeQueryParameter(
std::to_string(createOptions.Timeout.GetValue())));
}
std::set<std::string> metadataKeys;
for (const auto& pair : createOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
request.AddHeader(Details::HeaderVersion, createOptions.ApiVersionParameter);
if (createOptions.FilePermission.HasValue())
{
@ -4528,8 +4497,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
// For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
// Timeouts for File Service Operations.</a>
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
std::string ApiVersionParameter
= Details::DefaultServiceApiVersion; // Specifies the version of the operation to use
// for this request.
@ -4552,16 +4520,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::UrlEncodeQueryParameter(
std::to_string(setMetadataOptions.Timeout.GetValue())));
}
std::set<std::string> metadataKeys;
for (const auto& pair : setMetadataOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
request.AddHeader(Details::HeaderVersion, setMetadataOptions.ApiVersionParameter);
return SetMetadataParseResult(context, pipeline.Send(context, request));
}
@ -5593,7 +5555,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
std::string ApiVersionParameter
= Details::DefaultServiceApiVersion; // Specifies the version of the operation to use
// for this request.
int64_t XMsContentLength; // Specifies the maximum size for the file, up to 4 TB.
int64_t XMsContentLength
= int64_t(); // Specifies the maximum size for the file, up to 4 TB.
Azure::Core::Nullable<std::string>
FileContentType; // Sets the MIME content type of the file. The default type is
// 'application/octet-stream'.
@ -5608,8 +5571,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Azure::Core::Nullable<std::string> FileContentMd5; // Sets the file's MD5 hash.
Azure::Core::Nullable<std::string>
FileContentDisposition; // Sets the file's Content-Disposition header.
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
Azure::Core::Nullable<std::string>
FilePermission; // If specified the permission (security descriptor) shall be set for
// the directory/file. This header can be used if Permission size is
@ -5681,16 +5643,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Details::HeaderFileContentDisposition,
createOptions.FileContentDisposition.GetValue());
}
std::set<std::string> metadataKeys;
for (const auto& pair : createOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
if (createOptions.FilePermission.HasValue())
{
request.AddHeader(
@ -5986,8 +5942,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
// For more information, see <a
// href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
// Timeouts for File Service Operations.</a>
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
std::string ApiVersionParameter
= Details::DefaultServiceApiVersion; // Specifies the version of the operation to use
// for this request.
@ -6012,16 +5967,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::UrlEncodeQueryParameter(
std::to_string(setMetadataOptions.Timeout.GetValue())));
}
std::set<std::string> metadataKeys;
for (const auto& pair : setMetadataOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
request.AddHeader(Details::HeaderVersion, setMetadataOptions.ApiVersionParameter);
if (setMetadataOptions.LeaseIdOptional.HasValue())
{
@ -6255,14 +6204,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
// the file's full size. The File service accepts only a single byte range
// for the Range and 'x-ms-range' headers, and the byte range must be
// specified in the following format: bytes=startByte-endByte.
Models::FileRangeWriteType
XMsWrite; // Specify one of the following options: - Update: Writes the bytes
// specified by the request body into the specified range. The Range and
// Content-Length headers must match to perform the update. - Clear: Clears
// the specified range and releases the space used in storage for that
// range. To clear a range, set the Content-Length header to zero, and set
// the Range header to a value that indicates the range to clear, up to
// maximum file size.
Models::FileRangeWriteType XMsWrite = Models::FileRangeWriteType::
Unknown; // Specify one of the following options: - Update: Writes the bytes specified
// by the request body into the specified range. The Range and Content-Length
// headers must match to perform the update. - Clear: Clears the specified
// range and releases the space used in storage for that range. To clear a
// range, set the Content-Length header to zero, and set the Range header to
// a value that indicates the range to clear, up to maximum file size.
int64_t ContentLength
= int64_t(); // Specifies the number of bytes being transmitted in the request body.
// When the x-ms-write header is set to clear, the value of this header
@ -6288,8 +6236,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Azure::Core::Context context,
const UploadRangeOptions& uploadRangeOptions)
{
Azure::Core::Http::Request request(
Azure::Core::Http::HttpMethod::Put, std::move(url), &bodyStream);
Azure::Core::Http::Request request(Azure::Core::Http::HttpMethod::Put, url, &bodyStream);
request.GetUrl().AppendQueryParameter(Details::QueryComp, "range");
if (uploadRangeOptions.Timeout.HasValue())
{
@ -6492,8 +6439,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
std::string ApiVersionParameter
= Details::DefaultServiceApiVersion; // Specifies the version of the operation to use
// for this request.
std::map<std::string, std::string>
Metadata; // A name-value pair to associate with a file storage object.
Storage::Metadata Metadata; // A name-value pair to associate with a file storage object.
std::string
CopySource; // Specifies the URL of the source file or blob, up to 2 KB in length. To
// copy a file to another file within the same storage account, you may
@ -6563,16 +6509,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
std::to_string(startCopyOptions.Timeout.GetValue())));
}
request.AddHeader(Details::HeaderVersion, startCopyOptions.ApiVersionParameter);
std::set<std::string> metadataKeys;
for (const auto& pair : startCopyOptions.Metadata)
{
if (metadataKeys.insert(Azure::Core::Strings::ToLower(pair.first)).second == false)
{
throw std::runtime_error("duplicate keys in metadata");
}
request.AddHeader(Details::HeaderMetadata + ("-" + pair.first), pair.second);
}
metadataKeys.clear();
request.AddHeader(Details::HeaderCopySource, startCopyOptions.CopySource);
if (startCopyOptions.FilePermission.HasValue())
{

View File

@ -148,7 +148,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* including the version and modified time of a share.
*/
Azure::Core::Response<Models::SetShareMetadataResult> SetMetadata(
std::map<std::string, std::string> metadata,
Storage::Metadata metadata,
const SetShareMetadataOptions& options = SetShareMetadataOptions()) const;
/**

View File

@ -137,7 +137,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* of the directory returned from the server.
*/
Azure::Core::Response<Models::SetDirectoryMetadataResult> SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetDirectoryMetadataOptions& options = SetDirectoryMetadataOptions()) const;
/**

View File

@ -220,7 +220,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* the file returned from the server.
*/
Azure::Core::Response<Models::SetFileMetadataResult> SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetFileMetadataOptions& options = SetFileMetadataOptions()) const;
/**

View File

@ -105,7 +105,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
/**
* @brief A name-value pair to associate with a file storage object.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief Specifies the maximum size of the share, in gigabytes.
@ -136,7 +136,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
/**
* @brief The metadata to be set on the snapshot of the share.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
};
struct GetSharePropertiesOptions
@ -277,7 +277,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
/**
* @brief A name-value pair to associate with a directory object.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief This permission is the security descriptor for the directory specified in the Security
@ -445,7 +445,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
/**
* @brief A name-value pair to associate with a file storage object.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief The operation will only succeed if the access condition is met.
@ -507,7 +507,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
/**
* @brief A name-value pair to associate with a file storage object.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief This permission is the security descriptor for the file specified in the Security
@ -858,7 +858,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
/**
* @brief Name-value pairs associated with the file as metadata.
*/
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
/**
* @brief The maximum number of bytes in a single request.

View File

@ -117,7 +117,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { names
std::string LastModified;
int64_t ContentLength = 0;
FileShareHttpHeaders HttpHeaders;
std::map<std::string, std::string> Metadata;
Storage::Metadata Metadata;
Azure::Core::Nullable<bool> IsServerEncrypted;
};

View File

@ -30,7 +30,7 @@ void FileShareGettingStarted()
fileClient.UploadFrom(reinterpret_cast<const uint8_t*>(fileContent.data()), fileContent.size());
std::map<std::string, std::string> fileMetadata = {{"key1", "value1"}, {"key2", "value2"}};
Azure::Storage::Metadata fileMetadata = {{"key1", "value1"}, {"key2", "value2"}};
fileClient.SetMetadata(fileMetadata);
auto properties = *fileClient.GetProperties();

View File

@ -171,7 +171,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
Azure::Core::Response<Models::SetShareMetadataResult> ShareClient::SetMetadata(
std::map<std::string, std::string> metadata,
Storage::Metadata metadata,
const SetShareMetadataOptions& options) const
{
auto protocolLayerOptions = Details::ShareRestClient::Share::SetMetadataOptions();

View File

@ -219,11 +219,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
Azure::Core::Response<Models::SetDirectoryMetadataResult> ShareDirectoryClient::SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetDirectoryMetadataOptions& options) const
{
auto protocolLayerOptions = Details::ShareRestClient::Directory::SetMetadataOptions();
protocolLayerOptions.Metadata = metadata;
protocolLayerOptions.Metadata = std::move(metadata);
return Details::ShareRestClient::Directory::SetMetadata(
m_shareDirectoryUri, *m_pipeline, options.Context, protocolLayerOptions);
}

View File

@ -387,11 +387,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
Azure::Core::Response<Models::SetFileMetadataResult> ShareFileClient::SetMetadata(
const std::map<std::string, std::string>& metadata,
Storage::Metadata metadata,
const SetFileMetadataOptions& options) const
{
auto protocolLayerOptions = Details::ShareRestClient::File::SetMetadataOptions();
protocolLayerOptions.Metadata = metadata;
protocolLayerOptions.Metadata = std::move(metadata);
protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId;
return Details::ShareRestClient::File::SetMetadata(
m_shareFileUri, *m_pipeline, options.Context, protocolLayerOptions);