248 lines
7.4 KiB
C++
248 lines
7.4 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/ec2/model/SnapshotInfo.h>
|
|
#include <aws/core/utils/xml/XmlSerializer.h>
|
|
#include <aws/core/utils/StringUtils.h>
|
|
#include <aws/core/utils/memory/stl/AWSStringStream.h>
|
|
|
|
#include <utility>
|
|
|
|
using namespace Aws::Utils::Xml;
|
|
using namespace Aws::Utils;
|
|
|
|
namespace Aws
|
|
{
|
|
namespace EC2
|
|
{
|
|
namespace Model
|
|
{
|
|
|
|
SnapshotInfo::SnapshotInfo() :
|
|
m_descriptionHasBeenSet(false),
|
|
m_tagsHasBeenSet(false),
|
|
m_encrypted(false),
|
|
m_encryptedHasBeenSet(false),
|
|
m_volumeIdHasBeenSet(false),
|
|
m_state(SnapshotState::NOT_SET),
|
|
m_stateHasBeenSet(false),
|
|
m_volumeSize(0),
|
|
m_volumeSizeHasBeenSet(false),
|
|
m_startTimeHasBeenSet(false),
|
|
m_progressHasBeenSet(false),
|
|
m_ownerIdHasBeenSet(false),
|
|
m_snapshotIdHasBeenSet(false)
|
|
{
|
|
}
|
|
|
|
SnapshotInfo::SnapshotInfo(const XmlNode& xmlNode) :
|
|
m_descriptionHasBeenSet(false),
|
|
m_tagsHasBeenSet(false),
|
|
m_encrypted(false),
|
|
m_encryptedHasBeenSet(false),
|
|
m_volumeIdHasBeenSet(false),
|
|
m_state(SnapshotState::NOT_SET),
|
|
m_stateHasBeenSet(false),
|
|
m_volumeSize(0),
|
|
m_volumeSizeHasBeenSet(false),
|
|
m_startTimeHasBeenSet(false),
|
|
m_progressHasBeenSet(false),
|
|
m_ownerIdHasBeenSet(false),
|
|
m_snapshotIdHasBeenSet(false)
|
|
{
|
|
*this = xmlNode;
|
|
}
|
|
|
|
SnapshotInfo& SnapshotInfo::operator =(const XmlNode& xmlNode)
|
|
{
|
|
XmlNode resultNode = xmlNode;
|
|
|
|
if(!resultNode.IsNull())
|
|
{
|
|
XmlNode descriptionNode = resultNode.FirstChild("description");
|
|
if(!descriptionNode.IsNull())
|
|
{
|
|
m_description = Aws::Utils::Xml::DecodeEscapedXmlText(descriptionNode.GetText());
|
|
m_descriptionHasBeenSet = true;
|
|
}
|
|
XmlNode tagsNode = resultNode.FirstChild("tagSet");
|
|
if(!tagsNode.IsNull())
|
|
{
|
|
XmlNode tagsMember = tagsNode.FirstChild("item");
|
|
while(!tagsMember.IsNull())
|
|
{
|
|
m_tags.push_back(tagsMember);
|
|
tagsMember = tagsMember.NextNode("item");
|
|
}
|
|
|
|
m_tagsHasBeenSet = true;
|
|
}
|
|
XmlNode encryptedNode = resultNode.FirstChild("encrypted");
|
|
if(!encryptedNode.IsNull())
|
|
{
|
|
m_encrypted = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(encryptedNode.GetText()).c_str()).c_str());
|
|
m_encryptedHasBeenSet = true;
|
|
}
|
|
XmlNode volumeIdNode = resultNode.FirstChild("volumeId");
|
|
if(!volumeIdNode.IsNull())
|
|
{
|
|
m_volumeId = Aws::Utils::Xml::DecodeEscapedXmlText(volumeIdNode.GetText());
|
|
m_volumeIdHasBeenSet = true;
|
|
}
|
|
XmlNode stateNode = resultNode.FirstChild("state");
|
|
if(!stateNode.IsNull())
|
|
{
|
|
m_state = SnapshotStateMapper::GetSnapshotStateForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(stateNode.GetText()).c_str()).c_str());
|
|
m_stateHasBeenSet = true;
|
|
}
|
|
XmlNode volumeSizeNode = resultNode.FirstChild("volumeSize");
|
|
if(!volumeSizeNode.IsNull())
|
|
{
|
|
m_volumeSize = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(volumeSizeNode.GetText()).c_str()).c_str());
|
|
m_volumeSizeHasBeenSet = true;
|
|
}
|
|
XmlNode startTimeNode = resultNode.FirstChild("startTime");
|
|
if(!startTimeNode.IsNull())
|
|
{
|
|
m_startTime = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(startTimeNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
|
|
m_startTimeHasBeenSet = true;
|
|
}
|
|
XmlNode progressNode = resultNode.FirstChild("progress");
|
|
if(!progressNode.IsNull())
|
|
{
|
|
m_progress = Aws::Utils::Xml::DecodeEscapedXmlText(progressNode.GetText());
|
|
m_progressHasBeenSet = true;
|
|
}
|
|
XmlNode ownerIdNode = resultNode.FirstChild("ownerId");
|
|
if(!ownerIdNode.IsNull())
|
|
{
|
|
m_ownerId = Aws::Utils::Xml::DecodeEscapedXmlText(ownerIdNode.GetText());
|
|
m_ownerIdHasBeenSet = true;
|
|
}
|
|
XmlNode snapshotIdNode = resultNode.FirstChild("snapshotId");
|
|
if(!snapshotIdNode.IsNull())
|
|
{
|
|
m_snapshotId = Aws::Utils::Xml::DecodeEscapedXmlText(snapshotIdNode.GetText());
|
|
m_snapshotIdHasBeenSet = true;
|
|
}
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
void SnapshotInfo::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
|
|
{
|
|
if(m_descriptionHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".Description=" << StringUtils::URLEncode(m_description.c_str()) << "&";
|
|
}
|
|
|
|
if(m_tagsHasBeenSet)
|
|
{
|
|
unsigned tagsIdx = 1;
|
|
for(auto& item : m_tags)
|
|
{
|
|
Aws::StringStream tagsSs;
|
|
tagsSs << location << index << locationValue << ".TagSet." << tagsIdx++;
|
|
item.OutputToStream(oStream, tagsSs.str().c_str());
|
|
}
|
|
}
|
|
|
|
if(m_encryptedHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".Encrypted=" << std::boolalpha << m_encrypted << "&";
|
|
}
|
|
|
|
if(m_volumeIdHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".VolumeId=" << StringUtils::URLEncode(m_volumeId.c_str()) << "&";
|
|
}
|
|
|
|
if(m_stateHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".State=" << SnapshotStateMapper::GetNameForSnapshotState(m_state) << "&";
|
|
}
|
|
|
|
if(m_volumeSizeHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".VolumeSize=" << m_volumeSize << "&";
|
|
}
|
|
|
|
if(m_startTimeHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".StartTime=" << StringUtils::URLEncode(m_startTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
|
|
}
|
|
|
|
if(m_progressHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".Progress=" << StringUtils::URLEncode(m_progress.c_str()) << "&";
|
|
}
|
|
|
|
if(m_ownerIdHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".OwnerId=" << StringUtils::URLEncode(m_ownerId.c_str()) << "&";
|
|
}
|
|
|
|
if(m_snapshotIdHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".SnapshotId=" << StringUtils::URLEncode(m_snapshotId.c_str()) << "&";
|
|
}
|
|
|
|
}
|
|
|
|
void SnapshotInfo::OutputToStream(Aws::OStream& oStream, const char* location) const
|
|
{
|
|
if(m_descriptionHasBeenSet)
|
|
{
|
|
oStream << location << ".Description=" << StringUtils::URLEncode(m_description.c_str()) << "&";
|
|
}
|
|
if(m_tagsHasBeenSet)
|
|
{
|
|
unsigned tagsIdx = 1;
|
|
for(auto& item : m_tags)
|
|
{
|
|
Aws::StringStream tagsSs;
|
|
tagsSs << location << ".TagSet." << tagsIdx++;
|
|
item.OutputToStream(oStream, tagsSs.str().c_str());
|
|
}
|
|
}
|
|
if(m_encryptedHasBeenSet)
|
|
{
|
|
oStream << location << ".Encrypted=" << std::boolalpha << m_encrypted << "&";
|
|
}
|
|
if(m_volumeIdHasBeenSet)
|
|
{
|
|
oStream << location << ".VolumeId=" << StringUtils::URLEncode(m_volumeId.c_str()) << "&";
|
|
}
|
|
if(m_stateHasBeenSet)
|
|
{
|
|
oStream << location << ".State=" << SnapshotStateMapper::GetNameForSnapshotState(m_state) << "&";
|
|
}
|
|
if(m_volumeSizeHasBeenSet)
|
|
{
|
|
oStream << location << ".VolumeSize=" << m_volumeSize << "&";
|
|
}
|
|
if(m_startTimeHasBeenSet)
|
|
{
|
|
oStream << location << ".StartTime=" << StringUtils::URLEncode(m_startTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
|
|
}
|
|
if(m_progressHasBeenSet)
|
|
{
|
|
oStream << location << ".Progress=" << StringUtils::URLEncode(m_progress.c_str()) << "&";
|
|
}
|
|
if(m_ownerIdHasBeenSet)
|
|
{
|
|
oStream << location << ".OwnerId=" << StringUtils::URLEncode(m_ownerId.c_str()) << "&";
|
|
}
|
|
if(m_snapshotIdHasBeenSet)
|
|
{
|
|
oStream << location << ".SnapshotId=" << StringUtils::URLEncode(m_snapshotId.c_str()) << "&";
|
|
}
|
|
}
|
|
|
|
} // namespace Model
|
|
} // namespace EC2
|
|
} // namespace Aws
|