Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables cleanup work #6181

Merged
merged 35 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
672f23f
conn and names key out
gearama Nov 5, 2024
a14acb2
all work except get set acl
gearama Nov 5, 2024
6992ee0
samples
gearama Nov 5, 2024
95c1107
dqwd
gearama Nov 5, 2024
981cae0
extra space
gearama Nov 5, 2024
d6c4eef
record transactions, because test proxy
gearama Nov 6, 2024
e9e2e03
tty
gearama Nov 6, 2024
48a0d36
clang and samples working , assets json
gearama Nov 6, 2024
466253a
fds
gearama Nov 6, 2024
6a1d6c1
samples , and remove APIs
gearama Nov 8, 2024
a661973
dsds
gearama Nov 8, 2024
afbaecf
acct name
gearama Nov 8, 2024
4bff7a6
dsfds
gearama Nov 8, 2024
19f518f
oopsie
gearama Nov 8, 2024
d7b2b8f
dasdas
gearama Nov 8, 2024
dd479b1
fdsfsd
gearama Nov 8, 2024
ec4d3f9
clangs
gearama Nov 8, 2024
82a0aa8
account key for sas
gearama Nov 8, 2024
572a634
kjhdsakjhdkjashdjkwash
gearama Nov 8, 2024
6f9df58
dssfsd
gearama Nov 8, 2024
2a2d4fa
ggd
gearama Nov 8, 2024
6e70940
Update sdk/tables/azure-data-tables/samples/CMakeLists.txt
gearama Nov 8, 2024
37e0571
put back unused env in CI
gearama Nov 8, 2024
cd1e9ad
Merge branch 'TablesCleanupWork' of https://github.com/gearama/azure-…
gearama Nov 8, 2024
4ed944f
Update sdk/tables/azure-data-tables/src/table_clients.cpp
gearama Nov 8, 2024
234ad59
Update sdk/tables/azure-data-tables/src/table_clients.cpp
gearama Nov 8, 2024
1e4a274
fdg
gearama Nov 8, 2024
5d282f6
fds
gearama Nov 8, 2024
06cfc6b
Merge branch 'Azure:main' into TablesCleanupWork
gearama Nov 8, 2024
4ddfcda
update samples and readme
gearama Nov 13, 2024
4f8fdd9
sdjkfhsdkj
gearama Nov 13, 2024
42a773e
Update sdk/tables/azure-data-tables/README.md
gearama Nov 13, 2024
91650cb
Update sdk/tables/azure-data-tables/test/ut/table_client_test.hpp
gearama Nov 13, 2024
37544d7
Update sdk/tables/azure-data-tables/test/ut/table_client_test.hpp
gearama Nov 13, 2024
43c7d8d
update remove namespaces
gearama Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/tables/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/tables",
"Tag": "cpp/tables_cb42be8953"
"Tag": "cpp/tables_0b3363cab7"
}
10 changes: 6 additions & 4 deletions sdk/tables/azure-data-tables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,16 @@ Two different clients are provided to interact with the various components of th

##### Creating and deleting a table

In order to Create/Delete a table we need to create a TablesClient first.
In order to Create/Delete a table we need to create a `TableServiceClient` first.

```cpp
#include <azure/data/tables.hpp>
...
using namespace Azure::Data::Tables;
const std::string TableName = "sample1";
...
auto tableServiceClient = TableServiceClient::CreateFromConnectionString(GetConnectionString());
auto credential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto tableServiceClient = Azure::Data::Tables::TableServiceClient(GetServiceUrl(), credential);
gearama marked this conversation as resolved.
Show resolved Hide resolved

// create new table
tableServiceClient.CreateTable(TableName);
Expand Down Expand Up @@ -155,7 +156,7 @@ auto tableClient = tableServiceClient.GetTableClient(TableName);
```
N.B. Here we are obtaining the table client from the table service client using the credentials that were passed to the table service client.

