/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include #include #include #include #include #include using namespace Aws::RecycleBin::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; CreateRuleResult::CreateRuleResult() : m_resourceType(ResourceType::NOT_SET), m_status(RuleStatus::NOT_SET), m_lockState(LockState::NOT_SET) { } CreateRuleResult::CreateRuleResult(const Aws::AmazonWebServiceResult& result) : m_resourceType(ResourceType::NOT_SET), m_status(RuleStatus::NOT_SET), m_lockState(LockState::NOT_SET) { *this = result; } CreateRuleResult& CreateRuleResult::operator =(const Aws::AmazonWebServiceResult& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("Identifier")) { m_identifier = jsonValue.GetString("Identifier"); } if(jsonValue.ValueExists("RetentionPeriod")) { m_retentionPeriod = jsonValue.GetObject("RetentionPeriod"); } if(jsonValue.ValueExists("Description")) { m_description = jsonValue.GetString("Description"); } if(jsonValue.ValueExists("Tags")) { Aws::Utils::Array tagsJsonList = jsonValue.GetArray("Tags"); for(unsigned tagsIndex = 0; tagsIndex < tagsJsonList.GetLength(); ++tagsIndex) { m_tags.push_back(tagsJsonList[tagsIndex].AsObject()); } } if(jsonValue.ValueExists("ResourceType")) { m_resourceType = ResourceTypeMapper::GetResourceTypeForName(jsonValue.GetString("ResourceType")); } if(jsonValue.ValueExists("ResourceTags")) { Aws::Utils::Array resourceTagsJsonList = jsonValue.GetArray("ResourceTags"); for(unsigned resourceTagsIndex = 0; resourceTagsIndex < resourceTagsJsonList.GetLength(); ++resourceTagsIndex) { m_resourceTags.push_back(resourceTagsJsonList[resourceTagsIndex].AsObject()); } } if(jsonValue.ValueExists("Status")) { m_status = RuleStatusMapper::GetRuleStatusForName(jsonValue.GetString("Status")); } if(jsonValue.ValueExists("LockConfiguration")) { m_lockConfiguration = jsonValue.GetObject("LockConfiguration"); } if(jsonValue.ValueExists("LockState")) { m_lockState = LockStateMapper::GetLockStateForName(jsonValue.GetString("LockState")); } const auto& headers = result.GetHeaderValueCollection(); const auto& requestIdIter = headers.find("x-amzn-requestid"); if(requestIdIter != headers.end()) { m_requestId = requestIdIter->second; } return *this; }