1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/iam/model/GenerateCredentialReportResult.h>
7 #include <aws/core/utils/xml/XmlSerializer.h>
8 #include <aws/core/AmazonWebServiceResult.h>
9 #include <aws/core/utils/StringUtils.h>
10 #include <aws/core/utils/logging/LogMacros.h>
11 
12 #include <utility>
13 
14 using namespace Aws::IAM::Model;
15 using namespace Aws::Utils::Xml;
16 using namespace Aws::Utils::Logging;
17 using namespace Aws::Utils;
18 using namespace Aws;
19 
GenerateCredentialReportResult()20 GenerateCredentialReportResult::GenerateCredentialReportResult() :
21     m_state(ReportStateType::NOT_SET)
22 {
23 }
24 
GenerateCredentialReportResult(const Aws::AmazonWebServiceResult<XmlDocument> & result)25 GenerateCredentialReportResult::GenerateCredentialReportResult(const Aws::AmazonWebServiceResult<XmlDocument>& result) :
26     m_state(ReportStateType::NOT_SET)
27 {
28   *this = result;
29 }
30 
operator =(const Aws::AmazonWebServiceResult<XmlDocument> & result)31 GenerateCredentialReportResult& GenerateCredentialReportResult::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result)
32 {
33   const XmlDocument& xmlDocument = result.GetPayload();
34   XmlNode rootNode = xmlDocument.GetRootElement();
35   XmlNode resultNode = rootNode;
36   if (!rootNode.IsNull() && (rootNode.GetName() != "GenerateCredentialReportResult"))
37   {
38     resultNode = rootNode.FirstChild("GenerateCredentialReportResult");
39   }
40 
41   if(!resultNode.IsNull())
42   {
43     XmlNode stateNode = resultNode.FirstChild("State");
44     if(!stateNode.IsNull())
45     {
46       m_state = ReportStateTypeMapper::GetReportStateTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(stateNode.GetText()).c_str()).c_str());
47     }
48     XmlNode descriptionNode = resultNode.FirstChild("Description");
49     if(!descriptionNode.IsNull())
50     {
51       m_description = Aws::Utils::Xml::DecodeEscapedXmlText(descriptionNode.GetText());
52     }
53   }
54 
55   if (!rootNode.IsNull()) {
56     XmlNode responseMetadataNode = rootNode.FirstChild("ResponseMetadata");
57     m_responseMetadata = responseMetadataNode;
58     AWS_LOGSTREAM_DEBUG("Aws::IAM::Model::GenerateCredentialReportResult", "x-amzn-request-id: " << m_responseMetadata.GetRequestId() );
59   }
60   return *this;
61 }
62