/** * 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 GuardDuty { namespace Model { UsageStatistics::UsageStatistics() : m_sumByAccountHasBeenSet(false), m_sumByDataSourceHasBeenSet(false), m_sumByResourceHasBeenSet(false), m_topResourcesHasBeenSet(false), m_sumByFeatureHasBeenSet(false) { } UsageStatistics::UsageStatistics(JsonView jsonValue) : m_sumByAccountHasBeenSet(false), m_sumByDataSourceHasBeenSet(false), m_sumByResourceHasBeenSet(false), m_topResourcesHasBeenSet(false), m_sumByFeatureHasBeenSet(false) { *this = jsonValue; } UsageStatistics& UsageStatistics::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("sumByAccount")) { Aws::Utils::Array sumByAccountJsonList = jsonValue.GetArray("sumByAccount"); for(unsigned sumByAccountIndex = 0; sumByAccountIndex < sumByAccountJsonList.GetLength(); ++sumByAccountIndex) { m_sumByAccount.push_back(sumByAccountJsonList[sumByAccountIndex].AsObject()); } m_sumByAccountHasBeenSet = true; } if(jsonValue.ValueExists("sumByDataSource")) { Aws::Utils::Array sumByDataSourceJsonList = jsonValue.GetArray("sumByDataSource"); for(unsigned sumByDataSourceIndex = 0; sumByDataSourceIndex < sumByDataSourceJsonList.GetLength(); ++sumByDataSourceIndex) { m_sumByDataSource.push_back(sumByDataSourceJsonList[sumByDataSourceIndex].AsObject()); } m_sumByDataSourceHasBeenSet = true; } if(jsonValue.ValueExists("sumByResource")) { Aws::Utils::Array sumByResourceJsonList = jsonValue.GetArray("sumByResource"); for(unsigned sumByResourceIndex = 0; sumByResourceIndex < sumByResourceJsonList.GetLength(); ++sumByResourceIndex) { m_sumByResource.push_back(sumByResourceJsonList[sumByResourceIndex].AsObject()); } m_sumByResourceHasBeenSet = true; } if(jsonValue.ValueExists("topResources")) { Aws::Utils::Array topResourcesJsonList = jsonValue.GetArray("topResources"); for(unsigned topResourcesIndex = 0; topResourcesIndex < topResourcesJsonList.GetLength(); ++topResourcesIndex) { m_topResources.push_back(topResourcesJsonList[topResourcesIndex].AsObject()); } m_topResourcesHasBeenSet = true; } if(jsonValue.ValueExists("sumByFeature")) { Aws::Utils::Array sumByFeatureJsonList = jsonValue.GetArray("sumByFeature"); for(unsigned sumByFeatureIndex = 0; sumByFeatureIndex < sumByFeatureJsonList.GetLength(); ++sumByFeatureIndex) { m_sumByFeature.push_back(sumByFeatureJsonList[sumByFeatureIndex].AsObject()); } m_sumByFeatureHasBeenSet = true; } return *this; } JsonValue UsageStatistics::Jsonize() const { JsonValue payload; if(m_sumByAccountHasBeenSet) { Aws::Utils::Array sumByAccountJsonList(m_sumByAccount.size()); for(unsigned sumByAccountIndex = 0; sumByAccountIndex < sumByAccountJsonList.GetLength(); ++sumByAccountIndex) { sumByAccountJsonList[sumByAccountIndex].AsObject(m_sumByAccount[sumByAccountIndex].Jsonize()); } payload.WithArray("sumByAccount", std::move(sumByAccountJsonList)); } if(m_sumByDataSourceHasBeenSet) { Aws::Utils::Array sumByDataSourceJsonList(m_sumByDataSource.size()); for(unsigned sumByDataSourceIndex = 0; sumByDataSourceIndex < sumByDataSourceJsonList.GetLength(); ++sumByDataSourceIndex) { sumByDataSourceJsonList[sumByDataSourceIndex].AsObject(m_sumByDataSource[sumByDataSourceIndex].Jsonize()); } payload.WithArray("sumByDataSource", std::move(sumByDataSourceJsonList)); } if(m_sumByResourceHasBeenSet) { Aws::Utils::Array sumByResourceJsonList(m_sumByResource.size()); for(unsigned sumByResourceIndex = 0; sumByResourceIndex < sumByResourceJsonList.GetLength(); ++sumByResourceIndex) { sumByResourceJsonList[sumByResourceIndex].AsObject(m_sumByResource[sumByResourceIndex].Jsonize()); } payload.WithArray("sumByResource", std::move(sumByResourceJsonList)); } if(m_topResourcesHasBeenSet) { Aws::Utils::Array topResourcesJsonList(m_topResources.size()); for(unsigned topResourcesIndex = 0; topResourcesIndex < topResourcesJsonList.GetLength(); ++topResourcesIndex) { topResourcesJsonList[topResourcesIndex].AsObject(m_topResources[topResourcesIndex].Jsonize()); } payload.WithArray("topResources", std::move(topResourcesJsonList)); } if(m_sumByFeatureHasBeenSet) { Aws::Utils::Array sumByFeatureJsonList(m_sumByFeature.size()); for(unsigned sumByFeatureIndex = 0; sumByFeatureIndex < sumByFeatureJsonList.GetLength(); ++sumByFeatureIndex) { sumByFeatureJsonList[sumByFeatureIndex].AsObject(m_sumByFeature[sumByFeatureIndex].Jsonize()); } payload.WithArray("sumByFeature", std::move(sumByFeatureJsonList)); } return payload; } } // namespace Model } // namespace GuardDuty } // namespace Aws