This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
pxz-hos-client-cpp-module/support/aws-sdk-cpp-master/aws-cpp-sdk-athena/source/model/TableMetadata.cpp

172 lines
4.1 KiB
C++

/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/athena/model/TableMetadata.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace Athena
{
namespace Model
{
TableMetadata::TableMetadata() :
m_nameHasBeenSet(false),
m_createTimeHasBeenSet(false),
m_lastAccessTimeHasBeenSet(false),
m_tableTypeHasBeenSet(false),
m_columnsHasBeenSet(false),
m_partitionKeysHasBeenSet(false),
m_parametersHasBeenSet(false)
{
}
TableMetadata::TableMetadata(JsonView jsonValue) :
m_nameHasBeenSet(false),
m_createTimeHasBeenSet(false),
m_lastAccessTimeHasBeenSet(false),
m_tableTypeHasBeenSet(false),
m_columnsHasBeenSet(false),
m_partitionKeysHasBeenSet(false),
m_parametersHasBeenSet(false)
{
*this = jsonValue;
}
TableMetadata& TableMetadata::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("Name"))
{
m_name = jsonValue.GetString("Name");
m_nameHasBeenSet = true;
}
if(jsonValue.ValueExists("CreateTime"))
{
m_createTime = jsonValue.GetDouble("CreateTime");
m_createTimeHasBeenSet = true;
}
if(jsonValue.ValueExists("LastAccessTime"))
{
m_lastAccessTime = jsonValue.GetDouble("LastAccessTime");
m_lastAccessTimeHasBeenSet = true;
}
if(jsonValue.ValueExists("TableType"))
{
m_tableType = jsonValue.GetString("TableType");
m_tableTypeHasBeenSet = true;
}
if(jsonValue.ValueExists("Columns"))
{
Array<JsonView> columnsJsonList = jsonValue.GetArray("Columns");
for(unsigned columnsIndex = 0; columnsIndex < columnsJsonList.GetLength(); ++columnsIndex)
{
m_columns.push_back(columnsJsonList[columnsIndex].AsObject());
}
m_columnsHasBeenSet = true;
}
if(jsonValue.ValueExists("PartitionKeys"))
{
Array<JsonView> partitionKeysJsonList = jsonValue.GetArray("PartitionKeys");
for(unsigned partitionKeysIndex = 0; partitionKeysIndex < partitionKeysJsonList.GetLength(); ++partitionKeysIndex)
{
m_partitionKeys.push_back(partitionKeysJsonList[partitionKeysIndex].AsObject());
}
m_partitionKeysHasBeenSet = true;
}
if(jsonValue.ValueExists("Parameters"))
{
Aws::Map<Aws::String, JsonView> parametersJsonMap = jsonValue.GetObject("Parameters").GetAllObjects();
for(auto& parametersItem : parametersJsonMap)
{
m_parameters[parametersItem.first] = parametersItem.second.AsString();
}
m_parametersHasBeenSet = true;
}
return *this;
}
JsonValue TableMetadata::Jsonize() const
{
JsonValue payload;
if(m_nameHasBeenSet)
{
payload.WithString("Name", m_name);
}
if(m_createTimeHasBeenSet)
{
payload.WithDouble("CreateTime", m_createTime.SecondsWithMSPrecision());
}
if(m_lastAccessTimeHasBeenSet)
{
payload.WithDouble("LastAccessTime", m_lastAccessTime.SecondsWithMSPrecision());
}
if(m_tableTypeHasBeenSet)
{
payload.WithString("TableType", m_tableType);
}
if(m_columnsHasBeenSet)
{
Array<JsonValue> columnsJsonList(m_columns.size());
for(unsigned columnsIndex = 0; columnsIndex < columnsJsonList.GetLength(); ++columnsIndex)
{
columnsJsonList[columnsIndex].AsObject(m_columns[columnsIndex].Jsonize());
}
payload.WithArray("Columns", std::move(columnsJsonList));
}
if(m_partitionKeysHasBeenSet)
{
Array<JsonValue> partitionKeysJsonList(m_partitionKeys.size());
for(unsigned partitionKeysIndex = 0; partitionKeysIndex < partitionKeysJsonList.GetLength(); ++partitionKeysIndex)
{
partitionKeysJsonList[partitionKeysIndex].AsObject(m_partitionKeys[partitionKeysIndex].Jsonize());
}
payload.WithArray("PartitionKeys", std::move(partitionKeysJsonList));
}
if(m_parametersHasBeenSet)
{
JsonValue parametersJsonMap;
for(auto& parametersItem : m_parameters)
{
parametersJsonMap.WithString(parametersItem.first, parametersItem.second);
}
payload.WithObject("Parameters", std::move(parametersJsonMap));
}
return payload;
}
} // namespace Model
} // namespace Athena
} // namespace Aws