/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include #include 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")) { Aws::Utils::Array 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")) { Aws::Utils::Array 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 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) { Aws::Utils::Array 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) { Aws::Utils::Array 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