/** * 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 { UsageCriteria::UsageCriteria() : m_accountIdsHasBeenSet(false), m_dataSourcesHasBeenSet(false), m_resourcesHasBeenSet(false) { } UsageCriteria::UsageCriteria(JsonView jsonValue) : m_accountIdsHasBeenSet(false), m_dataSourcesHasBeenSet(false), m_resourcesHasBeenSet(false) { *this = jsonValue; } UsageCriteria& UsageCriteria::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("accountIds")) { Array accountIdsJsonList = jsonValue.GetArray("accountIds"); for(unsigned accountIdsIndex = 0; accountIdsIndex < accountIdsJsonList.GetLength(); ++accountIdsIndex) { m_accountIds.push_back(accountIdsJsonList[accountIdsIndex].AsString()); } m_accountIdsHasBeenSet = true; } if(jsonValue.ValueExists("dataSources")) { Array dataSourcesJsonList = jsonValue.GetArray("dataSources"); for(unsigned dataSourcesIndex = 0; dataSourcesIndex < dataSourcesJsonList.GetLength(); ++dataSourcesIndex) { m_dataSources.push_back(DataSourceMapper::GetDataSourceForName(dataSourcesJsonList[dataSourcesIndex].AsString())); } m_dataSourcesHasBeenSet = true; } if(jsonValue.ValueExists("resources")) { Array resourcesJsonList = jsonValue.GetArray("resources"); for(unsigned resourcesIndex = 0; resourcesIndex < resourcesJsonList.GetLength(); ++resourcesIndex) { m_resources.push_back(resourcesJsonList[resourcesIndex].AsString()); } m_resourcesHasBeenSet = true; } return *this; } JsonValue UsageCriteria::Jsonize() const { JsonValue payload; if(m_accountIdsHasBeenSet) { Array accountIdsJsonList(m_accountIds.size()); for(unsigned accountIdsIndex = 0; accountIdsIndex < accountIdsJsonList.GetLength(); ++accountIdsIndex) { accountIdsJsonList[accountIdsIndex].AsString(m_accountIds[accountIdsIndex]); } payload.WithArray("accountIds", std::move(accountIdsJsonList)); } if(m_dataSourcesHasBeenSet) { Array dataSourcesJsonList(m_dataSources.size()); for(unsigned dataSourcesIndex = 0; dataSourcesIndex < dataSourcesJsonList.GetLength(); ++dataSourcesIndex) { dataSourcesJsonList[dataSourcesIndex].AsString(DataSourceMapper::GetNameForDataSource(m_dataSources[dataSourcesIndex])); } payload.WithArray("dataSources", std::move(dataSourcesJsonList)); } if(m_resourcesHasBeenSet) { Array resourcesJsonList(m_resources.size()); for(unsigned resourcesIndex = 0; resourcesIndex < resourcesJsonList.GetLength(); ++resourcesIndex) { resourcesJsonList[resourcesIndex].AsString(m_resources[resourcesIndex]); } payload.WithArray("resources", std::move(resourcesJsonList)); } return payload; } } // namespace Model } // namespace GuardDuty } // namespace Aws