/** * 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 SSM { namespace Model { Association::Association() : m_nameHasBeenSet(false), m_instanceIdHasBeenSet(false), m_associationIdHasBeenSet(false), m_associationVersionHasBeenSet(false), m_documentVersionHasBeenSet(false), m_targetsHasBeenSet(false), m_lastExecutionDateHasBeenSet(false), m_overviewHasBeenSet(false), m_scheduleExpressionHasBeenSet(false), m_associationNameHasBeenSet(false), m_scheduleOffset(0), m_scheduleOffsetHasBeenSet(false), m_targetMapsHasBeenSet(false) { } Association::Association(JsonView jsonValue) : m_nameHasBeenSet(false), m_instanceIdHasBeenSet(false), m_associationIdHasBeenSet(false), m_associationVersionHasBeenSet(false), m_documentVersionHasBeenSet(false), m_targetsHasBeenSet(false), m_lastExecutionDateHasBeenSet(false), m_overviewHasBeenSet(false), m_scheduleExpressionHasBeenSet(false), m_associationNameHasBeenSet(false), m_scheduleOffset(0), m_scheduleOffsetHasBeenSet(false), m_targetMapsHasBeenSet(false) { *this = jsonValue; } Association& Association::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("Name")) { m_name = jsonValue.GetString("Name"); m_nameHasBeenSet = true; } if(jsonValue.ValueExists("InstanceId")) { m_instanceId = jsonValue.GetString("InstanceId"); m_instanceIdHasBeenSet = true; } if(jsonValue.ValueExists("AssociationId")) { m_associationId = jsonValue.GetString("AssociationId"); m_associationIdHasBeenSet = true; } if(jsonValue.ValueExists("AssociationVersion")) { m_associationVersion = jsonValue.GetString("AssociationVersion"); m_associationVersionHasBeenSet = true; } if(jsonValue.ValueExists("DocumentVersion")) { m_documentVersion = jsonValue.GetString("DocumentVersion"); m_documentVersionHasBeenSet = true; } if(jsonValue.ValueExists("Targets")) { Aws::Utils::Array targetsJsonList = jsonValue.GetArray("Targets"); for(unsigned targetsIndex = 0; targetsIndex < targetsJsonList.GetLength(); ++targetsIndex) { m_targets.push_back(targetsJsonList[targetsIndex].AsObject()); } m_targetsHasBeenSet = true; } if(jsonValue.ValueExists("LastExecutionDate")) { m_lastExecutionDate = jsonValue.GetDouble("LastExecutionDate"); m_lastExecutionDateHasBeenSet = true; } if(jsonValue.ValueExists("Overview")) { m_overview = jsonValue.GetObject("Overview"); m_overviewHasBeenSet = true; } if(jsonValue.ValueExists("ScheduleExpression")) { m_scheduleExpression = jsonValue.GetString("ScheduleExpression"); m_scheduleExpressionHasBeenSet = true; } if(jsonValue.ValueExists("AssociationName")) { m_associationName = jsonValue.GetString("AssociationName"); m_associationNameHasBeenSet = true; } if(jsonValue.ValueExists("ScheduleOffset")) { m_scheduleOffset = jsonValue.GetInteger("ScheduleOffset"); m_scheduleOffsetHasBeenSet = true; } if(jsonValue.ValueExists("TargetMaps")) { Aws::Utils::Array targetMapsJsonList = jsonValue.GetArray("TargetMaps"); for(unsigned targetMapsIndex = 0; targetMapsIndex < targetMapsJsonList.GetLength(); ++targetMapsIndex) { Aws::Map targetMapJsonMap = targetMapsJsonList[targetMapsIndex].GetAllObjects(); Aws::Map> targetMapMap; for(auto& targetMapItem : targetMapJsonMap) { Aws::Utils::Array targetMapValueListJsonList = targetMapItem.second.AsArray(); Aws::Vector targetMapValueListList; targetMapValueListList.reserve((size_t)targetMapValueListJsonList.GetLength()); for(unsigned targetMapValueListIndex = 0; targetMapValueListIndex < targetMapValueListJsonList.GetLength(); ++targetMapValueListIndex) { targetMapValueListList.push_back(targetMapValueListJsonList[targetMapValueListIndex].AsString()); } targetMapMap[targetMapItem.first] = std::move(targetMapValueListList); } m_targetMaps.push_back(std::move(targetMapMap)); } m_targetMapsHasBeenSet = true; } return *this; } JsonValue Association::Jsonize() const { JsonValue payload; if(m_nameHasBeenSet) { payload.WithString("Name", m_name); } if(m_instanceIdHasBeenSet) { payload.WithString("InstanceId", m_instanceId); } if(m_associationIdHasBeenSet) { payload.WithString("AssociationId", m_associationId); } if(m_associationVersionHasBeenSet) { payload.WithString("AssociationVersion", m_associationVersion); } if(m_documentVersionHasBeenSet) { payload.WithString("DocumentVersion", m_documentVersion); } if(m_targetsHasBeenSet) { Aws::Utils::Array targetsJsonList(m_targets.size()); for(unsigned targetsIndex = 0; targetsIndex < targetsJsonList.GetLength(); ++targetsIndex) { targetsJsonList[targetsIndex].AsObject(m_targets[targetsIndex].Jsonize()); } payload.WithArray("Targets", std::move(targetsJsonList)); } if(m_lastExecutionDateHasBeenSet) { payload.WithDouble("LastExecutionDate", m_lastExecutionDate.SecondsWithMSPrecision()); } if(m_overviewHasBeenSet) { payload.WithObject("Overview", m_overview.Jsonize()); } if(m_scheduleExpressionHasBeenSet) { payload.WithString("ScheduleExpression", m_scheduleExpression); } if(m_associationNameHasBeenSet) { payload.WithString("AssociationName", m_associationName); } if(m_scheduleOffsetHasBeenSet) { payload.WithInteger("ScheduleOffset", m_scheduleOffset); } if(m_targetMapsHasBeenSet) { Aws::Utils::Array targetMapsJsonList(m_targetMaps.size()); for(unsigned targetMapsIndex = 0; targetMapsIndex < targetMapsJsonList.GetLength(); ++targetMapsIndex) { JsonValue targetMapJsonMap; for(auto& targetMapItem : m_targetMaps[targetMapsIndex]) { Aws::Utils::Array targetMapValueListJsonList(targetMapItem.second.size()); for(unsigned targetMapValueListIndex = 0; targetMapValueListIndex < targetMapValueListJsonList.GetLength(); ++targetMapValueListIndex) { targetMapValueListJsonList[targetMapValueListIndex].AsString(targetMapItem.second[targetMapValueListIndex]); } targetMapJsonMap.WithArray(targetMapItem.first, std::move(targetMapValueListJsonList)); } targetMapsJsonList[targetMapsIndex].AsObject(std::move(targetMapJsonMap)); } payload.WithArray("TargetMaps", std::move(targetMapsJsonList)); } return payload; } } // namespace Model } // namespace SSM } // namespace Aws