API review change (#942)
* make SharedKeyCredential a class
* move xml stuff to Details namespace
* Rename LastModifiedTimeAccessConditions -> ModifiedTimeConditions
* remove {Block/Append/Page}BlobClientOptions
* file -> fileName
* rename StorageError->StorageException
* rename storage_error.hpp -> storage_exception.hpp
* fix build error
* Adapted name/namespace change
* fix typo
* Removed Azure in Azure::Storage
Co-authored-by: Tank Tang <kat@microsoft.com>
This commit is contained in:
parent
8c45574292
commit
8e46bbaacd
@ -38,7 +38,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const std::string& connectionString,
|
||||
const std::string& containerName,
|
||||
const std::string& blobName,
|
||||
const AppendBlobClientOptions& options = AppendBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of AppendBlobClient.
|
||||
@ -54,7 +54,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
explicit AppendBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<SharedKeyCredential> credential,
|
||||
const AppendBlobClientOptions& options = AppendBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of AppendBlobClient.
|
||||
@ -69,7 +69,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
explicit AppendBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<Identity::ClientSecretCredential> credential,
|
||||
const AppendBlobClientOptions& options = AppendBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of AppendBlobClient.
|
||||
@ -83,7 +83,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
*/
|
||||
explicit AppendBlobClient(
|
||||
const std::string& blobUri,
|
||||
const AppendBlobClientOptions& options = AppendBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the AppendBlobClient class with an identical uri
|
||||
|
||||
@ -244,12 +244,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @brief Downloads a blob or a blob range from the service to a file using parallel
|
||||
* requests.
|
||||
*
|
||||
* @param file A file path to write the downloaded content to.
|
||||
* @param fileName A file path to write the downloaded content to.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A DownloadBlobToResult describing the downloaded blob.
|
||||
*/
|
||||
Azure::Core::Response<DownloadBlobToResult> DownloadTo(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const DownloadBlobToOptions& options = DownloadBlobToOptions()) const;
|
||||
|
||||
/**
|
||||
|
||||
@ -16,8 +16,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Specifies access conditions for a container.
|
||||
*/
|
||||
struct ContainerAccessConditions : public LastModifiedTimeAccessConditions,
|
||||
public LeaseAccessConditions
|
||||
struct ContainerAccessConditions : public ModifiedTimeConditions, public LeaseAccessConditions
|
||||
{
|
||||
};
|
||||
|
||||
@ -37,7 +36,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Specifies access conditions for a blob.
|
||||
*/
|
||||
struct BlobAccessConditions : public LastModifiedTimeAccessConditions,
|
||||
struct BlobAccessConditions : public ModifiedTimeConditions,
|
||||
public ETagAccessConditions,
|
||||
public LeaseAccessConditions,
|
||||
public TagAccessConditions
|
||||
@ -456,7 +455,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobContainerClient::AcquireLease.
|
||||
*/
|
||||
struct AcquireContainerLeaseOptions : public LastModifiedTimeAccessConditions
|
||||
struct AcquireContainerLeaseOptions : public ModifiedTimeConditions
|
||||
{
|
||||
/**
|
||||
* @brief Context for cancelling long running operations.
|
||||
@ -467,7 +466,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobContainerClient::RenewLease.
|
||||
*/
|
||||
struct RenewContainerLeaseOptions : public LastModifiedTimeAccessConditions
|
||||
struct RenewContainerLeaseOptions : public ModifiedTimeConditions
|
||||
{
|
||||
/**
|
||||
* @brief Context for cancelling long running operations.
|
||||
@ -478,7 +477,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobContainerClient::ChangeLease.
|
||||
*/
|
||||
struct ChangeContainerLeaseOptions : public LastModifiedTimeAccessConditions
|
||||
struct ChangeContainerLeaseOptions : public ModifiedTimeConditions
|
||||
{
|
||||
/**
|
||||
* @brief Context for cancelling long running operations.
|
||||
@ -489,7 +488,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobContainerClient::ReleaseLease.
|
||||
*/
|
||||
struct ReleaseContainerLeaseOptions : public LastModifiedTimeAccessConditions
|
||||
struct ReleaseContainerLeaseOptions : public ModifiedTimeConditions
|
||||
{
|
||||
/**
|
||||
* @brief Context for cancelling long running operations.
|
||||
@ -500,7 +499,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobContainerClient::BreakLease.
|
||||
*/
|
||||
struct BreakContainerLeaseOptions : public LastModifiedTimeAccessConditions
|
||||
struct BreakContainerLeaseOptions : public ModifiedTimeConditions
|
||||
{
|
||||
/**
|
||||
* @brief Context for cancelling long running operations.
|
||||
@ -550,27 +549,6 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
StorageRetryWithSecondaryOptions RetryOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Block blob client options used to initalize BlockBlobClient.
|
||||
*/
|
||||
struct BlockBlobClientOptions : public BlobClientOptions
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Append blob client options used to initalize AppendBlobClient.
|
||||
*/
|
||||
struct AppendBlobClientOptions : public BlobClientOptions
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Page blob client options used to initalize PageBlobClient.
|
||||
*/
|
||||
struct PageBlobClientOptions : public BlobClientOptions
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Optional parameters for BlobClient::GetProperties.
|
||||
*/
|
||||
@ -827,7 +805,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobClient::AcquireLease.
|
||||
*/
|
||||
struct AcquireBlobLeaseOptions : public LastModifiedTimeAccessConditions,
|
||||
struct AcquireBlobLeaseOptions : public ModifiedTimeConditions,
|
||||
public ETagAccessConditions,
|
||||
public TagAccessConditions
|
||||
{
|
||||
@ -840,7 +818,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobClient::RenewLease.
|
||||
*/
|
||||
struct RenewBlobLeaseOptions : public LastModifiedTimeAccessConditions,
|
||||
struct RenewBlobLeaseOptions : public ModifiedTimeConditions,
|
||||
public ETagAccessConditions,
|
||||
public TagAccessConditions
|
||||
{
|
||||
@ -853,7 +831,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobClient::ChangeLease.
|
||||
*/
|
||||
struct ChangeBlobLeaseOptions : public LastModifiedTimeAccessConditions,
|
||||
struct ChangeBlobLeaseOptions : public ModifiedTimeConditions,
|
||||
public ETagAccessConditions,
|
||||
public TagAccessConditions
|
||||
{
|
||||
@ -866,7 +844,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobClient::ReleaseLease.
|
||||
*/
|
||||
struct ReleaseBlobLeaseOptions : public LastModifiedTimeAccessConditions,
|
||||
struct ReleaseBlobLeaseOptions : public ModifiedTimeConditions,
|
||||
public ETagAccessConditions,
|
||||
public TagAccessConditions
|
||||
{
|
||||
@ -879,7 +857,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional parameters for BlobClient::BreakLease.
|
||||
*/
|
||||
struct BreakBlobLeaseOptions : public LastModifiedTimeAccessConditions,
|
||||
struct BreakBlobLeaseOptions : public ModifiedTimeConditions,
|
||||
public ETagAccessConditions,
|
||||
public TagAccessConditions
|
||||
{
|
||||
@ -1074,7 +1052,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Optional conditions that the source must meet to perform this operation.
|
||||
*/
|
||||
struct : public LastModifiedTimeAccessConditions, public ETagAccessConditions
|
||||
struct : public ModifiedTimeConditions, public ETagAccessConditions
|
||||
{
|
||||
} SourceConditions;
|
||||
};
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const std::string& connectionString,
|
||||
const std::string& containerName,
|
||||
const std::string& blobName,
|
||||
const BlockBlobClientOptions& options = BlockBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of BlockBlobClient.
|
||||
@ -64,7 +64,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
explicit BlockBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<SharedKeyCredential> credential,
|
||||
const BlockBlobClientOptions& options = BlockBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of BlockBlobClient.
|
||||
@ -79,7 +79,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
explicit BlockBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<Identity::ClientSecretCredential> credential,
|
||||
const BlockBlobClientOptions& options = BlockBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of BlockBlobClient.
|
||||
@ -93,7 +93,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
*/
|
||||
explicit BlockBlobClient(
|
||||
const std::string& blobUri,
|
||||
const BlockBlobClientOptions& options = BlockBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the BlockBlobClient class with an identical uri
|
||||
@ -146,12 +146,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @brief Creates a new block blob, or updates the content of an existing block blob. Updating
|
||||
* an existing block blob overwrites any existing metadata on the blob.
|
||||
*
|
||||
* @param file A file containing the content to upload.
|
||||
* @param fileName A file containing the content to upload.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A UploadBlockBlobFromResult describing the state of the updated block blob.
|
||||
*/
|
||||
Azure::Core::Response<UploadBlockBlobFromResult> UploadFrom(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const UploadBlockBlobFromOptions& options = UploadBlockBlobFromOptions()) const;
|
||||
|
||||
/**
|
||||
|
||||
@ -40,7 +40,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const std::string& connectionString,
|
||||
const std::string& containerName,
|
||||
const std::string& blobName,
|
||||
const PageBlobClientOptions& options = PageBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of PageBlobClient.
|
||||
@ -56,7 +56,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
explicit PageBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<SharedKeyCredential> credential,
|
||||
const PageBlobClientOptions& options = PageBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of PageBlobClient.
|
||||
@ -71,7 +71,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
explicit PageBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<Identity::ClientSecretCredential> credential,
|
||||
const PageBlobClientOptions& options = PageBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initialize a new instance of PageBlobClient.
|
||||
@ -85,7 +85,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
*/
|
||||
explicit PageBlobClient(
|
||||
const std::string& blobUri,
|
||||
const PageBlobClientOptions& options = PageBlobClientOptions());
|
||||
const BlobClientOptions& options = BlobClientOptions());
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the PageBlobClient class with an identical uri
|
||||
@ -156,7 +156,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A UploadPageBlobPagesFromUriResult describing the state of the updated pages.
|
||||
*/
|
||||
Azure::Core::Response<UploadPageBlobPagesFromUriResult> UploadPagesFromUri(
|
||||
int64_t destinationoffset,
|
||||
int64_t destinationOffset,
|
||||
std::string sourceUri,
|
||||
int64_t sourceOffset,
|
||||
int64_t sourceLength,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const std::string& connectionString,
|
||||
const std::string& containerName,
|
||||
const std::string& blobName,
|
||||
const AppendBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
{
|
||||
AppendBlobClient newClient(
|
||||
BlobClient::CreateFromConnectionString(connectionString, containerName, blobName, options));
|
||||
@ -22,7 +22,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
AppendBlobClient::AppendBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<SharedKeyCredential> credential,
|
||||
const AppendBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, std::move(credential), options)
|
||||
{
|
||||
}
|
||||
@ -30,14 +30,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
AppendBlobClient::AppendBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<Identity::ClientSecretCredential> credential,
|
||||
const AppendBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, std::move(credential), options)
|
||||
{
|
||||
}
|
||||
|
||||
AppendBlobClient::AppendBlobClient(
|
||||
const std::string& blobUri,
|
||||
const AppendBlobClientOptions& options)
|
||||
AppendBlobClient::AppendBlobClient(const std::string& blobUri, const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, options)
|
||||
{
|
||||
}
|
||||
|
||||
@ -401,7 +401,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Details::BlobRestClient::Blob::DeleteCreateResponse(
|
||||
options.Context, std::move(rawSubresponse)));
|
||||
}
|
||||
catch (StorageError& e)
|
||||
catch (StorageException& e)
|
||||
{
|
||||
batchResult.DeleteBlobResults.emplace_back(Azure::Core::Response<DeleteBlobResult>(
|
||||
DeleteBlobResult{}, std::move(e.RawResponse)));
|
||||
@ -415,7 +415,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Details::BlobRestClient::Blob::SetAccessTierCreateResponse(
|
||||
options.Context, std::move(rawSubresponse)));
|
||||
}
|
||||
catch (StorageError& e)
|
||||
catch (StorageException& e)
|
||||
{
|
||||
batchResult.SetBlobAccessTierResults.emplace_back(
|
||||
Azure::Core::Response<SetBlobAccessTierResult>(
|
||||
|
||||
@ -344,7 +344,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
|
||||
Azure::Core::Response<DownloadBlobToResult> BlobClient::DownloadTo(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const DownloadBlobToOptions& options) const
|
||||
{
|
||||
constexpr int64_t c_defaultChunkSize = 4 * 1024 * 1024;
|
||||
@ -371,7 +371,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
firstChunkOptions.Length = firstChunkLength;
|
||||
}
|
||||
|
||||
Storage::Details::FileWriter fileWriter(file);
|
||||
Storage::Details::FileWriter fileWriter(fileName);
|
||||
|
||||
auto firstChunk = Download(firstChunkOptions);
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const std::string& connectionString,
|
||||
const std::string& containerName,
|
||||
const std::string& blobName,
|
||||
const BlockBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
{
|
||||
BlockBlobClient newClient(
|
||||
BlobClient::CreateFromConnectionString(connectionString, containerName, blobName, options));
|
||||
@ -25,7 +25,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
BlockBlobClient::BlockBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<SharedKeyCredential> credential,
|
||||
const BlockBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, std::move(credential), options)
|
||||
{
|
||||
}
|
||||
@ -33,14 +33,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
BlockBlobClient::BlockBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<Identity::ClientSecretCredential> credential,
|
||||
const BlockBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, std::move(credential), options)
|
||||
{
|
||||
}
|
||||
|
||||
BlockBlobClient::BlockBlobClient(
|
||||
const std::string& blobUri,
|
||||
const BlockBlobClientOptions& options)
|
||||
BlockBlobClient::BlockBlobClient(const std::string& blobUri, const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, options)
|
||||
{
|
||||
}
|
||||
@ -186,14 +184,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadBlockBlobFromResult> BlockBlobClient::UploadFrom(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const UploadBlockBlobFromOptions& options) const
|
||||
{
|
||||
constexpr int64_t c_defaultBlockSize = 8 * 1024 * 1024;
|
||||
constexpr int64_t c_maximumNumberBlocks = 50000;
|
||||
constexpr int64_t c_grainSize = 4 * 1024;
|
||||
|
||||
Storage::Details::FileReader fileReader(file);
|
||||
Storage::Details::FileReader fileReader(fileName);
|
||||
|
||||
int64_t chunkSize = c_defaultBlockSize;
|
||||
if (options.ChunkSize.HasValue())
|
||||
|
||||
@ -14,7 +14,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const std::string& connectionString,
|
||||
const std::string& containerName,
|
||||
const std::string& blobName,
|
||||
const PageBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
{
|
||||
PageBlobClient newClient(
|
||||
BlobClient::CreateFromConnectionString(connectionString, containerName, blobName, options));
|
||||
@ -24,7 +24,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
PageBlobClient::PageBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<SharedKeyCredential> credential,
|
||||
const PageBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, std::move(credential), options)
|
||||
{
|
||||
}
|
||||
@ -32,12 +32,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
PageBlobClient::PageBlobClient(
|
||||
const std::string& blobUri,
|
||||
std::shared_ptr<Identity::ClientSecretCredential> credential,
|
||||
const PageBlobClientOptions& options)
|
||||
const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, std::move(credential), options)
|
||||
{
|
||||
}
|
||||
|
||||
PageBlobClient::PageBlobClient(const std::string& blobUri, const PageBlobClientOptions& options)
|
||||
PageBlobClient::PageBlobClient(const std::string& blobUri, const BlobClientOptions& options)
|
||||
: BlobClient(blobUri, options)
|
||||
{
|
||||
}
|
||||
@ -130,7 +130,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadPageBlobPagesFromUriResult> PageBlobClient::UploadPagesFromUri(
|
||||
int64_t destinationoffset,
|
||||
int64_t destinationOffset,
|
||||
std::string sourceUri,
|
||||
int64_t sourceOffset,
|
||||
int64_t sourceLength,
|
||||
@ -141,7 +141,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
protocolLayerOptions.SourceRange
|
||||
= std::make_pair(sourceOffset, sourceOffset + sourceLength - 1);
|
||||
protocolLayerOptions.Range
|
||||
= std::make_pair(destinationoffset, destinationoffset + sourceLength - 1);
|
||||
= std::make_pair(destinationOffset, destinationOffset + sourceLength - 1);
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
|
||||
@ -65,7 +65,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Azure::Storage::Blobs::AppendBlockOptions options;
|
||||
options.AccessConditions.AppendPosition = 1_MB;
|
||||
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
EXPECT_THROW(appendBlobClient.AppendBlock(&blockContent, options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.AppendBlock(&blockContent, options), StorageException);
|
||||
options.AccessConditions.AppendPosition = properties.ContentLength;
|
||||
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
appendBlobClient.AppendBlock(&blockContent, options);
|
||||
@ -74,7 +74,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options = Azure::Storage::Blobs::AppendBlockOptions();
|
||||
options.AccessConditions.MaxSize = properties.ContentLength + m_blobContent.size() - 1;
|
||||
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
EXPECT_THROW(appendBlobClient.AppendBlock(&blockContent, options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.AppendBlock(&blockContent, options), StorageException);
|
||||
options.AccessConditions.MaxSize = properties.ContentLength + m_blobContent.size();
|
||||
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
appendBlobClient.AppendBlock(&blockContent, options);
|
||||
@ -87,7 +87,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
properties.ContentLength, static_cast<int64_t>(originalLength + m_blobContent.size()));
|
||||
|
||||
appendBlobClient.Delete();
|
||||
EXPECT_THROW(appendBlobClient.Delete(), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.Delete(), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(AppendBlobClientTest, AccessConditionLastModifiedTime)
|
||||
@ -132,7 +132,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|| (condition == Condition::UnmodifiedSince && sinceTime == TimePoint::TimeBefore);
|
||||
if (shouldThrow)
|
||||
{
|
||||
EXPECT_THROW(appendBlobClient.GetProperties(options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.GetProperties(options), StorageException);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -150,7 +150,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Blobs::CreateAppendBlobOptions createOptions;
|
||||
createOptions.AccessConditions.IfNoneMatch = "*";
|
||||
EXPECT_NO_THROW(appendBlobClient.Create(createOptions));
|
||||
EXPECT_THROW(appendBlobClient.Create(createOptions), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.Create(createOptions), StorageException);
|
||||
|
||||
std::string eTag = appendBlobClient.GetProperties()->ETag;
|
||||
for (std::string match : {eTag, std::string(c_dummyETag), std::string()})
|
||||
@ -169,7 +169,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
bool shouldThrow = (!match.empty() && match != eTag) || noneMatch == eTag;
|
||||
if (shouldThrow)
|
||||
{
|
||||
EXPECT_THROW(appendBlobClient.GetProperties(options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.GetProperties(options), StorageException);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -187,7 +187,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
std::string leaseId = CreateUniqueLeaseId();
|
||||
appendBlobClient.AcquireLease(leaseId, 30);
|
||||
EXPECT_THROW(appendBlobClient.Delete(), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.Delete(), StorageException);
|
||||
Blobs::DeleteBlobOptions options;
|
||||
options.AccessConditions.LeaseId = leaseId;
|
||||
EXPECT_NO_THROW(appendBlobClient.Delete(options));
|
||||
@ -215,7 +215,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
/*
|
||||
don't know why, the copy operation also succeeds even if the lease id doesn't match.
|
||||
EXPECT_THROW(
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageError);
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageException);
|
||||
*/
|
||||
options.SourceConditions.LeaseId = leaseId;
|
||||
EXPECT_NO_THROW(destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options));
|
||||
@ -227,7 +227,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options));
|
||||
options.SourceConditions.IfMatch = c_dummyETag;
|
||||
EXPECT_THROW(
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageError);
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageException);
|
||||
}
|
||||
{
|
||||
Blobs::StartCopyBlobFromUriOptions options;
|
||||
@ -235,7 +235,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options));
|
||||
options.SourceConditions.IfNoneMatch = eTag;
|
||||
EXPECT_THROW(
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageError);
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageException);
|
||||
}
|
||||
{
|
||||
Blobs::StartCopyBlobFromUriOptions options;
|
||||
@ -243,7 +243,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options));
|
||||
options.SourceConditions.IfModifiedSince = timeAfterStr;
|
||||
EXPECT_THROW(
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageError);
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageException);
|
||||
}
|
||||
{
|
||||
Blobs::StartCopyBlobFromUriOptions options;
|
||||
@ -251,7 +251,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options));
|
||||
options.SourceConditions.IfUnmodifiedSince = timeBeforeStr;
|
||||
EXPECT_THROW(
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageError);
|
||||
destBlobClient.StartCopyFromUri(sourceBlobClient.GetUri(), options), StorageException);
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
Blobs::SealAppendBlobOptions sealOptions;
|
||||
sealOptions.AccessConditions.AppendPosition = m_blobContent.size() + 1;
|
||||
EXPECT_THROW(blobClient.Seal(sealOptions), StorageError);
|
||||
EXPECT_THROW(blobClient.Seal(sealOptions), StorageException);
|
||||
|
||||
sealOptions.AccessConditions.AppendPosition = m_blobContent.size();
|
||||
auto sealResult = blobClient.Seal(sealOptions);
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
auto batchClient = Blobs::BlobBatchClient(serviceClient.GetUri());
|
||||
|
||||
EXPECT_THROW(batchClient.SubmitBatch(batch), StorageError);
|
||||
EXPECT_THROW(batchClient.SubmitBatch(batch), StorageException);
|
||||
|
||||
batchClient = Blobs::BlobBatchClient(
|
||||
serviceClient.GetUri() + accountSasBuilder.ToSasQueryParameters(*keyCredential));
|
||||
@ -89,7 +89,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
int32_t id3 = batch.SetBlobAccessTier(containerName2, blobName21, Blobs::AccessTier::Hot);
|
||||
int32_t id4 = batch.SetBlobAccessTier(containerName2, blobName22, Blobs::AccessTier::Cool);
|
||||
unused(id1, id2, id3, id4);
|
||||
|
||||
|
||||
std::size_t failedId = static_cast<std::size_t>(id4);
|
||||
std::size_t batchSize = static_cast<std::size_t>(id4) + 1;
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_THROW(container_client.Create(), StorageError);
|
||||
EXPECT_THROW(container_client.Create(), StorageException);
|
||||
|
||||
auto res2 = container_client.Delete();
|
||||
EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
@ -470,7 +470,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
}
|
||||
{
|
||||
std::string blobName = RandomString();
|
||||
Blobs::AppendBlobClientOptions options;
|
||||
Blobs::BlobClientOptions options;
|
||||
options.EncryptionScope = c_TestEncryptionScope;
|
||||
auto appendBlobClient = Azure::Storage::Blobs::AppendBlobClient::CreateFromConnectionString(
|
||||
StandardStorageConnectionString(), m_containerName, blobName, options);
|
||||
@ -488,8 +488,9 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto appendBlobClientWithoutEncryptionScope
|
||||
= Azure::Storage::Blobs::AppendBlobClient::CreateFromConnectionString(
|
||||
StandardStorageConnectionString(), m_containerName, blobName);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionScope.AppendBlock(&bodyStream), StorageError);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionScope.CreateSnapshot(), StorageError);
|
||||
EXPECT_THROW(
|
||||
appendBlobClientWithoutEncryptionScope.AppendBlock(&bodyStream), StorageException);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionScope.CreateSnapshot(), StorageException);
|
||||
appendBlobClient.Delete();
|
||||
}
|
||||
}
|
||||
@ -529,14 +530,14 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(blockBlob.StageBlockFromUri(blockId2, copySourceBlob.GetUri() + GetSas()));
|
||||
EXPECT_NO_THROW(blockBlob.CommitBlockList(
|
||||
{{Blobs::BlockType::Uncommitted, blockId1}, {Blobs::BlockType::Uncommitted, blockId2}}));
|
||||
EXPECT_THROW(blockBlob.SetAccessTier(Blobs::AccessTier::Cool), StorageError);
|
||||
EXPECT_THROW(blockBlob.SetAccessTier(Blobs::AccessTier::Cool), StorageException);
|
||||
|
||||
auto appendBlobClientWithoutEncryptionKey
|
||||
= Azure::Storage::Blobs::BlockBlobClient::CreateFromConnectionString(
|
||||
StandardStorageConnectionString(), m_containerName, blockBlobName);
|
||||
EXPECT_THROW(
|
||||
appendBlobClientWithoutEncryptionKey.SetAccessTier(Blobs::AccessTier::Cool),
|
||||
StorageError);
|
||||
StorageException);
|
||||
EXPECT_NO_THROW(appendBlobClientWithoutEncryptionKey.GetBlockList());
|
||||
}
|
||||
|
||||
@ -563,15 +564,15 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
= Azure::Storage::Blobs::AppendBlobClient::CreateFromConnectionString(
|
||||
StandardStorageConnectionString(), m_containerName, appendBlobName);
|
||||
bodyStream.Rewind();
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.AppendBlock(&bodyStream), StorageError);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.AppendBlock(&bodyStream), StorageException);
|
||||
EXPECT_THROW(
|
||||
appendBlobClientWithoutEncryptionKey.AppendBlockFromUri(
|
||||
copySourceBlob.GetUri() + GetSas()),
|
||||
StorageError);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.Download(), StorageError);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.GetProperties(), StorageError);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.SetMetadata({}), StorageError);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.CreateSnapshot(), StorageError);
|
||||
StorageException);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.Download(), StorageException);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.GetProperties(), StorageException);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.SetMetadata({}), StorageException);
|
||||
EXPECT_THROW(appendBlobClientWithoutEncryptionKey.CreateSnapshot(), StorageException);
|
||||
EXPECT_NO_THROW(
|
||||
appendBlobClientWithoutEncryptionKey.SetHttpHeaders(Blobs::BlobHttpHeaders()));
|
||||
Blobs::DeleteBlobOptions deleteOptions;
|
||||
@ -647,7 +648,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|| (condition == Condition::UnmodifiedSince && sinceTime == TimePoint::TimeBefore);
|
||||
if (shouldThrow)
|
||||
{
|
||||
EXPECT_THROW(containerClient.SetAccessPolicy(options), StorageError);
|
||||
EXPECT_THROW(containerClient.SetAccessPolicy(options), StorageException);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -666,7 +667,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
std::string leaseId = CreateUniqueLeaseId();
|
||||
containerClient.AcquireLease(leaseId, 30);
|
||||
EXPECT_THROW(containerClient.Delete(), StorageError);
|
||||
EXPECT_THROW(containerClient.Delete(), StorageException);
|
||||
Blobs::DeleteContainerOptions options;
|
||||
options.AccessConditions.LeaseId = leaseId;
|
||||
EXPECT_NO_THROW(containerClient.Delete(options));
|
||||
@ -719,7 +720,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
deletedContainerItem.Name, deletedContainerItem.VersionId.GetValue());
|
||||
break;
|
||||
}
|
||||
catch (StorageError& e)
|
||||
catch (StorageException& e)
|
||||
{
|
||||
if (e.StatusCode == Azure::Core::Http::HttpStatusCode::Conflict
|
||||
&& e.ReasonPhrase == "The specified container is being deleted.")
|
||||
@ -842,7 +843,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.GetProperties(options));
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.GetProperties(options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.GetProperties(options), StorageException);
|
||||
}
|
||||
|
||||
{
|
||||
@ -851,7 +852,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(appendBlobClient.SetHttpHeaders(Blobs::BlobHttpHeaders(), options));
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(
|
||||
appendBlobClient.SetHttpHeaders(Blobs::BlobHttpHeaders(), options), StorageError);
|
||||
appendBlobClient.SetHttpHeaders(Blobs::BlobHttpHeaders(), options), StorageException);
|
||||
}
|
||||
|
||||
{
|
||||
@ -859,7 +860,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.SetMetadata({}, options));
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.SetMetadata({}, options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.SetMetadata({}, options), StorageException);
|
||||
}
|
||||
|
||||
{
|
||||
@ -867,7 +868,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.Download(options));
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.Download(options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.Download(options), StorageException);
|
||||
}
|
||||
|
||||
{
|
||||
@ -875,13 +876,13 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.CreateSnapshot(options));
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.CreateSnapshot(options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.CreateSnapshot(options), StorageException);
|
||||
}
|
||||
|
||||
{
|
||||
Blobs::CreateAppendBlobOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.Create(options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.Create(options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.Create(options));
|
||||
appendBlobClient.SetTags(tags);
|
||||
@ -891,7 +892,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Blobs::AppendBlockOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
content.Rewind();
|
||||
EXPECT_THROW(appendBlobClient.AppendBlock(&content, options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.AppendBlock(&content, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
content.Rewind();
|
||||
EXPECT_NO_THROW(appendBlobClient.AppendBlock(&content, options));
|
||||
@ -899,7 +900,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
std::string uri = appendBlobClient.GetUri() + GetSas();
|
||||
Blobs::AppendBlockFromUriOptions options2;
|
||||
options2.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.AppendBlockFromUri(uri, options2), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.AppendBlockFromUri(uri, options2), StorageException);
|
||||
options2.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.AppendBlockFromUri(uri, options2));
|
||||
}
|
||||
@ -911,7 +912,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto blobClient2 = Azure::Storage::Blobs::AppendBlobClient::CreateFromConnectionString(
|
||||
StandardStorageConnectionString(), m_containerName, RandomString());
|
||||
options.SourceConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(blobClient2.StartCopyFromUri(uri, options), StorageError);
|
||||
EXPECT_THROW(blobClient2.StartCopyFromUri(uri, options), StorageException);
|
||||
options.SourceConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(blobClient2.StartCopyFromUri(uri, options));
|
||||
|
||||
@ -919,7 +920,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
blobClient2.SetTags(tags);
|
||||
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(blobClient2.StartCopyFromUri(uri, options), StorageError);
|
||||
EXPECT_THROW(blobClient2.StartCopyFromUri(uri, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(blobClient2.StartCopyFromUri(uri, options));
|
||||
}
|
||||
@ -928,13 +929,13 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
std::string leaseId = CreateUniqueLeaseId();
|
||||
Blobs::AcquireBlobLeaseOptions options;
|
||||
options.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.AcquireLease(leaseId, 60, options), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.AcquireLease(leaseId, 60, options), StorageException);
|
||||
options.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.AcquireLease(leaseId, 60, options));
|
||||
|
||||
Blobs::BreakBlobLeaseOptions options2;
|
||||
options2.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.BreakLease(options2), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.BreakLease(options2), StorageException);
|
||||
options2.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.BreakLease(options2));
|
||||
|
||||
@ -944,7 +945,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options3.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(appendBlobClient.Delete(options3));
|
||||
options3.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(appendBlobClient.Delete(options3), StorageError);
|
||||
EXPECT_THROW(appendBlobClient.Delete(options3), StorageException);
|
||||
}
|
||||
|
||||
blobName = RandomString();
|
||||
@ -956,7 +957,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
Blobs::CreatePageBlobOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(pageBlobClient.Create(contentSize, options), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.Create(contentSize, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(pageBlobClient.Create(contentSize, options));
|
||||
|
||||
@ -967,7 +968,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Blobs::UploadPageBlobPagesOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
content.Rewind();
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &content, options), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &content, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
content.Rewind();
|
||||
EXPECT_NO_THROW(pageBlobClient.UploadPages(0, &content, options));
|
||||
@ -978,7 +979,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Blobs::UploadPageBlobPagesFromUriOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(
|
||||
pageBlobClient.UploadPagesFromUri(0, uri, 0, contentSize, options), StorageError);
|
||||
pageBlobClient.UploadPagesFromUri(0, uri, 0, contentSize, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(pageBlobClient.UploadPagesFromUri(0, uri, 0, contentSize, options));
|
||||
}
|
||||
@ -986,7 +987,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
Blobs::ClearPageBlobPagesOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(pageBlobClient.ClearPages(0, contentSize, options), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.ClearPages(0, contentSize, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(pageBlobClient.ClearPages(0, contentSize, options));
|
||||
}
|
||||
@ -994,7 +995,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
Blobs::ResizePageBlobOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(pageBlobClient.Resize(contentSize, options), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.Resize(contentSize, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(pageBlobClient.Resize(contentSize, options));
|
||||
}
|
||||
@ -1002,7 +1003,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
Blobs::GetPageBlobPageRangesOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(pageBlobClient.GetPageRanges(options), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.GetPageRanges(options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(pageBlobClient.GetPageRanges(options));
|
||||
}
|
||||
@ -1017,7 +1018,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Blobs::UploadBlockBlobOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
content.Rewind();
|
||||
EXPECT_THROW(blockBlobClient.Upload(&content, options), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.Upload(&content, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
content.Rewind();
|
||||
EXPECT_NO_THROW(blockBlobClient.Upload(&content, options));
|
||||
@ -1033,7 +1034,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
Blobs::CommitBlockListOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(blockBlobClient.CommitBlockList(blockIds, options), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.CommitBlockList(blockIds, options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(blockBlobClient.CommitBlockList(blockIds, options));
|
||||
blockBlobClient.SetTags(tags);
|
||||
@ -1042,7 +1043,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
Blobs::GetBlockListOptions options;
|
||||
options.AccessConditions.TagConditions = failWhereExpression;
|
||||
EXPECT_THROW(blockBlobClient.GetBlockList(options), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.GetBlockList(options), StorageException);
|
||||
options.AccessConditions.TagConditions = successWhereExpression;
|
||||
EXPECT_NO_THROW(blockBlobClient.GetBlockList(options));
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
blobClient0.Delete();
|
||||
}
|
||||
catch (StorageError&)
|
||||
catch (StorageException&)
|
||||
{
|
||||
}
|
||||
auto blobClient = Blobs::AppendBlobClient(blobUri + sas);
|
||||
@ -220,7 +220,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
builder2.StartsOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(5));
|
||||
builder2.ExpiresOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(1));
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageException);
|
||||
}
|
||||
|
||||
// Without start time
|
||||
@ -236,7 +236,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
AccountSasBuilder builder2 = accountSasBuilder;
|
||||
builder2.IPRange = "1.1.1.1";
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageException);
|
||||
|
||||
// TODO: Add this test case back with support to contain IPv6 ranges when service is ready.
|
||||
// builder2.IPRange = "0.0.0.0-255.255.255.255";
|
||||
@ -249,7 +249,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
AccountSasBuilder builder2 = accountSasBuilder;
|
||||
builder2.Services = AccountSasServices::Files;
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageException);
|
||||
|
||||
builder2.Services = AccountSasServices::All;
|
||||
sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
@ -261,7 +261,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
AccountSasBuilder builder2 = accountSasBuilder;
|
||||
builder2.ResourceTypes = AccountSasResource::Service;
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageException);
|
||||
|
||||
auto serviceClient = Blobs::BlobServiceClient(serviceUri + sasToken);
|
||||
EXPECT_NO_THROW(serviceClient.ListBlobContainersSegment());
|
||||
@ -332,10 +332,10 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
builder2.StartsOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(5));
|
||||
builder2.ExpiresOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(1));
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageException);
|
||||
|
||||
auto sasToken2 = builder2.ToSasQueryParameters(userDelegationKey, accountName);
|
||||
EXPECT_THROW(verify_blob_create(sasToken2), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken2), StorageException);
|
||||
}
|
||||
|
||||
// Without start time
|
||||
@ -353,9 +353,9 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Blobs::BlobSasBuilder builder2 = blobSasBuilder;
|
||||
builder2.IPRange = "0.0.0.0-0.0.0.1";
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken), StorageException);
|
||||
auto sasToken2 = builder2.ToSasQueryParameters(userDelegationKey, accountName);
|
||||
EXPECT_THROW(verify_blob_create(sasToken2), StorageError);
|
||||
EXPECT_THROW(verify_blob_create(sasToken2), StorageException);
|
||||
|
||||
// TODO: Add this test case back with support to contain IPv6 ranges when service is ready.
|
||||
// builder2.IPRange = "0.0.0.0-255.255.255.255";
|
||||
|
||||
@ -320,7 +320,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
TEST_F(BlobServiceClientTest, Statistics)
|
||||
{
|
||||
EXPECT_THROW(m_blobServiceClient.GetStatistics(), StorageError);
|
||||
EXPECT_THROW(m_blobServiceClient.GetStatistics(), StorageException);
|
||||
|
||||
auto keyCredential
|
||||
= Details::ParseConnectionString(StandardStorageConnectionString()).KeyCredential;
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_FALSE(blobContentInfo->EncryptionKeySha256.HasValue());
|
||||
|
||||
blockBlobClient.Delete();
|
||||
EXPECT_THROW(blockBlobClient.Delete(), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.Delete(), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(BlockBlobClientTest, UploadDownload)
|
||||
@ -161,9 +161,9 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
Azure::Storage::Blobs::DownloadBlobOptions options;
|
||||
options.Offset = 0;
|
||||
EXPECT_THROW(blockBlobClient.Download(options), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.Download(options), StorageException);
|
||||
options.Length = 1;
|
||||
EXPECT_THROW(blockBlobClient.Download(options), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.Download(options), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(BlockBlobClientTest, CopyFromUri)
|
||||
@ -213,16 +213,16 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_EQ(ReadBodyStream(versionClient.Download()->BodyStream), m_blobContent);
|
||||
EXPECT_EQ(versionClient.GetProperties()->Metadata, m_blobUploadOptions.Metadata);
|
||||
auto emptyContent = Azure::Core::Http::MemoryBodyStream(nullptr, 0);
|
||||
EXPECT_THROW(snapshotClient.Upload(&emptyContent), StorageError);
|
||||
EXPECT_THROW(snapshotClient.SetMetadata({}), StorageError);
|
||||
EXPECT_THROW(snapshotClient.Upload(&emptyContent), StorageException);
|
||||
EXPECT_THROW(snapshotClient.SetMetadata({}), StorageException);
|
||||
EXPECT_NO_THROW(snapshotClient.SetAccessTier(Azure::Storage::Blobs::AccessTier::Cool));
|
||||
EXPECT_THROW(
|
||||
snapshotClient.SetHttpHeaders(Azure::Storage::Blobs::BlobHttpHeaders()), StorageError);
|
||||
EXPECT_THROW(versionClient.Upload(&emptyContent), StorageError);
|
||||
EXPECT_THROW(versionClient.SetMetadata({}), StorageError);
|
||||
snapshotClient.SetHttpHeaders(Azure::Storage::Blobs::BlobHttpHeaders()), StorageException);
|
||||
EXPECT_THROW(versionClient.Upload(&emptyContent), StorageException);
|
||||
EXPECT_THROW(versionClient.SetMetadata({}), StorageException);
|
||||
EXPECT_NO_THROW(versionClient.SetAccessTier(Azure::Storage::Blobs::AccessTier::Cool));
|
||||
EXPECT_THROW(
|
||||
versionClient.SetHttpHeaders(Azure::Storage::Blobs::BlobHttpHeaders()), StorageError);
|
||||
versionClient.SetHttpHeaders(Azure::Storage::Blobs::BlobHttpHeaders()), StorageException);
|
||||
|
||||
Azure::Storage::Blobs::CreateBlobSnapshotOptions options;
|
||||
options.Metadata = {{"snapshotkey1", "snapshotvalue1"}, {"snapshotkey2", "SNAPSHOTVALUE2"}};
|
||||
@ -372,7 +372,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
EXPECT_THROW(
|
||||
m_blockBlobClient->DownloadTo(downloadBuffer.data(), downloadBuffer.size(), options),
|
||||
StorageError);
|
||||
StorageException);
|
||||
}
|
||||
};
|
||||
auto testDownloadToFile = [](int concurrency,
|
||||
@ -428,7 +428,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
}
|
||||
else
|
||||
{
|
||||
EXPECT_THROW(m_blockBlobClient->DownloadTo(tempFilename, options), StorageError);
|
||||
EXPECT_THROW(m_blockBlobClient->DownloadTo(tempFilename, options), StorageException);
|
||||
}
|
||||
DeleteFile(tempFilename);
|
||||
};
|
||||
@ -515,7 +515,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
StandardStorageConnectionString(), m_containerName, RandomString());
|
||||
std::string emptyFilename = RandomString();
|
||||
EXPECT_THROW(blockBlobClient.UploadFrom(emptyFilename), std::runtime_error);
|
||||
EXPECT_THROW(blockBlobClient.Delete(), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.Delete(), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(BlockBlobClientTest, ConcurrentDownloadNonExistingBlob)
|
||||
@ -525,8 +525,9 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
std::vector<uint8_t> blobContent(100);
|
||||
std::string tempFilename = RandomString();
|
||||
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(blobContent.data(), blobContent.size()), StorageError);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename), StorageError);
|
||||
EXPECT_THROW(
|
||||
blockBlobClient.DownloadTo(blobContent.data(), blobContent.size()), StorageException);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename), StorageException);
|
||||
DeleteFile(tempFilename);
|
||||
}
|
||||
|
||||
@ -624,28 +625,28 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.Offset = 0;
|
||||
EXPECT_THROW(
|
||||
blockBlobClient.DownloadTo(emptyContent.data(), static_cast<std::size_t>(8_MB), options),
|
||||
StorageError);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageError);
|
||||
StorageException);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException);
|
||||
|
||||
options.Offset = 1;
|
||||
EXPECT_THROW(
|
||||
blockBlobClient.DownloadTo(emptyContent.data(), static_cast<std::size_t>(8_MB), options),
|
||||
StorageError);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageError);
|
||||
StorageException);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException);
|
||||
|
||||
options.Offset = 0;
|
||||
options.Length = 1;
|
||||
EXPECT_THROW(
|
||||
blockBlobClient.DownloadTo(emptyContent.data(), static_cast<std::size_t>(8_MB), options),
|
||||
StorageError);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageError);
|
||||
StorageException);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException);
|
||||
|
||||
options.Offset = 100;
|
||||
options.Length = 100;
|
||||
EXPECT_THROW(
|
||||
blockBlobClient.DownloadTo(emptyContent.data(), static_cast<std::size_t>(8_MB), options),
|
||||
StorageError);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageError);
|
||||
StorageException);
|
||||
EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException);
|
||||
DeleteFile(tempFilename);
|
||||
}
|
||||
}
|
||||
@ -746,7 +747,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
blockBlobClient.Download();
|
||||
}
|
||||
catch (StorageError& e)
|
||||
catch (StorageException& e)
|
||||
{
|
||||
exceptionCaught = true;
|
||||
EXPECT_EQ(e.StatusCode, Azure::Core::Http::HttpStatusCode::NotFound);
|
||||
|
||||
@ -18,7 +18,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
containerClient.Create();
|
||||
}
|
||||
catch (StorageError& e)
|
||||
catch (StorageException& e)
|
||||
{
|
||||
if (e.StatusCode != Azure::Core::Http::HttpStatusCode::Conflict)
|
||||
{
|
||||
|
||||
@ -57,7 +57,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_FALSE(blobContentInfo->EncryptionKeySha256.HasValue());
|
||||
|
||||
pageBlobClient.Delete();
|
||||
EXPECT_THROW(pageBlobClient.Delete(), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.Delete(), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, Resize)
|
||||
@ -227,7 +227,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
pageContent.Rewind();
|
||||
options.TransactionalContentMd5 = c_dummyMd5;
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &pageContent, options), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &pageContent, options), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, ContentCrc64)
|
||||
@ -248,7 +248,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
pageContent.Rewind();
|
||||
options.TransactionalContentCrc64 = c_dummyCrc64;
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &pageContent, options), StorageError);
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &pageContent, options), StorageException);
|
||||
}
|
||||
|
||||
}}} // namespace Azure::Storage::Test
|
||||
|
||||
@ -15,7 +15,7 @@ set(AZURE_STORAGE_COMMON_HEADER
|
||||
inc/azure/storage/common/shared_key_policy.hpp
|
||||
inc/azure/storage/common/storage_common.hpp
|
||||
inc/azure/storage/common/storage_credential.hpp
|
||||
inc/azure/storage/common/storage_error.hpp
|
||||
inc/azure/storage/common/storage_exception.hpp
|
||||
inc/azure/storage/common/storage_per_retry_policy.hpp
|
||||
inc/azure/storage/common/storage_retry_policy.hpp
|
||||
inc/azure/storage/common/version.hpp
|
||||
@ -30,7 +30,7 @@ set(AZURE_STORAGE_COMMON_SOURCE
|
||||
src/shared_key_policy.cpp
|
||||
src/storage_common.cpp
|
||||
src/storage_credential.cpp
|
||||
src/storage_error.cpp
|
||||
src/storage_exception.cpp
|
||||
src/storage_per_retry_policy.cpp
|
||||
src/storage_retry_policy.cpp
|
||||
src/xml_wrapper.cpp
|
||||
|
||||
@ -12,7 +12,7 @@ namespace Azure { namespace Storage {
|
||||
/**
|
||||
* @brief Specifies HTTP options for conditional requests based on modification time value.
|
||||
*/
|
||||
struct LastModifiedTimeAccessConditions
|
||||
struct ModifiedTimeConditions
|
||||
{
|
||||
/**
|
||||
* @brief Specify this header to perform the operation only if the resource has been
|
||||
|
||||
@ -25,8 +25,8 @@ namespace Azure { namespace Storage {
|
||||
}
|
||||
} // namespace Files
|
||||
|
||||
struct SharedKeyCredential
|
||||
{
|
||||
class SharedKeyCredential {
|
||||
public:
|
||||
explicit SharedKeyCredential(std::string accountName, std::string accountKey)
|
||||
: AccountName(std::move(accountName)), m_accountKey(std::move(accountKey))
|
||||
{
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Azure { namespace Storage {
|
||||
|
||||
struct StorageError : public std::runtime_error
|
||||
struct StorageException : public std::runtime_error
|
||||
{
|
||||
explicit StorageError(const std::string& message) : std::runtime_error(message) {}
|
||||
explicit StorageException(const std::string& message) : std::runtime_error(message) {}
|
||||
|
||||
Azure::Core::Http::HttpStatusCode StatusCode = Azure::Core::Http::HttpStatusCode::None;
|
||||
std::string ReasonPhrase;
|
||||
@ -23,7 +23,7 @@ namespace Azure { namespace Storage {
|
||||
std::string Message;
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> RawResponse;
|
||||
|
||||
static StorageError CreateFromResponse(
|
||||
static StorageException CreateFromResponse(
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> response);
|
||||
};
|
||||
}} // namespace Azure::Storage
|
||||
@ -10,7 +10,7 @@ struct _xmlTextReader;
|
||||
struct _xmlTextWriter;
|
||||
struct _xmlBuffer;
|
||||
|
||||
namespace Azure { namespace Storage {
|
||||
namespace Azure { namespace Storage { namespace Details {
|
||||
|
||||
enum class XmlNodeType
|
||||
{
|
||||
@ -59,4 +59,4 @@ namespace Azure { namespace Storage {
|
||||
_xmlTextWriter* m_writer = nullptr;
|
||||
};
|
||||
|
||||
}} // namespace Azure::Storage
|
||||
}}} // namespace Azure::Storage::Details
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "azure/storage/common/storage_error.hpp"
|
||||
#include "azure/storage/common/storage_exception.hpp"
|
||||
|
||||
#include "azure/core/http/policy.hpp"
|
||||
#include "azure/storage/common/constants.hpp"
|
||||
@ -12,7 +12,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
namespace Azure { namespace Storage {
|
||||
StorageError StorageError::CreateFromResponse(
|
||||
StorageException StorageException::CreateFromResponse(
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> response)
|
||||
{
|
||||
std::vector<uint8_t> bodyBuffer = std::move(response->GetBody());
|
||||
@ -40,8 +40,8 @@ namespace Azure { namespace Storage {
|
||||
if (response->GetHeaders().at(Details::c_HttpHeaderContentType).find("xml")
|
||||
!= std::string::npos)
|
||||
{
|
||||
auto xmlReader
|
||||
= XmlReader(reinterpret_cast<const char*>(bodyBuffer.data()), bodyBuffer.size());
|
||||
auto xmlReader = Details::XmlReader(
|
||||
reinterpret_cast<const char*>(bodyBuffer.data()), bodyBuffer.size());
|
||||
|
||||
enum class XmlTagName
|
||||
{
|
||||
@ -54,11 +54,11 @@ namespace Azure { namespace Storage {
|
||||
while (true)
|
||||
{
|
||||
auto node = xmlReader.Read();
|
||||
if (node.Type == XmlNodeType::End)
|
||||
if (node.Type == Details::XmlNodeType::End)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (node.Type == XmlNodeType::EndTag)
|
||||
else if (node.Type == Details::XmlNodeType::EndTag)
|
||||
{
|
||||
if (path.size() > 0)
|
||||
{
|
||||
@ -69,7 +69,7 @@ namespace Azure { namespace Storage {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (node.Type == XmlNodeType::StartTag)
|
||||
else if (node.Type == Details::XmlNodeType::StartTag)
|
||||
{
|
||||
if (std::strcmp(node.Name, "Error") == 0)
|
||||
{
|
||||
@ -84,7 +84,7 @@ namespace Azure { namespace Storage {
|
||||
path.emplace_back(XmlTagName::c_Message);
|
||||
}
|
||||
}
|
||||
else if (node.Type == XmlNodeType::Text)
|
||||
else if (node.Type == Details::XmlNodeType::Text)
|
||||
{
|
||||
if (path.size() == 2 && path[0] == XmlTagName::c_Error && path[1] == XmlTagName::c_Code)
|
||||
{
|
||||
@ -121,7 +121,7 @@ namespace Azure { namespace Storage {
|
||||
}
|
||||
}
|
||||
|
||||
StorageError result = StorageError(
|
||||
StorageException result = StorageException(
|
||||
std::to_string(static_cast<std::underlying_type<Azure::Core::Http::HttpStatusCode>::type>(
|
||||
httpStatusCode))
|
||||
+ " " + reasonPhrase + "\n" + message + "\nRequest ID: " + requestId);
|
||||
@ -9,7 +9,7 @@
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Azure { namespace Storage {
|
||||
namespace Azure { namespace Storage { namespace Details {
|
||||
|
||||
struct XmlGlobalInitializer
|
||||
{
|
||||
@ -174,4 +174,4 @@ namespace Azure { namespace Storage {
|
||||
return std::string(reinterpret_cast<const char*>(m_buffer->content), m_buffer->use);
|
||||
}
|
||||
|
||||
}} // namespace Azure::Storage
|
||||
}}} // namespace Azure::Storage::Details
|
||||
|
||||
@ -188,14 +188,14 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
/**
|
||||
* @brief Creates a new file, or updates the content of an existing file. Updating
|
||||
* an existing file overwrites any existing metadata on the file.
|
||||
* @param file A file containing the content to upload.
|
||||
* @param fileName A file containing the content to upload.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return Azure::Core::Response<UploadFileFromResult> containing the information returned when
|
||||
* uploading a file from a local file.
|
||||
* @remark This request is sent to blob endpoint.
|
||||
*/
|
||||
Azure::Core::Response<UploadFileFromResult> UploadFrom(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const UploadFileFromOptions& options = UploadFileFromOptions()) const;
|
||||
|
||||
/**
|
||||
@ -217,14 +217,14 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
/**
|
||||
* @brief Downloads a file or a file range from the service to a file using parallel
|
||||
* requests.
|
||||
* @param file A file path to write the downloaded content to.
|
||||
* @param fileName A file path to write the downloaded content to.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return Azure::Core::Response<DownloadFileToResult> containing the information returned when
|
||||
* downloading a file to a local file.
|
||||
* @remark This request is sent to blob endpoint.
|
||||
*/
|
||||
Azure::Core::Response<DownloadFileToResult> DownloadTo(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const DownloadFileToOptions& options = DownloadFileToOptions()) const;
|
||||
|
||||
/**
|
||||
|
||||
@ -77,15 +77,14 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
/**
|
||||
* @brief Specifies access conditions for a file system.
|
||||
*/
|
||||
struct FileSystemAccessConditions : public LastModifiedTimeAccessConditions,
|
||||
public LeaseAccessConditions
|
||||
struct FileSystemAccessConditions : public ModifiedTimeConditions, public LeaseAccessConditions
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Specifies access conditions for a path.
|
||||
*/
|
||||
struct PathAccessConditions : public LastModifiedTimeAccessConditions,
|
||||
struct PathAccessConditions : public ModifiedTimeConditions,
|
||||
public ETagAccessConditions,
|
||||
public LeaseAccessConditions
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#include "azure/storage/common/crypt.hpp"
|
||||
#include "azure/storage/common/json.hpp"
|
||||
#include "azure/storage/common/storage_common.hpp"
|
||||
#include "azure/storage/common/storage_error.hpp"
|
||||
#include "azure/storage/common/storage_exception.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@ -771,24 +771,23 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
static Azure::Storage::Files::DataLake::FileSystem FileSystemFromJson(
|
||||
const nlohmann::json& node)
|
||||
static Storage::Files::DataLake::FileSystem FileSystemFromJson(const nlohmann::json& node)
|
||||
{
|
||||
Azure::Storage::Files::DataLake::FileSystem result;
|
||||
Storage::Files::DataLake::FileSystem result;
|
||||
result.Name = node["name"].get<std::string>();
|
||||
result.LastModified = node["lastModified"].get<std::string>();
|
||||
result.ETag = node["etag"].get<std::string>();
|
||||
return result;
|
||||
}
|
||||
|
||||
static Azure::Storage::Files::DataLake::FileSystemList FileSystemListFromJson(
|
||||
static Storage::Files::DataLake::FileSystemList FileSystemListFromJson(
|
||||
const nlohmann::json& node)
|
||||
{
|
||||
Azure::Storage::Files::DataLake::FileSystemList result;
|
||||
Storage::Files::DataLake::FileSystemList result;
|
||||
for (const auto& element : node["filesystems"])
|
||||
{
|
||||
result.Filesystems.emplace_back(FileSystemFromJson(element));
|
||||
@ -1161,7 +1160,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1182,7 +1181,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1206,7 +1205,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1225,7 +1224,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1253,13 +1252,13 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
static Azure::Storage::Files::DataLake::Path PathFromJson(const nlohmann::json& node)
|
||||
static Storage::Files::DataLake::Path PathFromJson(const nlohmann::json& node)
|
||||
{
|
||||
Azure::Storage::Files::DataLake::Path result;
|
||||
Storage::Files::DataLake::Path result;
|
||||
result.Name = node["name"].get<std::string>();
|
||||
if (node.contains("isDirectory"))
|
||||
{
|
||||
@ -1277,10 +1276,9 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
return result;
|
||||
}
|
||||
|
||||
static Azure::Storage::Files::DataLake::PathList PathListFromJson(
|
||||
const nlohmann::json& node)
|
||||
static Storage::Files::DataLake::PathList PathListFromJson(const nlohmann::json& node)
|
||||
{
|
||||
Azure::Storage::Files::DataLake::PathList result;
|
||||
Storage::Files::DataLake::PathList result;
|
||||
for (const auto& element : node["paths"])
|
||||
{
|
||||
result.Paths.emplace_back(PathFromJson(element));
|
||||
@ -2549,7 +2547,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2599,7 +2597,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2740,7 +2738,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2849,7 +2847,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2873,7 +2871,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2894,7 +2892,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2923,24 +2921,24 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
static Azure::Storage::Files::DataLake::AclFailedEntry AclFailedEntryFromJson(
|
||||
static Storage::Files::DataLake::AclFailedEntry AclFailedEntryFromJson(
|
||||
const nlohmann::json& node)
|
||||
{
|
||||
Azure::Storage::Files::DataLake::AclFailedEntry result;
|
||||
Storage::Files::DataLake::AclFailedEntry result;
|
||||
result.Name = node["name"].get<std::string>();
|
||||
result.Type = node["type"].get<std::string>();
|
||||
result.ErrorMessage = node["errorMessage"].get<std::string>();
|
||||
return result;
|
||||
}
|
||||
|
||||
static Azure::Storage::Files::DataLake::SetAccessControlRecursiveResponse
|
||||
static Storage::Files::DataLake::SetAccessControlRecursiveResponse
|
||||
SetAccessControlRecursiveResponseFromJson(const nlohmann::json& node)
|
||||
{
|
||||
Azure::Storage::Files::DataLake::SetAccessControlRecursiveResponse result;
|
||||
Storage::Files::DataLake::SetAccessControlRecursiveResponse result;
|
||||
result.DirectoriesSuccessful = node["directoriesSuccessful"].get<int32_t>();
|
||||
result.FilesSuccessful = node["filesSuccessful"].get<int32_t>();
|
||||
result.FailureCount = node["failureCount"].get<int32_t>();
|
||||
@ -2986,7 +2984,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3017,7 +3015,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3038,7 +3036,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
else
|
||||
{
|
||||
unused(context);
|
||||
throw Azure::Storage::StorageError::CreateFromResponse(std::move(responsePtr));
|
||||
throw Storage::StorageException::CreateFromResponse(std::move(responsePtr));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -32,7 +32,7 @@ void DataLakeGettingStarted()
|
||||
{
|
||||
fileSystemClient.Create();
|
||||
}
|
||||
catch (Azure::Storage::StorageError& e)
|
||||
catch (Azure::Storage::StorageException& e)
|
||||
{
|
||||
if (e.ErrorCode != "ContainerAlreadyExists")
|
||||
{
|
||||
@ -104,7 +104,7 @@ void DataLakeGettingStarted()
|
||||
|
||||
std::cout << "Successfully finished sample." << std::endl;
|
||||
}
|
||||
catch (const Azure::Storage::StorageError& e)
|
||||
catch (const Azure::Storage::StorageException& e)
|
||||
{
|
||||
// Deal with the information when storage error is met.
|
||||
std::cout << "Error encountered when sending the request." << std::endl;
|
||||
|
||||
@ -334,7 +334,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadFileFromResult> FileClient::UploadFrom(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const UploadFileFromOptions& options) const
|
||||
{
|
||||
Blobs::UploadBlockBlobFromOptions blobOptions;
|
||||
@ -343,7 +343,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
blobOptions.HttpHeaders = FromDataLakeHttpHeaders(options.HttpHeaders);
|
||||
blobOptions.Metadata = options.Metadata;
|
||||
blobOptions.Concurrency = options.Concurrency;
|
||||
return m_blockBlobClient.UploadFrom(file, blobOptions);
|
||||
return m_blockBlobClient.UploadFrom(fileName, blobOptions);
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadFileFromResult> FileClient::UploadFrom(
|
||||
@ -378,10 +378,10 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
}
|
||||
|
||||
Azure::Core::Response<DownloadFileToResult> FileClient::DownloadTo(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const DownloadFileToOptions& options) const
|
||||
{
|
||||
auto result = m_blockBlobClient.DownloadTo(file, options);
|
||||
auto result = m_blockBlobClient.DownloadTo(fileName, options);
|
||||
DownloadFileToResult ret;
|
||||
ret.ETag = std::move(result->ETag);
|
||||
ret.LastModified = std::move(result->LastModified);
|
||||
|
||||
@ -55,7 +55,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::DeleteDirectoryOptions options1;
|
||||
options1.AccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(client.Delete(false, options1), StorageError);
|
||||
EXPECT_THROW(client.Delete(false, options1), StorageException);
|
||||
Files::DataLake::DeleteDirectoryOptions options2;
|
||||
options2.AccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
EXPECT_NO_THROW(client.Delete(false, options2));
|
||||
@ -75,7 +75,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::DeleteDirectoryOptions options1;
|
||||
options1.AccessConditions.IfNoneMatch = response->ETag;
|
||||
EXPECT_THROW(client.Delete(false, options1), StorageError);
|
||||
EXPECT_THROW(client.Delete(false, options1), StorageException);
|
||||
Files::DataLake::DeleteDirectoryOptions options2;
|
||||
options2.AccessConditions.IfMatch = response->ETag;
|
||||
EXPECT_NO_THROW(client.Delete(false, options2));
|
||||
@ -95,7 +95,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(client.Create());
|
||||
directoryClient.emplace_back(std::move(client));
|
||||
}
|
||||
EXPECT_THROW(rootDirClient.Delete(false), StorageError);
|
||||
EXPECT_THROW(rootDirClient.Delete(false), StorageException);
|
||||
EXPECT_NO_THROW(rootDirClient.Delete(true));
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
}
|
||||
for (const auto& client : directoryClients)
|
||||
{
|
||||
EXPECT_THROW(client.Delete(false), StorageError);
|
||||
EXPECT_THROW(client.Delete(false), StorageException);
|
||||
}
|
||||
for (const auto& newPath : newPaths)
|
||||
{
|
||||
@ -141,7 +141,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::RenameDirectoryOptions options1;
|
||||
options1.SourceAccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageError);
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageException);
|
||||
Files::DataLake::RenameDirectoryOptions options2;
|
||||
options2.SourceAccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
auto newPath = LowercaseRandomString();
|
||||
@ -163,7 +163,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::RenameDirectoryOptions options1;
|
||||
options1.SourceAccessConditions.IfNoneMatch = response->ETag;
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageError);
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageException);
|
||||
Files::DataLake::RenameDirectoryOptions options2;
|
||||
options2.SourceAccessConditions.IfMatch = response->ETag;
|
||||
auto newPath = LowercaseRandomString();
|
||||
@ -186,7 +186,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.DestinationFileSystem = LowercaseRandomString();
|
||||
for (auto& client : directoryClient)
|
||||
{
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options), StorageError);
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options), StorageException);
|
||||
EXPECT_NO_THROW(client.GetProperties());
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::FileDeleteOptions options1;
|
||||
options1.AccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(client.Delete(options1), StorageError);
|
||||
EXPECT_THROW(client.Delete(options1), StorageException);
|
||||
Files::DataLake::FileDeleteOptions options2;
|
||||
options2.AccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
EXPECT_NO_THROW(client.Delete(options2));
|
||||
@ -75,7 +75,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::FileDeleteOptions options1;
|
||||
options1.AccessConditions.IfNoneMatch = response->ETag;
|
||||
EXPECT_THROW(client.Delete(options1), StorageError);
|
||||
EXPECT_THROW(client.Delete(options1), StorageException);
|
||||
Files::DataLake::FileDeleteOptions options2;
|
||||
options2.AccessConditions.IfMatch = response->ETag;
|
||||
EXPECT_NO_THROW(client.Delete(options2));
|
||||
@ -103,7 +103,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
}
|
||||
for (const auto& client : fileClients)
|
||||
{
|
||||
EXPECT_THROW(client.Delete(), StorageError);
|
||||
EXPECT_THROW(client.Delete(), StorageException);
|
||||
}
|
||||
for (const auto& newPath : newPaths)
|
||||
{
|
||||
@ -124,7 +124,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::RenameFileOptions options1;
|
||||
options1.SourceAccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageError);
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageException);
|
||||
Files::DataLake::RenameFileOptions options2;
|
||||
options2.SourceAccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
auto newPath = LowercaseRandomString();
|
||||
@ -146,7 +146,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::RenameFileOptions options1;
|
||||
options1.SourceAccessConditions.IfNoneMatch = response->ETag;
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageError);
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options1), StorageException);
|
||||
Files::DataLake::RenameFileOptions options2;
|
||||
options2.SourceAccessConditions.IfMatch = response->ETag;
|
||||
auto newPath = LowercaseRandomString();
|
||||
@ -169,7 +169,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.DestinationFileSystem = LowercaseRandomString();
|
||||
for (auto& client : fileClient)
|
||||
{
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options), StorageError);
|
||||
EXPECT_THROW(client.Rename(LowercaseRandomString(), options), StorageException);
|
||||
EXPECT_NO_THROW(client.GetProperties());
|
||||
}
|
||||
}
|
||||
@ -356,7 +356,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = newFileClient->GetProperties();
|
||||
Files::DataLake::ReadFileOptions options1;
|
||||
options1.AccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(newFileClient->Read(options1), StorageError);
|
||||
EXPECT_THROW(newFileClient->Read(options1), StorageException);
|
||||
Files::DataLake::ReadFileOptions options2;
|
||||
options2.AccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
EXPECT_NO_THROW(result = newFileClient->Read(options2));
|
||||
@ -368,7 +368,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = newFileClient->GetProperties();
|
||||
Files::DataLake::ReadFileOptions options1;
|
||||
options1.AccessConditions.IfNoneMatch = response->ETag;
|
||||
EXPECT_THROW(newFileClient->Read(options1), StorageError);
|
||||
EXPECT_THROW(newFileClient->Read(options1), StorageException);
|
||||
Files::DataLake::ReadFileOptions options2;
|
||||
options2.AccessConditions.IfMatch = response->ETag;
|
||||
EXPECT_NO_THROW(result = newFileClient->Read(options2));
|
||||
@ -392,7 +392,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_THROW(
|
||||
client.ScheduleDeletion(
|
||||
Files::DataLake::ScheduleFileExpiryOriginType::RelativeToNow, options),
|
||||
StorageError);
|
||||
StorageException);
|
||||
options.TimeToExpireInMs = 1000;
|
||||
EXPECT_NO_THROW(client.ScheduleDeletion(
|
||||
Files::DataLake::ScheduleFileExpiryOriginType::RelativeToNow, options));
|
||||
@ -403,11 +403,11 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Files::DataLake::ScheduleFileDeletionOptions options;
|
||||
EXPECT_THROW(
|
||||
client.ScheduleDeletion(Files::DataLake::ScheduleFileExpiryOriginType::Absolute, options),
|
||||
StorageError);
|
||||
StorageException);
|
||||
options.TimeToExpireInMs = 1000;
|
||||
EXPECT_THROW(
|
||||
client.ScheduleDeletion(Files::DataLake::ScheduleFileExpiryOriginType::Absolute, options),
|
||||
StorageError);
|
||||
StorageException);
|
||||
options.ExpiresOn = "Tue, 29 Sep 2100 09:53:03 GMT";
|
||||
EXPECT_THROW(
|
||||
client.ScheduleDeletion(Files::DataLake::ScheduleFileExpiryOriginType::Absolute, options),
|
||||
|
||||
@ -123,7 +123,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = client.GetProperties();
|
||||
Files::DataLake::DeleteFileSystemOptions options1;
|
||||
options1.AccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(client.Delete(options1), StorageError);
|
||||
EXPECT_THROW(client.Delete(options1), StorageException);
|
||||
Files::DataLake::DeleteFileSystemOptions options2;
|
||||
options2.AccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
EXPECT_NO_THROW(client.Delete(options2));
|
||||
|
||||
@ -166,7 +166,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Files::DataLake::SetPathHttpHeadersOptions options1;
|
||||
options1.AccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(
|
||||
m_pathClient->SetHttpHeaders(GetInterestingHttpHeaders(), options1), StorageError);
|
||||
m_pathClient->SetHttpHeaders(GetInterestingHttpHeaders(), options1), StorageException);
|
||||
Files::DataLake::SetPathHttpHeadersOptions options2;
|
||||
options2.AccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
EXPECT_NO_THROW(m_pathClient->SetHttpHeaders(GetInterestingHttpHeaders(), options2));
|
||||
@ -178,7 +178,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Files::DataLake::SetPathHttpHeadersOptions options1;
|
||||
options1.AccessConditions.IfNoneMatch = response->ETag;
|
||||
EXPECT_THROW(
|
||||
m_pathClient->SetHttpHeaders(GetInterestingHttpHeaders(), options1), StorageError);
|
||||
m_pathClient->SetHttpHeaders(GetInterestingHttpHeaders(), options1), StorageException);
|
||||
Files::DataLake::SetPathHttpHeadersOptions options2;
|
||||
options2.AccessConditions.IfMatch = response->ETag;
|
||||
EXPECT_NO_THROW(m_pathClient->SetHttpHeaders(GetInterestingHttpHeaders(), options2));
|
||||
@ -213,7 +213,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = m_pathClient->GetProperties();
|
||||
Files::DataLake::SetPathAccessControlOptions options1;
|
||||
options1.AccessConditions.IfModifiedSince = response->LastModified;
|
||||
EXPECT_THROW(m_pathClient->SetAccessControl(acls, options1), StorageError);
|
||||
EXPECT_THROW(m_pathClient->SetAccessControl(acls, options1), StorageException);
|
||||
Files::DataLake::SetPathAccessControlOptions options2;
|
||||
options2.AccessConditions.IfUnmodifiedSince = response->LastModified;
|
||||
EXPECT_NO_THROW(m_pathClient->SetAccessControl(acls, options2));
|
||||
@ -225,7 +225,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto response = m_pathClient->GetProperties();
|
||||
Files::DataLake::SetPathAccessControlOptions options1;
|
||||
options1.AccessConditions.IfNoneMatch = response->ETag;
|
||||
EXPECT_THROW(m_pathClient->SetAccessControl(acls, options1), StorageError);
|
||||
EXPECT_THROW(m_pathClient->SetAccessControl(acls, options1), StorageException);
|
||||
Files::DataLake::SetPathAccessControlOptions options2;
|
||||
options2.AccessConditions.IfMatch = response->ETag;
|
||||
EXPECT_NO_THROW(m_pathClient->SetAccessControl(acls, options2));
|
||||
|
||||
@ -100,7 +100,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
fileClient0.Delete();
|
||||
}
|
||||
catch (StorageError&)
|
||||
catch (StorageException&)
|
||||
{
|
||||
}
|
||||
auto fileClient = Files::DataLake::FileClient(fileUri + sas);
|
||||
@ -112,7 +112,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
fileClient0.Delete();
|
||||
}
|
||||
catch (StorageError&)
|
||||
catch (StorageException&)
|
||||
{
|
||||
}
|
||||
std::string newFilename = RandomString();
|
||||
@ -340,10 +340,10 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
builder2.StartsOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(5));
|
||||
builder2.ExpiresOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(1));
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_file_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_file_create(sasToken), StorageException);
|
||||
|
||||
auto sasToken2 = builder2.ToSasQueryParameters(userDelegationKey, accountName);
|
||||
EXPECT_THROW(verify_file_create(sasToken2), StorageError);
|
||||
EXPECT_THROW(verify_file_create(sasToken2), StorageException);
|
||||
}
|
||||
|
||||
// Without start time
|
||||
@ -361,9 +361,9 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Files::DataLake::DataLakeSasBuilder builder2 = fileSasBuilder;
|
||||
builder2.IPRange = "0.0.0.0-0.0.0.1";
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verify_file_create(sasToken), StorageError);
|
||||
EXPECT_THROW(verify_file_create(sasToken), StorageException);
|
||||
auto sasToken2 = builder2.ToSasQueryParameters(userDelegationKey, accountName);
|
||||
EXPECT_THROW(verify_file_create(sasToken2), StorageError);
|
||||
EXPECT_THROW(verify_file_create(sasToken2), StorageException);
|
||||
|
||||
// TODO: Add this test case back with support to contain IPv6 ranges when service is ready.
|
||||
// builder2.IPRange = "0.0.0.0-255.255.255.255";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -135,13 +135,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
* @brief Downloads a file or a file range from the service to a memory buffer using parallel
|
||||
* requests.
|
||||
*
|
||||
* @param file A file path to write the downloaded content to.
|
||||
* @param fileName A file path to write the downloaded content to.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return Azure::Core::Response<DownloadFileToResult> containing the information of the
|
||||
* downloaded file/file range.
|
||||
*/
|
||||
Azure::Core::Response<DownloadFileToResult> DownloadTo(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const DownloadFileToOptions& options = DownloadFileToOptions()) const;
|
||||
|
||||
/**
|
||||
@ -162,12 +162,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
* @brief Creates a new file, or updates the content of an existing file. Updating
|
||||
* an existing file overwrites any existing metadata on the file.
|
||||
*
|
||||
* @param file A file containing the content to upload.
|
||||
* @param fileName A file containing the content to upload.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A UploadFileFromResult describing the state of the updated file.
|
||||
*/
|
||||
Azure::Core::Response<UploadFileFromResult> UploadFrom(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const UploadFileFromOptions& options = UploadFileFromOptions()) const;
|
||||
|
||||
/**
|
||||
|
||||
@ -678,7 +678,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
}
|
||||
|
||||
Azure::Core::Response<DownloadFileToResult> FileClient::DownloadTo(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const DownloadFileToOptions& options) const
|
||||
{
|
||||
// Just start downloading using an initial chunk. If it's a small file, we'll get the whole
|
||||
@ -703,7 +703,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
firstChunkOptions.Length = firstChunkLength;
|
||||
}
|
||||
|
||||
Storage::Details::FileWriter fileWriter(file);
|
||||
Storage::Details::FileWriter fileWriter(fileName);
|
||||
|
||||
auto firstChunk = Download(firstChunkOptions);
|
||||
|
||||
@ -898,10 +898,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadFileFromResult> FileClient::UploadFrom(
|
||||
const std::string& file,
|
||||
const std::string& fileName,
|
||||
const UploadFileFromOptions& options) const
|
||||
{
|
||||
Storage::Details::FileReader fileReader(file);
|
||||
Storage::Details::FileReader fileReader(fileName);
|
||||
|
||||
Details::ShareRestClient::File::CreateOptions protocolLayerOptions;
|
||||
protocolLayerOptions.XMsContentLength = fileReader.GetFileSize();
|
||||
|
||||
@ -296,7 +296,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
// options.BreakPeriod = 0;
|
||||
// shareSnapshot.BreakLease(options);
|
||||
|
||||
// EXPECT_THROW(m_shareClient->Delete(), StorageError);
|
||||
// EXPECT_THROW(m_shareClient->Delete(), StorageException);
|
||||
//}
|
||||
|
||||
TEST_F(FileShareClientTest, UnencodedDirectoryFileNameWorks)
|
||||
|
||||
@ -93,7 +93,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto name = RandomString(10);
|
||||
Files::Shares::DirectoryClient client = m_shareClient->GetDirectoryClient(name);
|
||||
EXPECT_NO_THROW(client.Create());
|
||||
EXPECT_THROW(client.Create(), StorageError);
|
||||
EXPECT_THROW(client.Create(), StorageException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
EXPECT_THROW(
|
||||
m_fileClient->DownloadTo(downloadBuffer.data(), downloadBuffer.size(), options),
|
||||
StorageError);
|
||||
StorageException);
|
||||
}
|
||||
};
|
||||
auto testDownloadToFile = [](int concurrency,
|
||||
@ -444,7 +444,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
}
|
||||
else
|
||||
{
|
||||
EXPECT_THROW(m_fileClient->DownloadTo(tempFilename, options), StorageError);
|
||||
EXPECT_THROW(m_fileClient->DownloadTo(tempFilename, options), StorageException);
|
||||
}
|
||||
DeleteFile(tempFilename);
|
||||
};
|
||||
@ -567,7 +567,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_NO_THROW(fileClient.UploadRange(0, &memBodyStream, uploadOptions));
|
||||
uploadOptions.TransactionalMd5 = invalidMd5String;
|
||||
memBodyStream.Rewind();
|
||||
EXPECT_THROW(fileClient.UploadRange(0, &memBodyStream, uploadOptions), StorageError);
|
||||
EXPECT_THROW(fileClient.UploadRange(0, &memBodyStream, uploadOptions), StorageException);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
builder2.StartsOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(5));
|
||||
builder2.ExpiresOn = ToIso8601(std::chrono::system_clock::now() - std::chrono::minutes(1));
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verifyFileRead(sasToken), StorageError);
|
||||
EXPECT_THROW(verifyFileRead(sasToken), StorageException);
|
||||
}
|
||||
|
||||
// Without start time
|
||||
@ -162,7 +162,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Files::Shares::ShareSasBuilder builder2 = fileSasBuilder;
|
||||
builder2.IPRange = "0.0.0.0-0.0.0.1";
|
||||
auto sasToken = builder2.ToSasQueryParameters(*keyCredential);
|
||||
EXPECT_THROW(verifyFileRead(sasToken), StorageError);
|
||||
EXPECT_THROW(verifyFileRead(sasToken), StorageException);
|
||||
|
||||
// TODO: Add this test case back with support to contain IPv6 ranges when service is ready.
|
||||
// builder2.IPRange = "0.0.0.0-255.255.255.255";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user