1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 6 #include <aws/ssm/model/UpdatePatchBaselineResult.h> 7 #include <aws/core/utils/json/JsonSerializer.h> 8 #include <aws/core/AmazonWebServiceResult.h> 9 #include <aws/core/utils/StringUtils.h> 10 #include <aws/core/utils/UnreferencedParam.h> 11 12 #include <utility> 13 14 using namespace Aws::SSM::Model; 15 using namespace Aws::Utils::Json; 16 using namespace Aws::Utils; 17 using namespace Aws; 18 UpdatePatchBaselineResult()19UpdatePatchBaselineResult::UpdatePatchBaselineResult() : 20 m_operatingSystem(OperatingSystem::NOT_SET), 21 m_approvedPatchesComplianceLevel(PatchComplianceLevel::NOT_SET), 22 m_approvedPatchesEnableNonSecurity(false), 23 m_rejectedPatchesAction(PatchAction::NOT_SET) 24 { 25 } 26 UpdatePatchBaselineResult(const Aws::AmazonWebServiceResult<JsonValue> & result)27UpdatePatchBaselineResult::UpdatePatchBaselineResult(const Aws::AmazonWebServiceResult<JsonValue>& result) : 28 m_operatingSystem(OperatingSystem::NOT_SET), 29 m_approvedPatchesComplianceLevel(PatchComplianceLevel::NOT_SET), 30 m_approvedPatchesEnableNonSecurity(false), 31 m_rejectedPatchesAction(PatchAction::NOT_SET) 32 { 33 *this = result; 34 } 35 operator =(const Aws::AmazonWebServiceResult<JsonValue> & result)36UpdatePatchBaselineResult& UpdatePatchBaselineResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) 37 { 38 JsonView jsonValue = result.GetPayload().View(); 39 if(jsonValue.ValueExists("BaselineId")) 40 { 41 m_baselineId = jsonValue.GetString("BaselineId"); 42 43 } 44 45 if(jsonValue.ValueExists("Name")) 46 { 47 m_name = jsonValue.GetString("Name"); 48 49 } 50 51 if(jsonValue.ValueExists("OperatingSystem")) 52 { 53 m_operatingSystem = OperatingSystemMapper::GetOperatingSystemForName(jsonValue.GetString("OperatingSystem")); 54 55 } 56 57 if(jsonValue.ValueExists("GlobalFilters")) 58 { 59 m_globalFilters = jsonValue.GetObject("GlobalFilters"); 60 61 } 62 63 if(jsonValue.ValueExists("ApprovalRules")) 64 { 65 m_approvalRules = jsonValue.GetObject("ApprovalRules"); 66 67 } 68 69 if(jsonValue.ValueExists("ApprovedPatches")) 70 { 71 Array<JsonView> approvedPatchesJsonList = jsonValue.GetArray("ApprovedPatches"); 72 for(unsigned approvedPatchesIndex = 0; approvedPatchesIndex < approvedPatchesJsonList.GetLength(); ++approvedPatchesIndex) 73 { 74 m_approvedPatches.push_back(approvedPatchesJsonList[approvedPatchesIndex].AsString()); 75 } 76 } 77 78 if(jsonValue.ValueExists("ApprovedPatchesComplianceLevel")) 79 { 80 m_approvedPatchesComplianceLevel = PatchComplianceLevelMapper::GetPatchComplianceLevelForName(jsonValue.GetString("ApprovedPatchesComplianceLevel")); 81 82 } 83 84 if(jsonValue.ValueExists("ApprovedPatchesEnableNonSecurity")) 85 { 86 m_approvedPatchesEnableNonSecurity = jsonValue.GetBool("ApprovedPatchesEnableNonSecurity"); 87 88 } 89 90 if(jsonValue.ValueExists("RejectedPatches")) 91 { 92 Array<JsonView> rejectedPatchesJsonList = jsonValue.GetArray("RejectedPatches"); 93 for(unsigned rejectedPatchesIndex = 0; rejectedPatchesIndex < rejectedPatchesJsonList.GetLength(); ++rejectedPatchesIndex) 94 { 95 m_rejectedPatches.push_back(rejectedPatchesJsonList[rejectedPatchesIndex].AsString()); 96 } 97 } 98 99 if(jsonValue.ValueExists("RejectedPatchesAction")) 100 { 101 m_rejectedPatchesAction = PatchActionMapper::GetPatchActionForName(jsonValue.GetString("RejectedPatchesAction")); 102 103 } 104 105 if(jsonValue.ValueExists("CreatedDate")) 106 { 107 m_createdDate = jsonValue.GetDouble("CreatedDate"); 108 109 } 110 111 if(jsonValue.ValueExists("ModifiedDate")) 112 { 113 m_modifiedDate = jsonValue.GetDouble("ModifiedDate"); 114 115 } 116 117 if(jsonValue.ValueExists("Description")) 118 { 119 m_description = jsonValue.GetString("Description"); 120 121 } 122 123 if(jsonValue.ValueExists("Sources")) 124 { 125 Array<JsonView> sourcesJsonList = jsonValue.GetArray("Sources"); 126 for(unsigned sourcesIndex = 0; sourcesIndex < sourcesJsonList.GetLength(); ++sourcesIndex) 127 { 128 m_sources.push_back(sourcesJsonList[sourcesIndex].AsObject()); 129 } 130 } 131 132 133 134 return *this; 135 } 136