##### Create a client with a connection string
##### Create a client with DefaultAzureCredentials
In order to Create/Update/Merge/Delete entities we need to create a TablesClient first.

```cpp
Expand All @@ -164,7 +165,8 @@ In order to Create/Update/Merge/Delete entities we need to create a TablesClient
using namespace Azure::Data::Tables;
const std::string TableName = "sample1";
...
auto tableClient = TableClient::CreateFromConnectionString(..., TableName);
auto credential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto tableServiceClient = Azure::Data::Tables::TableServiceClient(GetServiceUrl(), credential);
gearama marked this conversation as resolved.
Show resolved Hide resolved
```

##### Entities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ namespace Azure { namespace Data { namespace Tables { namespace Sas {
Delete = 4,

/**
* @brief Indicates that Add is permitted.
* @brief Indicates that List is permitted.
*/
Add = 8,
List = 8,
LarryOsterman marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Indicates that List is permitted.
* @brief Indicates that Add is permitted.
*/
List = 16,
Add = 16,

/**
* @brief Indicates that Update is permitted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,6 @@ namespace Azure { namespace Data { namespace Tables {
std::shared_ptr<Core::Credentials::TokenCredential> credential,
const TableClientOptions& options = {});

/**
* @brief Initializes a new instance of tableClient.
*
* @param tableName The name of the table.
* @param credential The named key credential used to sign requests.
* @param url A url referencing the table that includes the name of the account and the name of
* @param options Optional client options that define the transport pipeline policies for
* authentication, retries, etc., that are applied to every request.
*/
explicit TableClient(
const std::string& tableName,
std::shared_ptr<Azure::Data::Tables::Credentials::NamedKeyCredential> credential,
std::string url,
const TableClientOptions& options = {});

/**
* @brief Initializes a new instance of tableClient.
*
Expand All @@ -118,41 +103,6 @@ namespace Azure { namespace Data { namespace Tables {
const std::string& tableName,
const TableClientOptions& options = {});

/**
* @brief Initializes a new instance of tableClient.
*
* @param connectionString the connection string used to initialize.
* @param tableName 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.
* @return TableClient.
*/
static TableClient CreateFromConnectionString(
const std::string& connectionString,
const std::string& tableName,
const TableClientOptions& options = {});

/**
* @brief Retrieves details about any stored access policies specified on the table that may be
* used with Shared Access Signatures.
*
* @param context for canceling long running operations.
* @return Get access policy result.
*/
Response<Models::TableAccessPolicy> GetAccessPolicy(Core::Context const& context = {});
gearama marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Sets stored access policies for the table that may be used with Shared Access
* Signatures.
*
* @param tableAccessPolicy The TableAccessPolicy to set.
* @param context for canceling long running operations.
* @return Set access policy result.
*/
Response<Models::SetTableAccessPolicyResult> SetAccessPolicy(
Models::TableAccessPolicy const& tableAccessPolicy,
Core::Context const& context = {});

/**
* @brief Add entity in a table.
*
Expand Down Expand Up @@ -236,14 +186,14 @@ namespace Azure { namespace Data { namespace Tables {
* @return Table entity.
*/
Response<Models::TableEntity> GetEntity(
const std::string& partitionKey,
const std::string& rowKey,
std::string const& partitionKey,
std::string const& rowKey,
Core::Context const& context = {});

/**
* @brief Submits a transaction.
*
* @param steps the transaction steps to execute.
* @param steps The transaction steps to execute.
* @param context for canceling long running operations.
* @return Submit transaction result.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@ namespace Azure { namespace Data { namespace Tables {
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.
*
Expand All @@ -78,18 +64,6 @@ namespace Azure { namespace Data { namespace Tables {
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.
*
Expand Down Expand Up @@ -176,7 +150,6 @@ namespace Azure { namespace Data { namespace Tables {
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
10 changes: 5 additions & 5 deletions sdk/tables/azure-data-tables/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ if(MSVC)
endif()

add_executable(tables-getting-started tables_getting_started.cpp )
target_link_libraries(tables-getting-started PRIVATE azure-data-tables get-env-helper)
target_link_libraries(tables-getting-started PRIVATE azure-data-tables azure-identity get-env-helper)
create_per_service_target_build_for_sample(tables tables-getting-started)
target_compile_definitions(tables-getting-started PRIVATE _azure_BUILDING_SAMPLES)

add_executable(tables_entity_operations tables_entity_operations.cpp)
target_link_libraries(tables_entity_operations PRIVATE azure-data-tables get-env-helper)
target_link_libraries(tables_entity_operations PRIVATE azure-data-tables azure-identity get-env-helper)
create_per_service_target_build_for_sample(tables tables_entity_operations)
target_compile_definitions(tables_entity_operations PRIVATE _azure_BUILDING_SAMPLES)

add_executable(tables_service_operations tables_service_operations.cpp)
target_link_libraries(tables_service_operations PRIVATE azure-data-tables get-env-helper)
target_link_libraries(tables_service_operations PRIVATE azure-data-tables azure-identity get-env-helper)
create_per_service_target_build_for_sample(tables tables_service_operations)
target_compile_definitions(tables_service_operations PRIVATE _azure_BUILDING_SAMPLES)

add_executable(tables_transactions_ok tables_transactions_ok.cpp)
target_link_libraries(tables_transactions_ok PRIVATE azure-data-tables get-env-helper)
target_link_libraries(tables_transactions_ok PRIVATE azure-data-tables azure-identity get-env-helper)
create_per_service_target_build_for_sample(tables tables_transactions_ok)
target_compile_definitions(tables_transactions_ok PRIVATE _azure_BUILDING_SAMPLES)

add_executable(tables_transactions_fail tables_transactions_fail.cpp)
target_link_libraries(tables_transactions_fail PRIVATE azure-data-tables get-env-helper)
target_link_libraries(tables_transactions_fail PRIVATE azure-data-tables azure-identity get-env-helper)
create_per_service_target_build_for_sample(tables tables_transactions_fail)
target_compile_definitions(tables_transactions_fail PRIVATE _azure_BUILDING_SAMPLES)
34 changes: 13 additions & 21 deletions sdk/tables/azure-data-tables/samples/tables_entity_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,28 @@
// Licensed under the MIT License.

#include <azure/data/tables.hpp>
#include <azure/identity.hpp>

#include <cstdio>
#include <iostream>
#include <stdexcept>
#include <thread>

using namespace Azure::Data::Tables;
using namespace Azure::Data::Tables::Models;
const std::string TableName = "table";

std::string GetConnectionString()
// The following environment variables must be set before running the sample.
// * ACCOUNT_NAME: The name of the storage account.
std::string GetAccountName() { return std::getenv("ACCOUNT_NAME"); }
std::string const GetServiceUrl()
{
const static std::string ConnectionString = "";

if (!ConnectionString.empty())
{
return ConnectionString;
}
const static std::string envConnectionString = std::getenv("STANDARD_STORAGE_CONNECTION_STRING");
if (!envConnectionString.empty())
{
return envConnectionString;
}
throw std::runtime_error("Cannot find connection string.");
return std::string{"https://" + GetAccountName() + ".table.core.windows.net/"};
}

int main()
{
auto tableServiceClient = TableServiceClient::CreateFromConnectionString(GetConnectionString());
auto tableClient = TableClient::CreateFromConnectionString(GetConnectionString(), TableName);
auto credential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto tableServiceClient = Azure::Data::Tables::TableServiceClient(GetServiceUrl(), credential);
auto tableClient = Azure::Data::Tables::TableClient(GetServiceUrl(), TableName, credential);
gearama marked this conversation as resolved.
Show resolved Hide resolved

// create new table
tableServiceClient.CreateTable(TableName);
Expand All @@ -46,19 +38,19 @@ int main()
Azure::Data::Tables::Models::TableEntity entity;
entity.SetPartitionKey("P1");
entity.SetRowKey("R1");
entity.Properties["Name"] = TableEntityProperty("Azure");
entity.Properties["Product"] = TableEntityProperty("Tables");
entity.Properties["Name"] = Azure::Data::Tables::Models::TableEntityProperty("Azure");
entity.Properties["Product"] = Azure::Data::Tables::Models::TableEntityProperty("Tables");
// create new entity
auto response = tableClient.AddEntity(entity);

// update entity
std::cout << response.Value.ETag << std::endl;
entity.Properties["Product"] = TableEntityProperty("Tables2");
entity.Properties["Product"] = Azure::Data::Tables::Models::TableEntityProperty("Tables2");
auto updateResponse = tableClient.UpdateEntity(entity);
std::cout << updateResponse.Value.ETag << std::endl;

// merge entity
entity.Properties["Product"] = TableEntityProperty("Tables3");
entity.Properties["Product"] = Azure::Data::Tables::Models::TableEntityProperty("Tables3");
entity.SetETag(updateResponse.Value.ETag);
auto updateResponse2 = tableClient.MergeEntity(entity);

Expand Down
28 changes: 10 additions & 18 deletions sdk/tables/azure-data-tables/samples/tables_getting_started.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,26 @@
// Licensed under the MIT License.

#include <azure/data/tables.hpp>
#include <azure/identity.hpp>

#include <cstdio>
#include <iostream>
#include <stdexcept>
#include <thread>

std::string GetConnectionString()
{
const static std::string ConnectionString = "";

if (!ConnectionString.empty())
{
return ConnectionString;
}
const static std::string envConnectionString = std::getenv("STANDARD_STORAGE_CONNECTION_STRING");
if (!envConnectionString.empty())
{
return envConnectionString;
}
throw std::runtime_error("Cannot find connection string.");
}

using namespace Azure::Data::Tables;
const std::string TableName = "sample1";

// The following environment variables must be set before running the sample.
// * ACCOUNT_NAME: The name of the storage account.
std::string GetAccountName() { return std::getenv("ACCOUNT_NAME"); }
std::string const GetServiceUrl()
{
return std::string{"https://" + GetAccountName() + ".table.core.windows.net/"};
}
int main()
{
auto tableServiceClient = TableServiceClient::CreateFromConnectionString(GetConnectionString());
auto credential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto tableServiceClient = Azure::Data::Tables::TableServiceClient(GetServiceUrl(), credential);
gearama marked this conversation as resolved.
Show resolved Hide resolved

// create new table
tableServiceClient.CreateTable(TableName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,27 @@
// Licensed under the MIT License.

#include <azure/data/tables.hpp>
#include <azure/identity.hpp>

#include <cstdio>
#include <iostream>
#include <stdexcept>
#include <thread>

std::string GetConnectionString()
{
const static std::string ConnectionString = "";
const std::string TableName = "sample1";

if (!ConnectionString.empty())
{
return ConnectionString;
}
const static std::string envConnectionString = std::getenv("STANDARD_STORAGE_CONNECTION_STRING");
if (!envConnectionString.empty())
{
return envConnectionString;
}
throw std::runtime_error("Cannot find connection string.");
// The following environment variables must be set before running the sample.
// * ACCOUNT_NAME: The name of the storage account.
std::string GetAccountName() { return std::getenv("ACCOUNT_NAME"); }
std::string const GetServiceUrl()
{
return std::string{"https://" + GetAccountName() + ".table.core.windows.net/"};
}

using namespace Azure::Data::Tables;
const std::string TableName = "sample1";

int main()
{
auto tableServiceClient = TableServiceClient::CreateFromConnectionString(GetConnectionString());

auto credential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto tableServiceClient = Azure::Data::Tables::TableServiceClient(GetServiceUrl(), credential);
// query tables
auto tables = tableServiceClient.QueryTables();

Expand Down
Loading