Rename table client headers and split out the clients into their own files. (#6135)

* Rename table client headers and split out the clients into their own files.

* Fix clang format.

* Add CL entry.

* fix clang format.

* fix merge.
This commit is contained in:
Ahson Khan 2024-10-29 20:11:59 -07:00 committed by GitHub
parent fb79281273
commit cb655deb44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 193 additions and 168 deletions

View File

@ -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.

View File

@ -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
)

View File

@ -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"

View File

@ -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<Core::Credentials::TokenCredential> 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<Azure::Data::Tables::Credentials::NamedKeyCredential> 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<Azure::Data::Tables::Credentials::AzureSasCredential> 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<Models::Table> 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<Models::DeleteTableResult> 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<Models::SetServicePropertiesResult> 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<Models::TableServiceProperties> GetServiceProperties(
Core::Context const& context = {});
/**
* @brief Get service statistics
*
* @param context for canceling long running operations.
* @return Get service statistics result.
*/
Response<Models::ServiceStatistics> 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<Models::PreflightCheckResult> 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<Core::Http::_internal::HttpPipeline> m_pipeline;
std::shared_ptr<Core::Credentials::TokenCredential> m_tokenCredential;
std::shared_ptr<Azure::Data::Tables::Credentials::NamedKeyCredential> m_namedKeyCredential;
Core::Url m_url;
};
}}} // namespace Azure::Data::Tables

View File

@ -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 <azure/core/credentials/credentials.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/http/policies/policy.hpp>
#include <azure/core/internal/http/pipeline.hpp>
#include <azure/core/internal/json/json.hpp>
#include <azure/core/response.hpp>
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include <vector>
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<Core::Credentials::TokenCredential> 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<Azure::Data::Tables::Credentials::NamedKeyCredential> 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<Azure::Data::Tables::Credentials::AzureSasCredential> 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<Models::Table> 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<Models::DeleteTableResult> 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<Models::SetServicePropertiesResult> 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<Models::TableServiceProperties> GetServiceProperties(
Core::Context const& context = {});
/**
* @brief Get service statistics
*
* @param context for canceling long running operations.
* @return Get service statistics result.
*/
Response<Models::ServiceStatistics> 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<Models::PreflightCheckResult> 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<Core::Http::_internal::HttpPipeline> m_pipeline;
std::shared_ptr<Core::Credentials::TokenCredential> m_tokenCredential;
std::shared_ptr<Azure::Data::Tables::Credentials::NamedKeyCredential> m_namedKeyCredential;
Core::Url m_url;
};
}}} // namespace Azure::Data::Tables

View File

@ -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"

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {