/** * 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 DLM { namespace Model { PolicyDetails::PolicyDetails() : m_policyType(PolicyTypeValues::NOT_SET), m_policyTypeHasBeenSet(false), m_resourceTypesHasBeenSet(false), m_targetTagsHasBeenSet(false), m_schedulesHasBeenSet(false), m_parametersHasBeenSet(false) { } PolicyDetails::PolicyDetails(JsonView jsonValue) : m_policyType(PolicyTypeValues::NOT_SET), m_policyTypeHasBeenSet(false), m_resourceTypesHasBeenSet(false), m_targetTagsHasBeenSet(false), m_schedulesHasBeenSet(false), m_parametersHasBeenSet(false) { *this = jsonValue; } PolicyDetails& PolicyDetails::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("PolicyType")) { m_policyType = PolicyTypeValuesMapper::GetPolicyTypeValuesForName(jsonValue.GetString("PolicyType")); m_policyTypeHasBeenSet = true; } if(jsonValue.ValueExists("ResourceTypes")) { Array resourceTypesJsonList = jsonValue.GetArray("ResourceTypes"); for(unsigned resourceTypesIndex = 0; resourceTypesIndex < resourceTypesJsonList.GetLength(); ++resourceTypesIndex) { m_resourceTypes.push_back(ResourceTypeValuesMapper::GetResourceTypeValuesForName(resourceTypesJsonList[resourceTypesIndex].AsString())); } m_resourceTypesHasBeenSet = true; } if(jsonValue.ValueExists("TargetTags")) { Array targetTagsJsonList = jsonValue.GetArray("TargetTags"); for(unsigned targetTagsIndex = 0; targetTagsIndex < targetTagsJsonList.GetLength(); ++targetTagsIndex) { m_targetTags.push_back(targetTagsJsonList[targetTagsIndex].AsObject()); } m_targetTagsHasBeenSet = true; } if(jsonValue.ValueExists("Schedules")) { Array schedulesJsonList = jsonValue.GetArray("Schedules"); for(unsigned schedulesIndex = 0; schedulesIndex < schedulesJsonList.GetLength(); ++schedulesIndex) { m_schedules.push_back(schedulesJsonList[schedulesIndex].AsObject()); } m_schedulesHasBeenSet = true; } if(jsonValue.ValueExists("Parameters")) { m_parameters = jsonValue.GetObject("Parameters"); m_parametersHasBeenSet = true; } return *this; } JsonValue PolicyDetails::Jsonize() const { JsonValue payload; if(m_policyTypeHasBeenSet) { payload.WithString("PolicyType", PolicyTypeValuesMapper::GetNameForPolicyTypeValues(m_policyType)); } if(m_resourceTypesHasBeenSet) { Array resourceTypesJsonList(m_resourceTypes.size()); for(unsigned resourceTypesIndex = 0; resourceTypesIndex < resourceTypesJsonList.GetLength(); ++resourceTypesIndex) { resourceTypesJsonList[resourceTypesIndex].AsString(ResourceTypeValuesMapper::GetNameForResourceTypeValues(m_resourceTypes[resourceTypesIndex])); } payload.WithArray("ResourceTypes", std::move(resourceTypesJsonList)); } if(m_targetTagsHasBeenSet) { Array targetTagsJsonList(m_targetTags.size()); for(unsigned targetTagsIndex = 0; targetTagsIndex < targetTagsJsonList.GetLength(); ++targetTagsIndex) { targetTagsJsonList[targetTagsIndex].AsObject(m_targetTags[targetTagsIndex].Jsonize()); } payload.WithArray("TargetTags", std::move(targetTagsJsonList)); } if(m_schedulesHasBeenSet) { Array schedulesJsonList(m_schedules.size()); for(unsigned schedulesIndex = 0; schedulesIndex < schedulesJsonList.GetLength(); ++schedulesIndex) { schedulesJsonList[schedulesIndex].AsObject(m_schedules[schedulesIndex].Jsonize()); } payload.WithArray("Schedules", std::move(schedulesJsonList)); } if(m_parametersHasBeenSet) { payload.WithObject("Parameters", m_parameters.Jsonize()); } return payload; } } // namespace Model } // namespace DLM } // namespace Aws