From 01ae3714f1846d16dc3696e4f4f28963eb1aa4d7 Mon Sep 17 00:00:00 2001 From: JinmingHu Date: Sat, 6 Mar 2021 16:26:34 +0800 Subject: [PATCH] return rawresponse for copy operation (#1807) * return rawresponse for copy operation * also for file copy * remove noexcept --- .../inc/azure/storage/blobs/blob_responses.hpp | 13 ++++++++----- sdk/storage/azure-storage-blobs/src/blob_client.cpp | 1 + .../azure-storage-blobs/src/page_blob_client.cpp | 1 + .../test/ut/block_blob_client_test.cpp | 1 + .../test/ut/page_blob_client_test.cpp | 1 + .../azure/storage/files/shares/share_responses.hpp | 13 ++++++++----- .../src/share_file_client.cpp | 1 + .../test/share_file_client_test.cpp | 1 + 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp index 3eb287ca5..f0cac62c8 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp @@ -87,11 +87,13 @@ namespace Azure { namespace Storage { namespace Blobs { * @return A pointer to #Azure::Core::Http::RawResponse. * @note Does not give up ownership of the RawResponse. */ - Azure::Core::Http::RawResponse* GetRawResponse() const override - { - // TODO: Fix to return the rawResponse - return nullptr; - } + Azure::Core::Http::RawResponse* GetRawResponse() const override { return m_rawResponse.get(); } + + StartCopyBlobOperation() = default; + + StartCopyBlobOperation(StartCopyBlobOperation&&) = default; + + StartCopyBlobOperation& operator=(StartCopyBlobOperation&&) = default; ~StartCopyBlobOperation() override {} @@ -109,6 +111,7 @@ namespace Azure { namespace Storage { namespace Blobs { std::chrono::milliseconds period, Azure::Core::Context& context) override; + std::unique_ptr m_rawResponse; std::shared_ptr m_blobClient; Models::GetBlobPropertiesResult m_pollResult; diff --git a/sdk/storage/azure-storage-blobs/src/blob_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_client.cpp index 6dbbadc41..b2c2158f5 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_client.cpp @@ -545,6 +545,7 @@ namespace Azure { namespace Storage { namespace Blobs { auto response = Details::BlobRestClient::Blob::StartCopyFromUri( context, *m_pipeline, m_blobUrl, protocolLayerOptions); StartCopyBlobOperation res; + res.m_rawResponse = response.ExtractRawResponse(); res.RequestId = std::move(response->RequestId); res.ETag = std::move(response->ETag); res.LastModified = std::move(response->LastModified); diff --git a/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp index a9b176e61..47d0e233b 100644 --- a/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp @@ -304,6 +304,7 @@ namespace Azure { namespace Storage { namespace Blobs { auto response = Details::BlobRestClient::PageBlob::StartCopyIncremental( context, *m_pipeline, m_blobUrl, protocolLayerOptions); StartCopyBlobOperation res; + res.m_rawResponse = response.ExtractRawResponse(); res.RequestId = std::move(response->RequestId); res.ETag = std::move(response->ETag); res.LastModified = std::move(response->LastModified); diff --git a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp index ee311df6c..5cb7ccaf2 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp @@ -205,6 +205,7 @@ namespace Azure { namespace Storage { namespace Test { { auto blobClient = m_blobContainerClient->GetBlobClient(RandomString()); auto res = blobClient.StartCopyFromUri(m_blockBlobClient->GetUrl()); + EXPECT_NE(res.GetRawResponse(), nullptr); EXPECT_FALSE(res.RequestId.empty()); EXPECT_TRUE(res.ETag.HasValue()); EXPECT_TRUE(IsValidTime(res.LastModified)); diff --git a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp index 0b194134a..8ea23ac47 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp @@ -150,6 +150,7 @@ namespace Azure { namespace Storage { namespace Test { Azure::Core::Http::Url sourceUri(m_pageBlobClient->WithSnapshot(snapshot).GetUrl()); sourceUri.AppendQueryParameters(GetSas()); auto copyInfo = pageBlobClient.StartCopyIncremental(sourceUri.GetAbsoluteUrl()); + EXPECT_NE(copyInfo.GetRawResponse(), nullptr); EXPECT_FALSE(copyInfo.RequestId.empty()); EXPECT_TRUE(copyInfo.ETag.HasValue()); EXPECT_TRUE(IsValidTime(copyInfo.LastModified)); diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp index a13e68f09..57a303d75 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp @@ -203,11 +203,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { * @return A pointer to #Azure::Core::Http::RawResponse. * @note Does not give up ownership of the RawResponse. */ - Azure::Core::Http::RawResponse* GetRawResponse() const override - { - // TODO: Fix to return the rawResponse - return nullptr; - } + Azure::Core::Http::RawResponse* GetRawResponse() const override { return m_rawResponse.get(); } + + StartCopyShareFileOperation() = default; + + StartCopyShareFileOperation(StartCopyShareFileOperation&&) = default; + + StartCopyShareFileOperation& operator=(StartCopyShareFileOperation&&) = default; ~StartCopyShareFileOperation() override {} @@ -225,6 +227,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { std::chrono::milliseconds period, Azure::Core::Context& context) override; + std::unique_ptr m_rawResponse; std::shared_ptr m_fileClient; Models::GetShareFilePropertiesResult m_pollResult; diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index ae77eccbd..d04c3b890 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -374,6 +374,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); StartCopyShareFileOperation res; + res.m_rawResponse = response.ExtractRawResponse(); res.RequestId = std::move(response->RequestId); res.ETag = std::move(response->ETag); res.LastModified = std::move(response->LastModified); diff --git a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp index 9b56f6e55..7764e4dc6 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp @@ -680,6 +680,7 @@ namespace Azure { namespace Storage { namespace Test { auto destFileClient = m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString(10)); auto copyOperation = destFileClient.StartCopy(fileClient.GetUrl()); + EXPECT_NE(copyOperation.GetRawResponse(), nullptr); EXPECT_FALSE(copyOperation.RequestId.empty()); EXPECT_TRUE(copyOperation.ETag.HasValue()); EXPECT_TRUE(IsValidTime(copyOperation.LastModified));