102 lines
2.6 KiB
C++
102 lines
2.6 KiB
C++
|
|
/**
|
|||
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|||
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#include <aws/dynamodb/model/GetItemRequest.h>
|
|||
|
|
#include <aws/core/utils/json/JsonSerializer.h>
|
|||
|
|
|
|||
|
|
#include <utility>
|
|||
|
|
|
|||
|
|
using namespace Aws::DynamoDB::Model;
|
|||
|
|
using namespace Aws::Utils::Json;
|
|||
|
|
using namespace Aws::Utils;
|
|||
|
|
|
|||
|
|
GetItemRequest::GetItemRequest() :
|
|||
|
|
m_tableNameHasBeenSet(false),
|
|||
|
|
m_keyHasBeenSet(false),
|
|||
|
|
m_attributesToGetHasBeenSet(false),
|
|||
|
|
m_consistentRead(false),
|
|||
|
|
m_consistentReadHasBeenSet(false),
|
|||
|
|
m_returnConsumedCapacity(ReturnConsumedCapacity::NOT_SET),
|
|||
|
|
m_returnConsumedCapacityHasBeenSet(false),
|
|||
|
|
m_projectionExpressionHasBeenSet(false),
|
|||
|
|
m_expressionAttributeNamesHasBeenSet(false)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Aws::String GetItemRequest::SerializePayload() const
|
|||
|
|
{
|
|||
|
|
JsonValue payload;
|
|||
|
|
|
|||
|
|
if(m_tableNameHasBeenSet)
|
|||
|
|
{
|
|||
|
|
payload.WithString("TableName", m_tableName);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_keyHasBeenSet)
|
|||
|
|
{
|
|||
|
|
JsonValue keyJsonMap;
|
|||
|
|
for(auto& keyItem : m_key)
|
|||
|
|
{
|
|||
|
|
keyJsonMap.WithObject(keyItem.first, keyItem.second.Jsonize());
|
|||
|
|
}
|
|||
|
|
payload.WithObject("Key", std::move(keyJsonMap));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_attributesToGetHasBeenSet)
|
|||
|
|
{
|
|||
|
|
Array<JsonValue> attributesToGetJsonList(m_attributesToGet.size());
|
|||
|
|
for(unsigned attributesToGetIndex = 0; attributesToGetIndex < attributesToGetJsonList.GetLength(); ++attributesToGetIndex)
|
|||
|
|
{
|
|||
|
|
attributesToGetJsonList[attributesToGetIndex].AsString(m_attributesToGet[attributesToGetIndex]);
|
|||
|
|
}
|
|||
|
|
payload.WithArray("AttributesToGet", std::move(attributesToGetJsonList));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_consistentReadHasBeenSet)
|
|||
|
|
{
|
|||
|
|
payload.WithBool("ConsistentRead", m_consistentRead);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_returnConsumedCapacityHasBeenSet)
|
|||
|
|
{
|
|||
|
|
payload.WithString("ReturnConsumedCapacity", ReturnConsumedCapacityMapper::GetNameForReturnConsumedCapacity(m_returnConsumedCapacity));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_projectionExpressionHasBeenSet)
|
|||
|
|
{
|
|||
|
|
payload.WithString("ProjectionExpression", m_projectionExpression);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_expressionAttributeNamesHasBeenSet)
|
|||
|
|
{
|
|||
|
|
JsonValue expressionAttributeNamesJsonMap;
|
|||
|
|
for(auto& expressionAttributeNamesItem : m_expressionAttributeNames)
|
|||
|
|
{
|
|||
|
|
expressionAttributeNamesJsonMap.WithString(expressionAttributeNamesItem.first, expressionAttributeNamesItem.second);
|
|||
|
|
}
|
|||
|
|
payload.WithObject("ExpressionAttributeNames", std::move(expressionAttributeNamesJsonMap));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return payload.View().WriteReadable();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Aws::Http::HeaderValueCollection GetItemRequest::GetRequestSpecificHeaders() const
|
|||
|
|
{
|
|||
|
|
Aws::Http::HeaderValueCollection headers;
|
|||
|
|
headers.insert(Aws::Http::HeaderValuePair("X-Amz-Target", "DynamoDB_20120810.GetItem"));
|
|||
|
|
return headers;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|