diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index a5e310919..2556d99e6 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -6,6 +6,7 @@ ### Breaking Changes +- Renamed `tables_clients.hpp` to `table_client.hpp` and split `TableServiceClient` into its own file, `table_service_client.hpp`. - Removed the `TablesAudience` field from `TableClientOptions` since it is not required. - Removed ServiceVersion type and changed the ApiVersion field within `TableClientOptions` to be std::string. - Removed the `TableServiceClient` constructor that only accepts one defaulted options parameter. diff --git a/sdk/tables/azure-data-tables/CMakeLists.txt b/sdk/tables/azure-data-tables/CMakeLists.txt index 96a55c790..9ac8e4607 100644 --- a/sdk/tables/azure-data-tables/CMakeLists.txt +++ b/sdk/tables/azure-data-tables/CMakeLists.txt @@ -49,7 +49,8 @@ set( inc/azure/data/tables/models.hpp inc/azure/data/tables/rtti.hpp inc/azure/data/tables.hpp - inc/azure/data/tables/tables_clients.hpp + inc/azure/data/tables/table_client.hpp + inc/azure/data/tables/table_service_client.hpp inc/azure/data/tables/tables_sas_builder.hpp ) diff --git a/sdk/tables/azure-data-tables/inc/azure/data/tables.hpp b/sdk/tables/azure-data-tables/inc/azure/data/tables.hpp index 6d3680ce3..e61964580 100644 --- a/sdk/tables/azure-data-tables/inc/azure/data/tables.hpp +++ b/sdk/tables/azure-data-tables/inc/azure/data/tables.hpp @@ -15,5 +15,6 @@ #include "azure/data/tables/enum_operators.hpp" #include "azure/data/tables/models.hpp" #include "azure/data/tables/rtti.hpp" -#include "azure/data/tables/tables_clients.hpp" +#include "azure/data/tables/table_client.hpp" +#include "azure/data/tables/table_service_client.hpp" #include "azure/data/tables/tables_sas_builder.hpp" diff --git a/sdk/tables/azure-data-tables/inc/azure/data/tables/tables_clients.hpp b/sdk/tables/azure-data-tables/inc/azure/data/tables/table_client.hpp similarity index 67% rename from sdk/tables/azure-data-tables/inc/azure/data/tables/tables_clients.hpp rename to sdk/tables/azure-data-tables/inc/azure/data/tables/table_client.hpp index ceff9d62d..d8c61aa99 100644 --- a/sdk/tables/azure-data-tables/inc/azure/data/tables/tables_clients.hpp +++ b/sdk/tables/azure-data-tables/inc/azure/data/tables/table_client.hpp @@ -310,165 +310,4 @@ namespace Azure { namespace Data { namespace Tables { Core::Url m_url; std::string m_tableName; }; - - /** - * @brief Table Service Client - */ - class TableServiceClient final { - public: - /** - * @brief Initializes a new instance of tableClient. - * - * @param serviceUrl A url referencing the table that includes the name of the account and the - * name of the table. - * @param options Optional client options that define the transport pipeline policies for - * authentication, retries, etc., that are applied to every request. - */ - explicit TableServiceClient( - const std::string& serviceUrl, - const TableClientOptions& options = {}); - - /** - * @brief Initializes a new instance of tableClient. - * - * @param serviceUrl A url referencing the table that includes the name of the account and the - * name of the table. - * @param credential The shared key credential used to sign requests. - * @param options Optional client options that define the transport pipeline policies for - * authentication, retries, etc., that are applied to every request. - */ - explicit TableServiceClient( - const std::string& serviceUrl, - std::shared_ptr credential, - const TableClientOptions& options = {}); - - /** - * @brief Initializes a new instance of tableClient. - * - * @param serviceUrl A url referencing the table that includes the name of the account and the - * name of the table. - * @param credential The named key credential used to sign requests. - * @param options Optional client options that define the transport pipeline policies for - * authentication, retries, etc., that are applied to every request. - */ - explicit TableServiceClient( - const std::string& serviceUrl, - std::shared_ptr credential, - const TableClientOptions& options = {}); - - /** - * @brief Initializes a new instance of tableClient. - * - * @param serviceUrl A url referencing the table that includes the name of the account and the - * name of the table. - * @param credential The SAS credential used to sign requests. - * @param options Optional client options that define the transport pipeline policies for - * authentication, retries, etc., that are applied to every request. - */ - explicit TableServiceClient( - const std::string& serviceUrl, - std::shared_ptr credential, - const TableClientOptions& options = {}); - - /** - * @brief Initializes a new instance of tableClient. - * - * @param connectionString the connection string used to initialize. - * @param options Optional client options that define the transport pipeline policies for - * authentication, retries, etc., that are applied to every request. - * @return TableServiceClient. - */ - static TableServiceClient CreateFromConnectionString( - const std::string& connectionString, - const TableClientOptions& options = {}); - - /** - * @brief Creates a new table under the given account. - * - * @param context for canceling long running operations. - * @param tableName The name of the table to be created. - * @return Create table result. - */ - Response CreateTable( - std::string const& tableName, - Core::Context const& context = {}); - - /** - * @brief Operation permanently deletes the specified table. - * - * @param context for canceling long running operations. - * @param tableName The name of the table to be deleted. - * @return Delete table result. - */ - Response DeleteTable( - std::string const& tableName, - Core::Context const& context = {}); - - /** - * @brief Queries tables under the given account. - * - * @param options Optional parameters to execute this function. - * @param context for canceling long running operations. - * @return Query tables paged response. - */ - Models::QueryTablesPagedResponse QueryTables( - const Models::QueryTablesOptions& options = {}, - const Azure::Core::Context& context = {}) const; - - /** - * @brief Set service properties - * - * @param options Optional parameters to execute this function. - * @param context for canceling long running operations. - */ - Response SetServiceProperties( - Models::SetServicePropertiesOptions const& options = {}, - Core::Context const& context = {}); - - /** - * @brief Get service properties - * - * @param context for canceling long running operations. - * @return Get service properties result. - */ - Response GetServiceProperties( - Core::Context const& context = {}); - - /** - * @brief Get service statistics - * - * @param context for canceling long running operations. - * @return Get service statistics result. - */ - Response GetStatistics(Core::Context const& context = {}); - - /** - * @brief Pre flight check - * - * @param options Optional parameters to execute this function. - * @param context for canceling long running operations. - * @return Get service statistics result. - */ - Response PreflightCheck( - Models::PreflightCheckOptions const& options, - Core::Context const& context = {}); - /** - * @brief Get table client. - * - * @param tableName The name of the table. - * @param options Optional parameters for the table client. - * @return TableClient. - * @remark The TableClient can be used to perform operations on the table. This method will - * attempt to create a table client with the same credentials as the service client except the - * SAS token credential as the SAS token permissions varies from the service level permissions. - */ - TableClient GetTableClient(const std::string& tableName, TableClientOptions const& options = {}) - const; - - private: - std::shared_ptr m_pipeline; - std::shared_ptr m_tokenCredential; - std::shared_ptr m_namedKeyCredential; - Core::Url m_url; - }; }}} // namespace Azure::Data::Tables diff --git a/sdk/tables/azure-data-tables/inc/azure/data/tables/table_service_client.hpp b/sdk/tables/azure-data-tables/inc/azure/data/tables/table_service_client.hpp new file mode 100644 index 000000000..8b11c5e85 --- /dev/null +++ b/sdk/tables/azure-data-tables/inc/azure/data/tables/table_service_client.hpp @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +#pragma once + +#include "azure/data/tables/table_client.hpp" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace Azure { namespace Data { namespace Tables { + /** + * @brief Table Service Client + */ + class TableServiceClient final { + public: + /** + * @brief Initializes a new instance of tableClient. + * + * @param serviceUrl A url referencing the table that includes the name of the account and the + * name of the table. + * @param options Optional client options that define the transport pipeline policies for + * authentication, retries, etc., that are applied to every request. + */ + explicit TableServiceClient( + const std::string& serviceUrl, + const TableClientOptions& options = {}); + + /** + * @brief Initializes a new instance of tableClient. + * + * @param serviceUrl A url referencing the table that includes the name of the account and the + * name of the table. + * @param credential The shared key credential used to sign requests. + * @param options Optional client options that define the transport pipeline policies for + * authentication, retries, etc., that are applied to every request. + */ + explicit TableServiceClient( + const std::string& serviceUrl, + std::shared_ptr credential, + const TableClientOptions& options = {}); + + /** + * @brief Initializes a new instance of tableClient. + * + * @param serviceUrl A url referencing the table that includes the name of the account and the + * name of the table. + * @param credential The named key credential used to sign requests. + * @param options Optional client options that define the transport pipeline policies for + * authentication, retries, etc., that are applied to every request. + */ + explicit TableServiceClient( + const std::string& serviceUrl, + std::shared_ptr credential, + const TableClientOptions& options = {}); + + /** + * @brief Initializes a new instance of tableClient. + * + * @param serviceUrl A url referencing the table that includes the name of the account and the + * name of the table. + * @param credential The SAS credential used to sign requests. + * @param options Optional client options that define the transport pipeline policies for + * authentication, retries, etc., that are applied to every request. + */ + explicit TableServiceClient( + const std::string& serviceUrl, + std::shared_ptr credential, + const TableClientOptions& options = {}); + + /** + * @brief Initializes a new instance of tableClient. + * + * @param connectionString the connection string used to initialize. + * @param options Optional client options that define the transport pipeline policies for + * authentication, retries, etc., that are applied to every request. + * @return TableServiceClient. + */ + static TableServiceClient CreateFromConnectionString( + const std::string& connectionString, + const TableClientOptions& options = {}); + + /** + * @brief Creates a new table under the given account. + * + * @param context for canceling long running operations. + * @param tableName The name of the table to be created. + * @return Create table result. + */ + Response CreateTable( + std::string const& tableName, + Core::Context const& context = {}); + + /** + * @brief Operation permanently deletes the specified table. + * + * @param context for canceling long running operations. + * @param tableName The name of the table to be deleted. + * @return Delete table result. + */ + Response DeleteTable( + std::string const& tableName, + Core::Context const& context = {}); + + /** + * @brief Queries tables under the given account. + * + * @param options Optional parameters to execute this function. + * @param context for canceling long running operations. + * @return Query tables paged response. + */ + Models::QueryTablesPagedResponse QueryTables( + const Models::QueryTablesOptions& options = {}, + const Azure::Core::Context& context = {}) const; + + /** + * @brief Set service properties + * + * @param options Optional parameters to execute this function. + * @param context for canceling long running operations. + */ + Response SetServiceProperties( + Models::SetServicePropertiesOptions const& options = {}, + Core::Context const& context = {}); + + /** + * @brief Get service properties + * + * @param context for canceling long running operations. + * @return Get service properties result. + */ + Response GetServiceProperties( + Core::Context const& context = {}); + + /** + * @brief Get service statistics + * + * @param context for canceling long running operations. + * @return Get service statistics result. + */ + Response GetStatistics(Core::Context const& context = {}); + + /** + * @brief Pre flight check + * + * @param options Optional parameters to execute this function. + * @param context for canceling long running operations. + * @return Get service statistics result. + */ + Response PreflightCheck( + Models::PreflightCheckOptions const& options, + Core::Context const& context = {}); + /** + * @brief Get table client. + * + * @param tableName The name of the table. + * @param options Optional parameters for the table client. + * @return TableClient. + * @remark The TableClient can be used to perform operations on the table. This method will + * attempt to create a table client with the same credentials as the service client except the + * SAS token credential as the SAS token permissions varies from the service level permissions. + */ + TableClient GetTableClient(const std::string& tableName, TableClientOptions const& options = {}) + const; + + private: + std::shared_ptr m_pipeline; + std::shared_ptr m_tokenCredential; + std::shared_ptr m_namedKeyCredential; + Core::Url m_url; + }; +}}} // namespace Azure::Data::Tables diff --git a/sdk/tables/azure-data-tables/src/tables_clients.cpp b/sdk/tables/azure-data-tables/src/tables_clients.cpp index e244bf7ae..34677e8ac 100644 --- a/sdk/tables/azure-data-tables/src/tables_clients.cpp +++ b/sdk/tables/azure-data-tables/src/tables_clients.cpp @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#include "azure/data/tables/tables_clients.hpp" - +#include "azure/data/tables/table_client.hpp" +#include "azure/data/tables/table_service_client.hpp" #include "private/package_version.hpp" #include "private/policies/service_version_policy.hpp" #include "private/policies/shared_key_lite_policy.hpp" diff --git a/sdk/tables/azure-data-tables/test/ut/serializers_test.hpp b/sdk/tables/azure-data-tables/test/ut/serializers_test.hpp index e4a84b6e9..ad92fa68d 100644 --- a/sdk/tables/azure-data-tables/test/ut/serializers_test.hpp +++ b/sdk/tables/azure-data-tables/test/ut/serializers_test.hpp @@ -3,7 +3,7 @@ // Licensed under the MIT License. #include "../src/private/serializers.hpp" -#include "azure/data/tables/tables_clients.hpp" +#include "azure/data/tables/table_client.hpp" #include "test/ut/test_base.hpp" namespace Azure { namespace Data { namespace Test { diff --git a/sdk/tables/azure-data-tables/test/ut/table_client_test.hpp b/sdk/tables/azure-data-tables/test/ut/table_client_test.hpp index e41e1ea01..e3d9838d7 100644 --- a/sdk/tables/azure-data-tables/test/ut/table_client_test.hpp +++ b/sdk/tables/azure-data-tables/test/ut/table_client_test.hpp @@ -3,7 +3,8 @@ // Licensed under the MIT License. #include "azure/data/tables/models.hpp" -#include "azure/data/tables/tables_clients.hpp" +#include "azure/data/tables/table_client.hpp" +#include "azure/data/tables/table_service_client.hpp" #include "test/ut/test_base.hpp" namespace Azure { namespace Data { namespace Test { diff --git a/sdk/tables/azure-data-tables/test/ut/transactions_test.hpp b/sdk/tables/azure-data-tables/test/ut/transactions_test.hpp index be9700782..78173b832 100644 --- a/sdk/tables/azure-data-tables/test/ut/transactions_test.hpp +++ b/sdk/tables/azure-data-tables/test/ut/transactions_test.hpp @@ -2,7 +2,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#include "azure/data/tables/tables_clients.hpp" +#include "azure/data/tables/table_client.hpp" #include "test/ut/test_base.hpp" namespace Azure { namespace Data { namespace Test {