From 29f5e30ad36095abc72e7e85a736e148a1f13c89 Mon Sep 17 00:00:00 2001 From: JinmingHu Date: Thu, 23 Jul 2020 15:39:51 +0800 Subject: [PATCH] integrate TelemetryPolicy into Blob Service (#328) * integrate TelemetryPolicy into Blob Service * Also add telemetry support to ADLS Gen 2. Co-authored-by: Tank Tang --- sdk/storage/CMakeLists.txt | 170 +++++++++--------- sdk/storage/inc/blobs/append_blob_client.hpp | 3 +- sdk/storage/inc/blobs/blob_client.hpp | 2 +- .../inc/blobs/blob_container_client.hpp | 2 +- sdk/storage/inc/blobs/blob_options.hpp | 2 +- sdk/storage/inc/blobs/blob_service_client.hpp | 2 +- sdk/storage/inc/blobs/block_blob_client.hpp | 2 +- sdk/storage/inc/blobs/page_blob_client.hpp | 2 +- .../protocol/blob_rest_client.hpp | 0 sdk/storage/inc/common/constants.hpp | 4 + sdk/storage/inc/common/storage_version.hpp | 12 ++ .../inc/datalake/datalake_responses.hpp | 2 +- sdk/storage/sample/CMakeLists.txt | 2 +- sdk/storage/src/blobs/blob_client.cpp | 7 + .../src/blobs/blob_container_client.cpp | 7 + sdk/storage/src/blobs/blob_service_client.cpp | 7 + sdk/storage/src/datalake/directory_client.cpp | 7 + sdk/storage/src/datalake/file_client.cpp | 7 + .../src/datalake/file_system_client.cpp | 9 +- sdk/storage/src/datalake/path_client.cpp | 7 + sdk/storage/src/datalake/service_client.cpp | 9 +- sdk/storage/test/CMakeLists.txt | 7 +- sdk/storage/test/main.cpp | 10 -- 23 files changed, 175 insertions(+), 107 deletions(-) rename sdk/storage/inc/blobs/{internal => }/protocol/blob_rest_client.hpp (100%) create mode 100644 sdk/storage/inc/common/storage_version.hpp delete mode 100644 sdk/storage/test/main.cpp diff --git a/sdk/storage/CMakeLists.txt b/sdk/storage/CMakeLists.txt index c5fb12a2f..56e9bc008 100644 --- a/sdk/storage/CMakeLists.txt +++ b/sdk/storage/CMakeLists.txt @@ -10,18 +10,80 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) option(BUILD_STORAGE_SAMPLES "Build sample codes" ON) -set (AZURE_STORAGE_BLOB_HEADER +if(MSVC) + add_compile_definitions(NOMINMAX) +endif() + +set(AZURE_STORAGE_COMMON_HEADER + inc/common/access_conditions.hpp + inc/common/common_headers_request_policy.hpp + inc/common/concurrent_transfer.hpp inc/common/constants.hpp + inc/common/crypt.hpp + inc/common/file_io.hpp + inc/common/shared_key_policy.hpp inc/common/storage_common.hpp inc/common/storage_credential.hpp + inc/common/storage_error.hpp inc/common/storage_uri_builder.hpp - inc/common/common_headers_request_policy.hpp - inc/common/shared_key_policy.hpp - inc/common/crypt.hpp + inc/common/storage_version.hpp inc/common/xml_wrapper.hpp - inc/common/concurrent_transfer.hpp - inc/common/file_io.hpp - inc/common/access_conditions.hpp +) + +set(AZURE_STORAGE_COMMON_SOURCE + src/common/common_headers_request_policy.cpp + src/common/crypt.cpp + src/common/file_io.cpp + src/common/shared_key_policy.cpp + src/common/storage_credential.cpp + src/common/storage_error.cpp + src/common/storage_uri_builder.cpp + src/common/xml_wrapper.cpp +) + +add_library(azure-storage-common ${AZURE_STORAGE_COMMON_HEADER} ${AZURE_STORAGE_COMMON_SOURCE}) + +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads REQUIRED) +find_package(LibXml2 REQUIRED) + +target_include_directories(azure-storage-common PUBLIC ${LIBXML2_INCLUDE_DIR} $ $ $) +target_link_libraries(azure-storage-common Threads::Threads azure-core ${LIBXML2_LIBRARIES}) + +if(MSVC) + target_link_libraries(azure-storage-common bcrypt) + # C28020 and C28204 are introduced by nlohmann/json + target_compile_options(azure-storage-common PUBLIC /wd28204 /wd28020) +else() + find_package(OpenSSL REQUIRED) + target_link_libraries(azure-storage-common OpenSSL::SSL OpenSSL::Crypto) +endif() + +file(READ "inc/common/storage_version.hpp" VERSION_FILE_CONTENT) + +string(REGEX MATCH "CommonComponentVersion = \"([^\"]*)" _ ${VERSION_FILE_CONTENT}) +if ("${CMAKE_MATCH_1}" STREQUAL "") + message(FATAL_ERROR "Failed to get Common component version") +endif() +set(COMMON_COMPONENT_VERSION ${CMAKE_MATCH_1}) +message("Common component version ${COMMON_COMPONENT_VERSION}") + +string(REGEX MATCH "BlobServiceVersion = \"([^\"]*)" _ ${VERSION_FILE_CONTENT}) +if ("${CMAKE_MATCH_1}" STREQUAL "") + message(FATAL_ERROR "Failed to get Blob service version") +endif() +set(BLOB_SERVICE_VERSION ${CMAKE_MATCH_1}) +message("Blob service version ${BLOB_SERVICE_VERSION}") + +string(REGEX MATCH "DataLakeServiceVersion = \"([^\"]*)" _ ${VERSION_FILE_CONTENT}) +if ("${CMAKE_MATCH_1}" STREQUAL "") + message(FATAL_ERROR "Failed to get DataLake service version") +endif() +set(DATALAKE_SERVICE_VERSION ${CMAKE_MATCH_1}) +message("DataLake service version ${DATALAKE_SERVICE_VERSION}") + +set (AZURE_STORAGE_BLOB_HEADER inc/blobs/blob.hpp inc/blobs/blob_service_client.hpp inc/blobs/blob_container_client.hpp @@ -30,21 +92,23 @@ set (AZURE_STORAGE_BLOB_HEADER inc/blobs/page_blob_client.hpp inc/blobs/append_blob_client.hpp inc/blobs/blob_options.hpp - inc/blobs/internal/protocol/blob_rest_client.hpp + inc/blobs/protocol/blob_rest_client.hpp ) +set (AZURE_STORAGE_BLOB_SOURCE + src/blobs/blob_service_client.cpp + src/blobs/blob_container_client.cpp + src/blobs/blob_client.cpp + src/blobs/block_blob_client.cpp + src/blobs/page_blob_client.cpp + src/blobs/append_blob_client.cpp +) + +add_library(azure-storage-blob ${AZURE_STORAGE_BLOB_HEADER} ${AZURE_STORAGE_BLOB_SOURCE}) +target_link_libraries(azure-storage-blob azure-storage-common) + set (AZURE_STORAGE_DATALAKE_HEADER - inc/common/storage_common.hpp - inc/common/xml_wrapper.hpp - inc/common/storage_error.hpp - inc/common/storage_credential.hpp - inc/common/storage_uri_builder.hpp - inc/common/common_headers_request_policy.hpp - inc/common/shared_key_policy.hpp - inc/common/crypt.hpp - inc/common/constants.hpp inc/datalake/datalake.hpp - inc/blobs/internal/protocol/blob_rest_client.hpp inc/datalake/protocol/datalake_rest_client.hpp inc/datalake/datalake_responses.hpp inc/datalake/datalake_options.hpp @@ -56,25 +120,7 @@ set (AZURE_STORAGE_DATALAKE_HEADER inc/datalake/directory_client.hpp ) -set (AZURE_STORAGE_BLOB_SOURCE - src/common/storage_credential.cpp - src/common/storage_uri_builder.cpp - src/common/common_headers_request_policy.cpp - src/common/shared_key_policy.cpp - src/common/storage_error.cpp - src/common/crypt.cpp - src/common/xml_wrapper.cpp - src/common/file_io.cpp - src/blobs/blob_service_client.cpp - src/blobs/blob_container_client.cpp - src/blobs/blob_client.cpp - src/blobs/block_blob_client.cpp - src/blobs/page_blob_client.cpp - src/blobs/append_blob_client.cpp -) - set (AZURE_STORAGE_DATALAKE_SOURCE - src/common/storage_credential.cpp src/datalake/service_client.cpp src/datalake/file_system_client.cpp src/datalake/path_client.cpp @@ -84,48 +130,12 @@ set (AZURE_STORAGE_DATALAKE_SOURCE src/datalake/datalake_responses.cpp ) -set(AZURE_STORAGE_HEADER - ${AZURE_STORAGE_BLOB_HEADER} - ${AZURE_STORAGE_DATALAKE_HEADER} -) +add_library(azure-storage-file-datalake ${AZURE_STORAGE_DATALAKE_HEADER} ${AZURE_STORAGE_DATALAKE_SOURCE}) +target_link_libraries(azure-storage-file-datalake azure-storage-blob) -set(AZURE_STORAGE_SOURCE - ${AZURE_STORAGE_BLOB_SOURCE} - ${AZURE_STORAGE_DATALAKE_SOURCE} -) - -add_library(azure-storage ${AZURE_STORAGE_HEADER} ${AZURE_STORAGE_SOURCE}) - -set(CMAKE_THREAD_PREFER_PTHREAD TRUE) -set(THREADS_PREFER_PTHREAD_FLAG TRUE) -find_package(Threads REQUIRED) - -find_package(LibXml2 REQUIRED) - -target_include_directories(azure-storage PUBLIC ${LIBXML2_INCLUDE_DIR} $ $ $) - -target_link_libraries(azure-storage Threads::Threads azure-core ${LIBXML2_LIBRARIES}) - -if(MSVC) - target_link_libraries(azure-storage bcrypt) - target_compile_definitions(azure-storage PRIVATE NOMINMAX) - # C28020 and C28204 are introduced by nlohmann/json - target_compile_options(azure-storage PUBLIC /wd28204 /wd28020) -else() - find_package(OpenSSL REQUIRED) - target_link_libraries(azure-storage OpenSSL::SSL OpenSSL::Crypto) -endif() - -# Set version numbers centralized -set(AZURE_STORAGE_VERSION_MAJOR 0) -set(AZURE_STORAGE_VERSION_MINOR 1) -set(AZURE_STORAGE_VERSION_REVISION 0) - -#install(DIRECTORY include/ DESTINATION include) -#install(TARGETS azure-storage -# ARCHIVE DESTINATION lib -# LIBRARY DESTINATION lib -# RUNTIME DESTINATION bin) +add_library(azure::storage::common ALIAS azure-storage-common) +add_library(azure::storage::blob ALIAS azure-storage-blob) +add_library(azure::storage::file::datalake ALIAS azure-storage-file-datalake) if(BUILD_STORAGE_SAMPLES) add_subdirectory(sample) @@ -135,7 +145,5 @@ if(BUILD_TESTING) add_subdirectory(test) endif() -# make sure that users can consume the project as a library. -add_library (azure::storage ALIAS azure-storage) - -generate_documentation(azure-storage 1.0.0-preview.1) \ No newline at end of file +# TODO: eng/sys teams is going to fix this +generate_documentation(azure-storage 1.0.0-preview.1) diff --git a/sdk/storage/inc/blobs/append_blob_client.hpp b/sdk/storage/inc/blobs/append_blob_client.hpp index b103f859d..b11235ba1 100644 --- a/sdk/storage/inc/blobs/append_blob_client.hpp +++ b/sdk/storage/inc/blobs/append_blob_client.hpp @@ -7,8 +7,7 @@ #include "blobs/blob_client.hpp" #include "common/storage_credential.hpp" #include "credentials/credentials.hpp" -#include "credentials/policy/policies.hpp" -#include "internal/protocol/blob_rest_client.hpp" +#include "protocol/blob_rest_client.hpp" #include diff --git a/sdk/storage/inc/blobs/blob_client.hpp b/sdk/storage/inc/blobs/blob_client.hpp index e950f5daa..41d4a7b75 100644 --- a/sdk/storage/inc/blobs/blob_client.hpp +++ b/sdk/storage/inc/blobs/blob_client.hpp @@ -7,7 +7,7 @@ #include "common/storage_credential.hpp" #include "common/storage_uri_builder.hpp" #include "credentials/credentials.hpp" -#include "internal/protocol/blob_rest_client.hpp" +#include "protocol/blob_rest_client.hpp" #include #include diff --git a/sdk/storage/inc/blobs/blob_container_client.hpp b/sdk/storage/inc/blobs/blob_container_client.hpp index dc73dc973..9d955a261 100644 --- a/sdk/storage/inc/blobs/blob_container_client.hpp +++ b/sdk/storage/inc/blobs/blob_container_client.hpp @@ -8,7 +8,7 @@ #include "common/storage_credential.hpp" #include "common/storage_uri_builder.hpp" #include "credentials/credentials.hpp" -#include "internal/protocol/blob_rest_client.hpp" +#include "protocol/blob_rest_client.hpp" #include #include diff --git a/sdk/storage/inc/blobs/blob_options.hpp b/sdk/storage/inc/blobs/blob_options.hpp index 6d08c68ed..cc14cfaa8 100644 --- a/sdk/storage/inc/blobs/blob_options.hpp +++ b/sdk/storage/inc/blobs/blob_options.hpp @@ -4,7 +4,7 @@ #pragma once #include "common/access_conditions.hpp" -#include "internal/protocol/blob_rest_client.hpp" +#include "protocol/blob_rest_client.hpp" #include #include diff --git a/sdk/storage/inc/blobs/blob_service_client.hpp b/sdk/storage/inc/blobs/blob_service_client.hpp index 6d9f0c9c1..114359589 100644 --- a/sdk/storage/inc/blobs/blob_service_client.hpp +++ b/sdk/storage/inc/blobs/blob_service_client.hpp @@ -8,7 +8,7 @@ #include "common/storage_credential.hpp" #include "common/storage_uri_builder.hpp" #include "credentials/credentials.hpp" -#include "internal/protocol/blob_rest_client.hpp" +#include "protocol/blob_rest_client.hpp" #include #include diff --git a/sdk/storage/inc/blobs/block_blob_client.hpp b/sdk/storage/inc/blobs/block_blob_client.hpp index ac5d39b73..f8b1f7b1e 100644 --- a/sdk/storage/inc/blobs/block_blob_client.hpp +++ b/sdk/storage/inc/blobs/block_blob_client.hpp @@ -7,7 +7,7 @@ #include "blobs/blob_client.hpp" #include "common/storage_credential.hpp" #include "credentials/credentials.hpp" -#include "internal/protocol/blob_rest_client.hpp" +#include "protocol/blob_rest_client.hpp" #include #include diff --git a/sdk/storage/inc/blobs/page_blob_client.hpp b/sdk/storage/inc/blobs/page_blob_client.hpp index c84826527..06c39d687 100644 --- a/sdk/storage/inc/blobs/page_blob_client.hpp +++ b/sdk/storage/inc/blobs/page_blob_client.hpp @@ -7,7 +7,7 @@ #include "blobs/blob_client.hpp" #include "common/storage_credential.hpp" #include "credentials/credentials.hpp" -#include "internal/protocol/blob_rest_client.hpp" +#include "protocol/blob_rest_client.hpp" #include diff --git a/sdk/storage/inc/blobs/internal/protocol/blob_rest_client.hpp b/sdk/storage/inc/blobs/protocol/blob_rest_client.hpp similarity index 100% rename from sdk/storage/inc/blobs/internal/protocol/blob_rest_client.hpp rename to sdk/storage/inc/blobs/protocol/blob_rest_client.hpp diff --git a/sdk/storage/inc/common/constants.hpp b/sdk/storage/inc/common/constants.hpp index 01a8cc7cc..704d02f94 100644 --- a/sdk/storage/inc/common/constants.hpp +++ b/sdk/storage/inc/common/constants.hpp @@ -5,6 +5,10 @@ #pragma once namespace Azure { namespace Storage { namespace Details { + constexpr static const char* c_BlobServicePackageName = "storageblob"; + constexpr static const char* c_DatalakeServicePackageName = "storagedatalake"; + constexpr static const char* c_FileServicePackageName = "storagefile"; + constexpr static const char* c_QueueServicePackageName = "storagequeue"; constexpr static const char* c_HttpQuerySnapshot = "snapshot"; constexpr static const char* c_HttpQueryVersionId = "versionid"; constexpr static const char* c_StorageScope = "https://storage.azure.com/.default"; diff --git a/sdk/storage/inc/common/storage_version.hpp b/sdk/storage/inc/common/storage_version.hpp new file mode 100644 index 000000000..c971169b5 --- /dev/null +++ b/sdk/storage/inc/common/storage_version.hpp @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +#pragma once + +namespace Azure { namespace Storage { + + constexpr static const char* CommonComponentVersion = "1.0.0-private.beta.1"; + constexpr static const char* BlobServiceVersion = "1.0.0-private.beta.1"; + constexpr static const char* DataLakeServiceVersion = "1.0.0-private.beta.1"; + +}} // namespace Azure::Storage diff --git a/sdk/storage/inc/datalake/datalake_responses.hpp b/sdk/storage/inc/datalake/datalake_responses.hpp index 7f7c39cf1..4fc0ebc72 100644 --- a/sdk/storage/inc/datalake/datalake_responses.hpp +++ b/sdk/storage/inc/datalake/datalake_responses.hpp @@ -3,7 +3,7 @@ #pragma once -#include "blobs/internal/protocol/blob_rest_client.hpp" +#include "blobs/protocol/blob_rest_client.hpp" #include "protocol/datalake_rest_client.hpp" namespace Azure { namespace Storage { namespace Files { namespace DataLake { diff --git a/sdk/storage/sample/CMakeLists.txt b/sdk/storage/sample/CMakeLists.txt index c29b3b67d..25a86ab10 100644 --- a/sdk/storage/sample/CMakeLists.txt +++ b/sdk/storage/sample/CMakeLists.txt @@ -11,4 +11,4 @@ add_executable ( datalake_getting_started.cpp ) -target_link_libraries(azure-storage-sample PRIVATE azure-storage) +target_link_libraries(azure-storage-sample azure::storage::blob azure::storage::file::datalake) diff --git a/sdk/storage/src/blobs/blob_client.cpp b/sdk/storage/src/blobs/blob_client.cpp index 301117e38..0e5352994 100644 --- a/sdk/storage/src/blobs/blob_client.cpp +++ b/sdk/storage/src/blobs/blob_client.cpp @@ -12,6 +12,7 @@ #include "common/file_io.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "http/curl/curl.hpp" @@ -45,6 +46,8 @@ namespace Azure { namespace Storage { namespace Blobs { : m_blobUrl(blobUri) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -69,6 +72,8 @@ namespace Azure { namespace Storage { namespace Blobs { : m_blobUrl(blobUri) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -92,6 +97,8 @@ namespace Azure { namespace Storage { namespace Blobs { : m_blobUrl(blobUri) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/src/blobs/blob_container_client.cpp b/sdk/storage/src/blobs/blob_container_client.cpp index 450001077..8988a3924 100644 --- a/sdk/storage/src/blobs/blob_container_client.cpp +++ b/sdk/storage/src/blobs/blob_container_client.cpp @@ -10,6 +10,7 @@ #include "common/constants.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "http/curl/curl.hpp" @@ -42,6 +43,8 @@ namespace Azure { namespace Storage { namespace Blobs { : BlobContainerClient(containerUri, options) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -66,6 +69,8 @@ namespace Azure { namespace Storage { namespace Blobs { : BlobContainerClient(containerUri, options) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -91,6 +96,8 @@ namespace Azure { namespace Storage { namespace Blobs { : m_containerUrl(containerUri) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/src/blobs/blob_service_client.cpp b/sdk/storage/src/blobs/blob_service_client.cpp index b0d4d0f06..8d7df2749 100644 --- a/sdk/storage/src/blobs/blob_service_client.cpp +++ b/sdk/storage/src/blobs/blob_service_client.cpp @@ -7,6 +7,7 @@ #include "common/constants.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "http/curl/curl.hpp" @@ -37,6 +38,8 @@ namespace Azure { namespace Storage { namespace Blobs { : m_serviceUrl(serviceUri) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -61,6 +64,8 @@ namespace Azure { namespace Storage { namespace Blobs { : m_serviceUrl(serviceUri) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -86,6 +91,8 @@ namespace Azure { namespace Storage { namespace Blobs { : m_serviceUrl(serviceUri) { std::vector> policies; + policies.emplace_back(std::make_unique( + Details::c_BlobServicePackageName, BlobServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/src/datalake/directory_client.cpp b/sdk/storage/src/datalake/directory_client.cpp index 9d95b2e65..de986d0a9 100644 --- a/sdk/storage/src/datalake/directory_client.cpp +++ b/sdk/storage/src/datalake/directory_client.cpp @@ -8,6 +8,7 @@ #include "common/crypt.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "datalake/datalake_utilities.hpp" #include "http/curl/curl.hpp" @@ -46,6 +47,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { : PathClient(directoryUri, credential, options) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -70,6 +73,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { : PathClient(directoryUri, credential, options) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -95,6 +100,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { : PathClient(directoryUri, options) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/src/datalake/file_client.cpp b/sdk/storage/src/datalake/file_client.cpp index 442cfe546..3fdc89db9 100644 --- a/sdk/storage/src/datalake/file_client.cpp +++ b/sdk/storage/src/datalake/file_client.cpp @@ -8,6 +8,7 @@ #include "common/crypt.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "datalake/datalake_utilities.hpp" #include "http/curl/curl.hpp" @@ -125,6 +126,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { m_blockBlobClient(m_blobClient.GetBlockBlobClient()) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -150,6 +153,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { m_blockBlobClient(m_blobClient.GetBlockBlobClient()) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -173,6 +178,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { : PathClient(fileUri, options), m_blockBlobClient(m_blobClient.GetBlockBlobClient()) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/src/datalake/file_system_client.cpp b/sdk/storage/src/datalake/file_system_client.cpp index cd2e077b2..f4cb25a2d 100644 --- a/sdk/storage/src/datalake/file_system_client.cpp +++ b/sdk/storage/src/datalake/file_system_client.cpp @@ -3,12 +3,13 @@ #include "datalake/file_system_client.hpp" -#include "blobs/internal/protocol/blob_rest_client.hpp" +#include "blobs/protocol/blob_rest_client.hpp" #include "common/common_headers_request_policy.hpp" #include "common/constants.hpp" #include "common/crypt.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "datalake/datalake_utilities.hpp" #include "datalake/directory_client.hpp" @@ -66,6 +67,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -94,6 +97,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { GetBlobContainerClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -122,6 +127,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { GetBlobContainerClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/src/datalake/path_client.cpp b/sdk/storage/src/datalake/path_client.cpp index 7618c8e23..bf3ae3754 100644 --- a/sdk/storage/src/datalake/path_client.cpp +++ b/sdk/storage/src/datalake/path_client.cpp @@ -8,6 +8,7 @@ #include "common/crypt.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "datalake/datalake_utilities.hpp" #include "http/curl/curl.hpp" @@ -106,6 +107,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { m_blobClient(Details::GetBlobUriFromUri(pathUri), credential, GetBlobClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -131,6 +134,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { m_blobClient(Details::GetBlobUriFromUri(pathUri), credential, GetBlobClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -155,6 +160,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { m_blobClient(Details::GetBlobUriFromUri(pathUri), GetBlobClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/src/datalake/service_client.cpp b/sdk/storage/src/datalake/service_client.cpp index 47c212d8e..4e5537f2f 100644 --- a/sdk/storage/src/datalake/service_client.cpp +++ b/sdk/storage/src/datalake/service_client.cpp @@ -3,12 +3,13 @@ #include "datalake/service_client.hpp" -#include "blobs/internal/protocol/blob_rest_client.hpp" +#include "blobs/protocol/blob_rest_client.hpp" #include "common/common_headers_request_policy.hpp" #include "common/constants.hpp" #include "common/shared_key_policy.hpp" #include "common/storage_common.hpp" #include "common/storage_credential.hpp" +#include "common/storage_version.hpp" #include "credentials/policy/policies.hpp" #include "datalake/datalake_utilities.hpp" #include "datalake/file_system_client.hpp" @@ -73,6 +74,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { GetBlobServiceClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -100,6 +103,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { GetBlobServiceClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); @@ -125,6 +130,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { GetBlobServiceClientOptions(options)) { std::vector> policies; + policies.emplace_back(std::make_unique( + Azure::Storage::Details::c_DatalakeServicePackageName, DataLakeServiceVersion)); for (const auto& p : options.PerOperationPolicies) { policies.emplace_back(p->Clone()); diff --git a/sdk/storage/test/CMakeLists.txt b/sdk/storage/test/CMakeLists.txt index 92adf6416..56e1b5ffb 100644 --- a/sdk/storage/test/CMakeLists.txt +++ b/sdk/storage/test/CMakeLists.txt @@ -29,15 +29,14 @@ add_executable ( datalake/directory_client_test.hpp datalake/directory_client_test.cpp common/bearer_token_test.cpp - main.cpp - ) +) target_include_directories(azure-storage-test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(azure-storage-test PRIVATE azure-storage) +target_link_libraries(azure-storage-test PUBLIC azure::storage::blob azure::storage::file::datalake) if (MSVC) - target_compile_options(azure-storage-test PRIVATE /wd6326 /wd26495 /wd26812) + target_compile_options(azure-storage-test PUBLIC /wd6326 /wd26495 /wd26812) endif() add_gtest(azure-storage-test) diff --git a/sdk/storage/test/main.cpp b/sdk/storage/test/main.cpp deleted file mode 100644 index 19e7500cb..000000000 --- a/sdk/storage/test/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -#include "gtest/gtest.h" - -int main(int argc, char** argv) -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -}