-
Notifications
You must be signed in to change notification settings - Fork 129
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
Get entity api #5456
Merged
Merged
Get entity api #5456
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6e0e7c2
mroe quotes
gearama cd9c1ec
dssf
gearama 3533f8b
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 166d493
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 1505804
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 735ec09
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 5f7bab8
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama bdd6871
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 7db0a2e
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 1114279
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama d01d911
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 15f57ae
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama f24d203
getentity
gearama 30d8ffc
Merge branch 'main' of https://github.com/gearama/azure-sdk-for-cpp
gearama 596e50f
ewe
gearama c4372b9
tests
gearama 576ad30
re
gearama c3d215d
assets working now
gearama 3e644f5
re
gearama fd7e64d
fgf
gearama c702052
clang
gearama bf445f4
url encode
gearama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -672,8 +672,8 @@ Azure::Response<Models::UpdateEntityResult> TableClient::UpdateEntity( | |
(void)options; | ||
auto url = m_url; | ||
url.AppendPath( | ||
m_tableName + "(PartitionKey='" + tableEntity.PartitionKey + "',RowKey='" + tableEntity.RowKey | ||
+ "')"); | ||
m_tableName + "(PartitionKey='" + Azure::Core::Url::Encode(tableEntity.PartitionKey) | ||
+ "',RowKey='" + Azure::Core::Url::Encode(tableEntity.RowKey) + "')"); | ||
|
||
std::string jsonBody = Serializers::UpdateEntity(tableEntity); | ||
|
||
|
@@ -716,8 +716,8 @@ Azure::Response<Models::MergeEntityResult> TableClient::MergeEntity( | |
(void)options; | ||
auto url = m_url; | ||
url.AppendPath( | ||
m_tableName + "(PartitionKey='" + tableEntity.PartitionKey + "',RowKey='" + tableEntity.RowKey | ||
+ "')"); | ||
m_tableName + "(PartitionKey='" + Azure::Core::Url::Encode(tableEntity.PartitionKey) | ||
+ "',RowKey='" + Azure::Core::Url::Encode(tableEntity.RowKey) + "')"); | ||
|
||
std::string jsonBody = Serializers::MergeEntity(tableEntity); | ||
|
||
|
@@ -758,8 +758,8 @@ Azure::Response<Models::DeleteEntityResult> TableClient::DeleteEntity( | |
{ | ||
auto url = m_url; | ||
url.AppendPath( | ||
m_tableName + "(PartitionKey='" + tableEntity.PartitionKey + "',RowKey='" + tableEntity.RowKey | ||
+ "')"); | ||
m_tableName + "(PartitionKey='" + Azure::Core::Url::Encode(tableEntity.PartitionKey) | ||
+ "',RowKey='" + Azure::Core::Url::Encode(tableEntity.RowKey) + "')"); | ||
|
||
Core::Http::Request request(Core::Http::HttpMethod::Delete, url); | ||
|
||
|
@@ -820,6 +820,39 @@ void Models::QueryEntitiesPagedResponse::OnNextPage(const Azure::Core::Context& | |
*this = m_tableClient->QueryEntities(m_operationOptions, context); | ||
} | ||
|
||
Azure::Response<Models::TableEntity> TableClient::GetEntity( | ||
const std::string& partitionKey, | ||
const std::string& rowKey, | ||
Core::Context const& context) | ||
{ | ||
auto url = m_url; | ||
url.AppendPath( | ||
m_tableName + "(PartitionKey='" + Azure::Core::Url::Encode(partitionKey) + "',RowKey='" | ||
+ Azure::Core::Url::Encode(rowKey) + "')"); | ||
|
||
Core::Http::Request request(Core::Http::HttpMethod::Get, url); | ||
request.SetHeader("Accept", "application/json;odata=fullmetadata"); | ||
|
||
auto rawResponse = m_pipeline->Send(request, context); | ||
auto const httpStatusCode = rawResponse->GetStatusCode(); | ||
if (httpStatusCode != Core::Http::HttpStatusCode::Ok) | ||
{ | ||
throw Core::RequestFailedException(rawResponse); | ||
} | ||
Comment on lines
+837
to
+841
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a test for the non-happy error path here? |
||
|
||
Models::TableEntity response{}; | ||
{ | ||
const auto& responseBody = rawResponse->GetBody(); | ||
std::string responseString = std::string(responseBody.begin(), responseBody.end()); | ||
|
||
auto const jsonRoot | ||
= Azure::Core::Json::_internal::json::parse(responseBody.begin(), responseBody.end()); | ||
|
||
response = Serializers::DeserializeEntity(jsonRoot); | ||
} | ||
return Response<Models::TableEntity>(std::move(response), std::move(rawResponse)); | ||
} | ||
|
||
Models::QueryEntitiesPagedResponse TableClient::QueryEntities( | ||
Models::QueryEntitiesOptions const& options, | ||
Core::Context const& context) | ||
|
@@ -828,23 +861,23 @@ Models::QueryEntitiesPagedResponse TableClient::QueryEntities( | |
std::string appendPath = m_tableName + "("; | ||
if (!options.PartitionKey.empty()) | ||
{ | ||
appendPath += "PartitionKey='" + options.PartitionKey + "'"; | ||
appendPath += "PartitionKey='" + Azure::Core::Url::Encode(options.PartitionKey) + "'"; | ||
} | ||
if (!options.RowKey.empty()) | ||
{ | ||
appendPath += ",RowKey='" + options.RowKey + "'"; | ||
appendPath += ",RowKey='" + Azure::Core::Url::Encode(options.RowKey) + "'"; | ||
} | ||
appendPath += ")"; | ||
|
||
url.AppendPath(appendPath); | ||
|
||
if (options.Filter.HasValue()) | ||
{ | ||
url.AppendQueryParameter("$filter", options.Filter.Value()); | ||
url.AppendQueryParameter("$filter", Azure::Core::Url::Encode(options.Filter.Value())); | ||
} | ||
if (!options.SelectColumns.empty()) | ||
{ | ||
url.AppendQueryParameter("$select", options.SelectColumns); | ||
url.AppendQueryParameter("$select", Azure::Core::Url::Encode(options.SelectColumns)); | ||
} | ||
|
||
Core::Http::Request request(Core::Http::HttpMethod::Get, url); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -469,6 +469,41 @@ namespace Azure { namespace Data { namespace Test { | |
EXPECT_EQ(responseQuery.TableEntities.size(), 1); | ||
} | ||
|
||
TEST_P(TablesClientTest, EntityGet) | ||
{ | ||
if (GetParam() == AuthType::Key) | ||
{ | ||
EXPECT_TRUE(true); | ||
return; | ||
} | ||
Comment on lines
+474
to
+478
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we have this type of parameterized test if it doesn't make sense here? Deserves a comment. |
||
Azure::Data::Tables::Models::TableEntity entity; | ||
|
||
entity.PartitionKey = "P1"; | ||
entity.RowKey = "R1"; | ||
entity.Properties["Name"] = "Azure"; | ||
entity.Properties["Product"] = "Tables"; | ||
auto createResponse = m_tableServiceClient->CreateTable(m_tableName); | ||
auto response = m_tableClient->CreateEntity(entity); | ||
EXPECT_EQ(response.RawResponse->GetStatusCode(), Azure::Core::Http::HttpStatusCode::NoContent); | ||
EXPECT_FALSE(response.Value.ETag.empty()); | ||
|
||
entity.Properties["Product"] = "Tables2"; | ||
entity.RowKey = "R2"; | ||
m_tableClient->CreateEntity(entity); | ||
|
||
entity.Properties["Product"] = "Tables3"; | ||
entity.RowKey = "R3"; | ||
m_tableClient->CreateEntity(entity); | ||
|
||
std::string partitionKey = "P1"; | ||
std::string rowKey = "R1"; | ||
auto responseQuery = m_tableClient->GetEntity(partitionKey, rowKey); | ||
EXPECT_EQ(responseQuery.Value.PartitionKey, "P1"); | ||
EXPECT_EQ(responseQuery.Value.RowKey, "R1"); | ||
EXPECT_EQ(responseQuery.Value.Properties["Name"], "Azure"); | ||
EXPECT_EQ(responseQuery.Value.Properties["Product"], "Tables"); | ||
} | ||
|
||
TEST_P(TablesClientTest, TransactionCreateFail_LIVEONLY_) | ||
{ | ||
Azure::Data::Tables::Models::TableEntity entity; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment doesn't match the
Response<T>
. It isn't a paged response.