extensible enum for blob servicve (#1253)
* extensible enum * changelog * Update sdk/storage/azure-storage-blobs/CMakeLists.txt
This commit is contained in:
parent
fb869f10af
commit
5e94ab4054
@ -61,6 +61,7 @@
|
||||
- All date time related strings are now changed to `Azure::Core::DateTime` type.
|
||||
- Replace `std::pair<int64_t, int64_t>` with `Azure::Core::Http::Range` to denote blob ranges.
|
||||
- Move version strings into `Details` namespace.
|
||||
- Replace scoped enums that don't support bitwise operations with extensible enum.
|
||||
|
||||
## 12.0.0-beta.5 (2020-11-13)
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ set(
|
||||
src/blob_batch_client.cpp
|
||||
src/blob_client.cpp
|
||||
src/blob_container_client.cpp
|
||||
src/blob_rest_client.cpp
|
||||
src/blob_sas_builder.cpp
|
||||
src/blob_service_client.cpp
|
||||
src/block_blob_client.cpp
|
||||
|
||||
@ -69,7 +69,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
std::string BlobContainerName;
|
||||
std::string BlobName;
|
||||
Models::AccessTier Tier = Models::AccessTier::Unknown;
|
||||
Models::AccessTier Tier;
|
||||
SetBlobAccessTierOptions Options;
|
||||
};
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ namespace Azure { namespace Storage { namespace Blobs { namespace Models {
|
||||
int64_t ContentLength = 0;
|
||||
BlobHttpHeaders HttpHeaders;
|
||||
Storage::Metadata Metadata;
|
||||
Models::BlobType BlobType = Models::BlobType::Unknown;
|
||||
Models::BlobType BlobType;
|
||||
bool IsServerEncrypted = false;
|
||||
Azure::Core::Nullable<std::vector<uint8_t>> EncryptionKeySha256;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
93
sdk/storage/azure-storage-blobs/src/blob_rest_client.cpp
Normal file
93
sdk/storage/azure-storage-blobs/src/blob_rest_client.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "azure/storage/blobs/protocol/blob_rest_client.hpp"
|
||||
|
||||
namespace Azure { namespace Storage { namespace Blobs { namespace Models {
|
||||
|
||||
const AccessTier AccessTier::P1("P1");
|
||||
const AccessTier AccessTier::P2("P2");
|
||||
const AccessTier AccessTier::P3("P3");
|
||||
const AccessTier AccessTier::P4("P4");
|
||||
const AccessTier AccessTier::P6("P6");
|
||||
const AccessTier AccessTier::P10("P10");
|
||||
const AccessTier AccessTier::P15("P15");
|
||||
const AccessTier AccessTier::P20("P20");
|
||||
const AccessTier AccessTier::P30("P30");
|
||||
const AccessTier AccessTier::P40("P40");
|
||||
const AccessTier AccessTier::P50("P50");
|
||||
const AccessTier AccessTier::P60("P60");
|
||||
const AccessTier AccessTier::P70("P70");
|
||||
const AccessTier AccessTier::P80("P80");
|
||||
const AccessTier AccessTier::Hot("Hot");
|
||||
const AccessTier AccessTier::Cool("Cool");
|
||||
const AccessTier AccessTier::Archive("Archive");
|
||||
|
||||
const AccountKind AccountKind::Storage("Storage");
|
||||
const AccountKind AccountKind::BlobStorage("BlobStorage");
|
||||
const AccountKind AccountKind::StorageV2("StorageV2");
|
||||
const AccountKind AccountKind::FileStorage("FileStorage");
|
||||
const AccountKind AccountKind::BlockBlobStorage("BlockBlobStorage");
|
||||
|
||||
const BlobArchiveStatus BlobArchiveStatus::RehydratePendingToHot("rehydrate-pending-to-hot");
|
||||
const BlobArchiveStatus BlobArchiveStatus::RehydratePendingToCool("rehydrate-pending-to-cool");
|
||||
|
||||
const BlobGeoReplicationStatus BlobGeoReplicationStatus::Live("live");
|
||||
const BlobGeoReplicationStatus BlobGeoReplicationStatus::Bootstrap("bootstrap");
|
||||
const BlobGeoReplicationStatus BlobGeoReplicationStatus::Unavailable("unavailable");
|
||||
|
||||
const BlobLeaseState BlobLeaseState::Available("available");
|
||||
const BlobLeaseState BlobLeaseState::Leased("leased");
|
||||
const BlobLeaseState BlobLeaseState::Expired("expired");
|
||||
const BlobLeaseState BlobLeaseState::Breaking("breaking");
|
||||
const BlobLeaseState BlobLeaseState::Broken("broken");
|
||||
|
||||
const BlobLeaseStatus BlobLeaseStatus::Locked("locked");
|
||||
const BlobLeaseStatus BlobLeaseStatus::Unlocked("unlocked");
|
||||
|
||||
const BlobType BlobType::BlockBlob("BlockBlob");
|
||||
const BlobType BlobType::PageBlob("PageBlob");
|
||||
const BlobType BlobType::AppendBlob("AppendBlob");
|
||||
|
||||
const BlockListTypeOption BlockListTypeOption::Committed("committed");
|
||||
const BlockListTypeOption BlockListTypeOption::Uncommitted("uncommitted");
|
||||
const BlockListTypeOption BlockListTypeOption::All("all");
|
||||
|
||||
const BlockType BlockType::Committed("Committed");
|
||||
const BlockType BlockType::Uncommitted("Uncommitted");
|
||||
const BlockType BlockType::Latest("Latest");
|
||||
|
||||
const CopyStatus CopyStatus::Success("success");
|
||||
const CopyStatus CopyStatus::Pending("pending");
|
||||
|
||||
const DeleteSnapshotsOption DeleteSnapshotsOption::IncludeSnapshots("include");
|
||||
const DeleteSnapshotsOption DeleteSnapshotsOption::Only("only");
|
||||
|
||||
const EncryptionAlgorithmType EncryptionAlgorithmType::Aes256("AES256");
|
||||
|
||||
const ObjectReplicationStatus ObjectReplicationStatus::Complete("complete");
|
||||
const ObjectReplicationStatus ObjectReplicationStatus::Failed("failed");
|
||||
|
||||
const PublicAccessType PublicAccessType::BlobContainer("container");
|
||||
const PublicAccessType PublicAccessType::Blob("blob");
|
||||
const PublicAccessType PublicAccessType::Private("Private");
|
||||
|
||||
const RehydratePriority RehydratePriority::High("High");
|
||||
const RehydratePriority RehydratePriority::Standard("Standard");
|
||||
|
||||
const ScheduleBlobExpiryOriginType ScheduleBlobExpiryOriginType::NeverExpire("NeverExpire");
|
||||
const ScheduleBlobExpiryOriginType ScheduleBlobExpiryOriginType::RelativeToCreation(
|
||||
"RelativeToCreation");
|
||||
const ScheduleBlobExpiryOriginType ScheduleBlobExpiryOriginType::RelativeToNow("RelativeToNow");
|
||||
const ScheduleBlobExpiryOriginType ScheduleBlobExpiryOriginType::Absolute("Absolute");
|
||||
|
||||
const SkuName SkuName::StandardLrs("Standard_LRS");
|
||||
const SkuName SkuName::StandardGrs("Standard_GRS");
|
||||
const SkuName SkuName::StandardRagrs("Standard_RAGRS");
|
||||
const SkuName SkuName::StandardZrs("Standard_ZRS");
|
||||
const SkuName SkuName::PremiumLrs("Premium_LRS");
|
||||
const SkuName SkuName::PremiumZrs("Premium_ZRS");
|
||||
const SkuName SkuName::StandardGzrs("Standard_GZRS");
|
||||
const SkuName SkuName::StandardRagzrs("Standard_RAGZRS");
|
||||
|
||||
}}}} // namespace Azure::Storage::Blobs::Models
|
||||
@ -177,7 +177,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_TRUE(IsValidTime(blob.CreatedOn));
|
||||
EXPECT_TRUE(IsValidTime(blob.LastModified));
|
||||
EXPECT_FALSE(blob.ETag.empty());
|
||||
EXPECT_NE(blob.BlobType, Azure::Storage::Blobs::Models::BlobType::Unknown);
|
||||
EXPECT_FALSE(blob.BlobType.Get().empty());
|
||||
if (blob.BlobType == Blobs::Models::BlobType::BlockBlob)
|
||||
{
|
||||
EXPECT_TRUE(blob.Tier.HasValue());
|
||||
@ -185,7 +185,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
}
|
||||
if (blob.Tier.HasValue())
|
||||
{
|
||||
EXPECT_NE(blob.Tier.GetValue(), Azure::Storage::Blobs::Models::AccessTier::Unknown);
|
||||
EXPECT_FALSE(blob.Tier.GetValue().Get().empty());
|
||||
}
|
||||
if (blob.BlobType == Blobs::Models::BlobType::AppendBlob)
|
||||
{
|
||||
|
||||
@ -318,8 +318,8 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
TEST_F(BlobServiceClientTest, AccountInfo)
|
||||
{
|
||||
auto accountInfo = *m_blobServiceClient.GetAccountInfo();
|
||||
EXPECT_NE(accountInfo.SkuName, Blobs::Models::SkuName::Unknown);
|
||||
EXPECT_NE(accountInfo.AccountKind, Blobs::Models::AccountKind::Unknown);
|
||||
EXPECT_FALSE(accountInfo.SkuName.Get().empty());
|
||||
EXPECT_FALSE(accountInfo.AccountKind.Get().empty());
|
||||
EXPECT_FALSE(accountInfo.IsHierarchicalNamespaceEnabled);
|
||||
|
||||
auto dataLakeServiceClient
|
||||
@ -337,8 +337,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto secondaryServiceClient
|
||||
= Blobs::BlobServiceClient(InferSecondaryUrl(m_blobServiceClient.GetUrl()), keyCredential);
|
||||
auto serviceStatistics = *secondaryServiceClient.GetStatistics();
|
||||
EXPECT_NE(
|
||||
serviceStatistics.GeoReplication.Status, Blobs::Models::BlobGeoReplicationStatus::Unknown);
|
||||
EXPECT_FALSE(serviceStatistics.GeoReplication.Status.Get().empty());
|
||||
if (serviceStatistics.GeoReplication.LastSyncedOn.HasValue())
|
||||
{
|
||||
EXPECT_TRUE(IsValidTime(serviceStatistics.GeoReplication.LastSyncedOn.GetValue()));
|
||||
|
||||
@ -150,7 +150,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_FALSE(copyInfo->ETag.empty());
|
||||
EXPECT_TRUE(IsValidTime(copyInfo->LastModified));
|
||||
EXPECT_FALSE(copyInfo->CopyId.empty());
|
||||
EXPECT_NE(copyInfo->CopyStatus, Blobs::Models::CopyStatus::Unknown);
|
||||
EXPECT_FALSE(copyInfo->CopyStatus.Get().empty());
|
||||
EXPECT_TRUE(copyInfo->VersionId.HasValue());
|
||||
EXPECT_FALSE(copyInfo->VersionId.GetValue().empty());
|
||||
}
|
||||
|
||||
@ -69,34 +69,40 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
|
||||
Models::LeaseStateType FromBlobLeaseState(Blobs::Models::BlobLeaseState state)
|
||||
{
|
||||
switch (state)
|
||||
if (state == Blobs::Models::BlobLeaseState::Available)
|
||||
{
|
||||
case Blobs::Models::BlobLeaseState::Available:
|
||||
return Models::LeaseStateType::Available;
|
||||
case Blobs::Models::BlobLeaseState::Breaking:
|
||||
return Models::LeaseStateType::Breaking;
|
||||
case Blobs::Models::BlobLeaseState::Broken:
|
||||
return Models::LeaseStateType::Broken;
|
||||
case Blobs::Models::BlobLeaseState::Expired:
|
||||
return Models::LeaseStateType::Expired;
|
||||
case Blobs::Models::BlobLeaseState::Leased:
|
||||
return Models::LeaseStateType::Leased;
|
||||
default:
|
||||
return Models::LeaseStateType::Unknown;
|
||||
return Models::LeaseStateType::Available;
|
||||
}
|
||||
if (state == Blobs::Models::BlobLeaseState::Breaking)
|
||||
{
|
||||
return Models::LeaseStateType::Breaking;
|
||||
}
|
||||
if (state == Blobs::Models::BlobLeaseState::Broken)
|
||||
{
|
||||
return Models::LeaseStateType::Broken;
|
||||
}
|
||||
if (state == Blobs::Models::BlobLeaseState::Expired)
|
||||
{
|
||||
return Models::LeaseStateType::Expired;
|
||||
}
|
||||
if (state == Blobs::Models::BlobLeaseState::Leased)
|
||||
{
|
||||
return Models::LeaseStateType::Leased;
|
||||
}
|
||||
return Models::LeaseStateType::Unknown;
|
||||
}
|
||||
|
||||
Models::LeaseStatusType FromBlobLeaseStatus(Blobs::Models::BlobLeaseStatus status)
|
||||
{
|
||||
switch (status)
|
||||
if (status == Blobs::Models::BlobLeaseStatus::Locked)
|
||||
{
|
||||
case Blobs::Models::BlobLeaseStatus::Locked:
|
||||
return Models::LeaseStatusType::Locked;
|
||||
case Blobs::Models::BlobLeaseStatus::Unlocked:
|
||||
return Models::LeaseStatusType::Unlocked;
|
||||
default:
|
||||
return Models::LeaseStatusType::Unknown;
|
||||
return Models::LeaseStatusType::Locked;
|
||||
}
|
||||
if (status == Blobs::Models::BlobLeaseStatus::Unlocked)
|
||||
{
|
||||
return Models::LeaseStatusType::Unlocked;
|
||||
}
|
||||
return Models::LeaseStatusType::Unknown;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
@ -35,47 +35,40 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
|
||||
Models::LeaseStateType FromBlobLeaseState(Blobs::Models::BlobLeaseState state)
|
||||
{
|
||||
auto ret = Models::LeaseStateType::Unknown;
|
||||
switch (state)
|
||||
if (state == Blobs::Models::BlobLeaseState::Available)
|
||||
{
|
||||
case Blobs::Models::BlobLeaseState::Available:
|
||||
ret = Models::LeaseStateType::Available;
|
||||
break;
|
||||
case Blobs::Models::BlobLeaseState::Breaking:
|
||||
ret = Models::LeaseStateType::Breaking;
|
||||
break;
|
||||
case Blobs::Models::BlobLeaseState::Broken:
|
||||
ret = Models::LeaseStateType::Broken;
|
||||
break;
|
||||
case Blobs::Models::BlobLeaseState::Expired:
|
||||
ret = Models::LeaseStateType::Expired;
|
||||
break;
|
||||
case Blobs::Models::BlobLeaseState::Leased:
|
||||
ret = Models::LeaseStateType::Leased;
|
||||
break;
|
||||
default:
|
||||
ret = Models::LeaseStateType::Unknown;
|
||||
break;
|
||||
return Models::LeaseStateType::Available;
|
||||
}
|
||||
return ret;
|
||||
if (state == Blobs::Models::BlobLeaseState::Breaking)
|
||||
{
|
||||
return Models::LeaseStateType::Breaking;
|
||||
}
|
||||
if (state == Blobs::Models::BlobLeaseState::Broken)
|
||||
{
|
||||
return Models::LeaseStateType::Broken;
|
||||
}
|
||||
if (state == Blobs::Models::BlobLeaseState::Expired)
|
||||
{
|
||||
return Models::LeaseStateType::Expired;
|
||||
}
|
||||
if (state == Blobs::Models::BlobLeaseState::Leased)
|
||||
{
|
||||
return Models::LeaseStateType::Leased;
|
||||
}
|
||||
return Models::LeaseStateType::Unknown;
|
||||
}
|
||||
|
||||
Models::LeaseStatusType FromBlobLeaseStatus(Blobs::Models::BlobLeaseStatus status)
|
||||
{
|
||||
auto ret = Models::LeaseStatusType::Unknown;
|
||||
switch (status)
|
||||
if (status == Blobs::Models::BlobLeaseStatus::Locked)
|
||||
{
|
||||
case Blobs::Models::BlobLeaseStatus::Locked:
|
||||
ret = Models::LeaseStatusType::Locked;
|
||||
break;
|
||||
case Blobs::Models::BlobLeaseStatus::Unlocked:
|
||||
ret = Models::LeaseStatusType::Unlocked;
|
||||
break;
|
||||
default:
|
||||
ret = Models::LeaseStatusType::Unknown;
|
||||
break;
|
||||
return Models::LeaseStatusType::Locked;
|
||||
}
|
||||
return ret;
|
||||
if (status == Blobs::Models::BlobLeaseStatus::Unlocked)
|
||||
{
|
||||
return Models::LeaseStatusType::Unlocked;
|
||||
}
|
||||
return Models::LeaseStatusType::Unknown;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user