/** * 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 ComputeOptimizer { namespace Model { ProjectedMetric::ProjectedMetric() : m_name(MetricName::NOT_SET), m_nameHasBeenSet(false), m_timestampsHasBeenSet(false), m_valuesHasBeenSet(false) { } ProjectedMetric::ProjectedMetric(JsonView jsonValue) : m_name(MetricName::NOT_SET), m_nameHasBeenSet(false), m_timestampsHasBeenSet(false), m_valuesHasBeenSet(false) { *this = jsonValue; } ProjectedMetric& ProjectedMetric::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("name")) { m_name = MetricNameMapper::GetMetricNameForName(jsonValue.GetString("name")); m_nameHasBeenSet = true; } if(jsonValue.ValueExists("timestamps")) { Aws::Utils::Array timestampsJsonList = jsonValue.GetArray("timestamps"); for(unsigned timestampsIndex = 0; timestampsIndex < timestampsJsonList.GetLength(); ++timestampsIndex) { m_timestamps.push_back(timestampsJsonList[timestampsIndex].AsDouble()); } m_timestampsHasBeenSet = true; } if(jsonValue.ValueExists("values")) { Aws::Utils::Array valuesJsonList = jsonValue.GetArray("values"); for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex) { m_values.push_back(valuesJsonList[valuesIndex].AsDouble()); } m_valuesHasBeenSet = true; } return *this; } JsonValue ProjectedMetric::Jsonize() const { JsonValue payload; if(m_nameHasBeenSet) { payload.WithString("name", MetricNameMapper::GetNameForMetricName(m_name)); } if(m_timestampsHasBeenSet) { Aws::Utils::Array timestampsJsonList(m_timestamps.size()); for(unsigned timestampsIndex = 0; timestampsIndex < timestampsJsonList.GetLength(); ++timestampsIndex) { timestampsJsonList[timestampsIndex].AsDouble(m_timestamps[timestampsIndex].SecondsWithMSPrecision()); } payload.WithArray("timestamps", std::move(timestampsJsonList)); } if(m_valuesHasBeenSet) { Aws::Utils::Array valuesJsonList(m_values.size()); for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex) { valuesJsonList[valuesIndex].AsDouble(m_values[valuesIndex]); } payload.WithArray("values", std::move(valuesJsonList)); } return payload; } } // namespace Model } // namespace ComputeOptimizer } // namespace Aws