/** * 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::RedshiftDataAPIService::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; GetStatementResultResult::GetStatementResultResult() : m_totalNumRows(0) { } GetStatementResultResult::GetStatementResultResult(const Aws::AmazonWebServiceResult& result) : m_totalNumRows(0) { *this = result; } GetStatementResultResult& GetStatementResultResult::operator =(const Aws::AmazonWebServiceResult& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("ColumnMetadata")) { Aws::Utils::Array columnMetadataJsonList = jsonValue.GetArray("ColumnMetadata"); for(unsigned columnMetadataIndex = 0; columnMetadataIndex < columnMetadataJsonList.GetLength(); ++columnMetadataIndex) { m_columnMetadata.push_back(columnMetadataJsonList[columnMetadataIndex].AsObject()); } } if(jsonValue.ValueExists("NextToken")) { m_nextToken = jsonValue.GetString("NextToken"); } if(jsonValue.ValueExists("Records")) { Aws::Utils::Array recordsJsonList = jsonValue.GetArray("Records"); for(unsigned recordsIndex = 0; recordsIndex < recordsJsonList.GetLength(); ++recordsIndex) { Aws::Utils::Array fieldListJsonList = recordsJsonList[recordsIndex].AsArray(); Aws::Vector fieldListList; fieldListList.reserve((size_t)fieldListJsonList.GetLength()); for(unsigned fieldListIndex = 0; fieldListIndex < fieldListJsonList.GetLength(); ++fieldListIndex) { fieldListList.push_back(fieldListJsonList[fieldListIndex].AsObject()); } m_records.push_back(std::move(fieldListList)); } } if(jsonValue.ValueExists("TotalNumRows")) { m_totalNumRows = jsonValue.GetInt64("TotalNumRows"); } const auto& headers = result.GetHeaderValueCollection(); const auto& requestIdIter = headers.find("x-amzn-requestid"); if(requestIdIter != headers.end()) { m_requestId = requestIdIter->second; } return *this; }