/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include #include #include #include #include #include using namespace Aws::DynamoDB::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; BatchGetItemResult::BatchGetItemResult() { } BatchGetItemResult::BatchGetItemResult(const Aws::AmazonWebServiceResult& result) { *this = result; } BatchGetItemResult& BatchGetItemResult::operator =(const Aws::AmazonWebServiceResult& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("Responses")) { Aws::Map responsesJsonMap = jsonValue.GetObject("Responses").GetAllObjects(); for(auto& responsesItem : responsesJsonMap) { Aws::Utils::Array itemListJsonList = responsesItem.second.AsArray(); Aws::Vector> itemListList; itemListList.reserve((size_t)itemListJsonList.GetLength()); for(unsigned itemListIndex = 0; itemListIndex < itemListJsonList.GetLength(); ++itemListIndex) { Aws::Map attributeMapJsonMap = itemListJsonList[itemListIndex].GetAllObjects(); Aws::Map attributeMapMap; for(auto& attributeMapItem : attributeMapJsonMap) { attributeMapMap[attributeMapItem.first] = attributeMapItem.second.AsObject(); } itemListList.push_back(std::move(attributeMapMap)); } m_responses[responsesItem.first] = std::move(itemListList); } } if(jsonValue.ValueExists("UnprocessedKeys")) { Aws::Map unprocessedKeysJsonMap = jsonValue.GetObject("UnprocessedKeys").GetAllObjects(); for(auto& unprocessedKeysItem : unprocessedKeysJsonMap) { m_unprocessedKeys[unprocessedKeysItem.first] = unprocessedKeysItem.second.AsObject(); } } if(jsonValue.ValueExists("ConsumedCapacity")) { Aws::Utils::Array consumedCapacityJsonList = jsonValue.GetArray("ConsumedCapacity"); for(unsigned consumedCapacityIndex = 0; consumedCapacityIndex < consumedCapacityJsonList.GetLength(); ++consumedCapacityIndex) { m_consumedCapacity.push_back(consumedCapacityJsonList[consumedCapacityIndex].AsObject()); } } const auto& headers = result.GetHeaderValueCollection(); const auto& requestIdIter = headers.find("x-amzn-requestid"); if(requestIdIter != headers.end()) { m_requestId = requestIdIter->second; } return *this; }