374 lines
12 KiB
C++
374 lines
12 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/ec2/model/Volume.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
|
|
{
|
|
|
|
Volume::Volume() :
|
|
m_attachmentsHasBeenSet(false),
|
|
m_availabilityZoneHasBeenSet(false),
|
|
m_createTimeHasBeenSet(false),
|
|
m_encrypted(false),
|
|
m_encryptedHasBeenSet(false),
|
|
m_kmsKeyIdHasBeenSet(false),
|
|
m_outpostArnHasBeenSet(false),
|
|
m_size(0),
|
|
m_sizeHasBeenSet(false),
|
|
m_snapshotIdHasBeenSet(false),
|
|
m_state(VolumeState::NOT_SET),
|
|
m_stateHasBeenSet(false),
|
|
m_volumeIdHasBeenSet(false),
|
|
m_iops(0),
|
|
m_iopsHasBeenSet(false),
|
|
m_tagsHasBeenSet(false),
|
|
m_volumeType(VolumeType::NOT_SET),
|
|
m_volumeTypeHasBeenSet(false),
|
|
m_fastRestored(false),
|
|
m_fastRestoredHasBeenSet(false),
|
|
m_multiAttachEnabled(false),
|
|
m_multiAttachEnabledHasBeenSet(false),
|
|
m_responseMetadataHasBeenSet(false)
|
|
{
|
|
}
|
|
|
|
Volume::Volume(const XmlNode& xmlNode) :
|
|
m_attachmentsHasBeenSet(false),
|
|
m_availabilityZoneHasBeenSet(false),
|
|
m_createTimeHasBeenSet(false),
|
|
m_encrypted(false),
|
|
m_encryptedHasBeenSet(false),
|
|
m_kmsKeyIdHasBeenSet(false),
|
|
m_outpostArnHasBeenSet(false),
|
|
m_size(0),
|
|
m_sizeHasBeenSet(false),
|
|
m_snapshotIdHasBeenSet(false),
|
|
m_state(VolumeState::NOT_SET),
|
|
m_stateHasBeenSet(false),
|
|
m_volumeIdHasBeenSet(false),
|
|
m_iops(0),
|
|
m_iopsHasBeenSet(false),
|
|
m_tagsHasBeenSet(false),
|
|
m_volumeType(VolumeType::NOT_SET),
|
|
m_volumeTypeHasBeenSet(false),
|
|
m_fastRestored(false),
|
|
m_fastRestoredHasBeenSet(false),
|
|
m_multiAttachEnabled(false),
|
|
m_multiAttachEnabledHasBeenSet(false),
|
|
m_responseMetadataHasBeenSet(false)
|
|
{
|
|
*this = xmlNode;
|
|
}
|
|
|
|
Volume& Volume::operator =(const XmlNode& xmlNode)
|
|
{
|
|
XmlNode resultNode = xmlNode;
|
|
|
|
if(!resultNode.IsNull())
|
|
{
|
|
XmlNode attachmentsNode = resultNode.FirstChild("attachmentSet");
|
|
if(!attachmentsNode.IsNull())
|
|
{
|
|
XmlNode attachmentsMember = attachmentsNode.FirstChild("item");
|
|
while(!attachmentsMember.IsNull())
|
|
{
|
|
m_attachments.push_back(attachmentsMember);
|
|
attachmentsMember = attachmentsMember.NextNode("item");
|
|
}
|
|
|
|
m_attachmentsHasBeenSet = true;
|
|
}
|
|
XmlNode availabilityZoneNode = resultNode.FirstChild("availabilityZone");
|
|
if(!availabilityZoneNode.IsNull())
|
|
{
|
|
m_availabilityZone = Aws::Utils::Xml::DecodeEscapedXmlText(availabilityZoneNode.GetText());
|
|
m_availabilityZoneHasBeenSet = true;
|
|
}
|
|
XmlNode createTimeNode = resultNode.FirstChild("createTime");
|
|
if(!createTimeNode.IsNull())
|
|
{
|
|
m_createTime = DateTime(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(createTimeNode.GetText()).c_str()).c_str(), DateFormat::ISO_8601);
|
|
m_createTimeHasBeenSet = 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 kmsKeyIdNode = resultNode.FirstChild("kmsKeyId");
|
|
if(!kmsKeyIdNode.IsNull())
|
|
{
|
|
m_kmsKeyId = Aws::Utils::Xml::DecodeEscapedXmlText(kmsKeyIdNode.GetText());
|
|
m_kmsKeyIdHasBeenSet = true;
|
|
}
|
|
XmlNode outpostArnNode = resultNode.FirstChild("outpostArn");
|
|
if(!outpostArnNode.IsNull())
|
|
{
|
|
m_outpostArn = Aws::Utils::Xml::DecodeEscapedXmlText(outpostArnNode.GetText());
|
|
m_outpostArnHasBeenSet = true;
|
|
}
|
|
XmlNode sizeNode = resultNode.FirstChild("size");
|
|
if(!sizeNode.IsNull())
|
|
{
|
|
m_size = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(sizeNode.GetText()).c_str()).c_str());
|
|
m_sizeHasBeenSet = true;
|
|
}
|
|
XmlNode snapshotIdNode = resultNode.FirstChild("snapshotId");
|
|
if(!snapshotIdNode.IsNull())
|
|
{
|
|
m_snapshotId = Aws::Utils::Xml::DecodeEscapedXmlText(snapshotIdNode.GetText());
|
|
m_snapshotIdHasBeenSet = true;
|
|
}
|
|
XmlNode stateNode = resultNode.FirstChild("status");
|
|
if(!stateNode.IsNull())
|
|
{
|
|
m_state = VolumeStateMapper::GetVolumeStateForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(stateNode.GetText()).c_str()).c_str());
|
|
m_stateHasBeenSet = true;
|
|
}
|
|
XmlNode volumeIdNode = resultNode.FirstChild("volumeId");
|
|
if(!volumeIdNode.IsNull())
|
|
{
|
|
m_volumeId = Aws::Utils::Xml::DecodeEscapedXmlText(volumeIdNode.GetText());
|
|
m_volumeIdHasBeenSet = true;
|
|
}
|
|
XmlNode iopsNode = resultNode.FirstChild("iops");
|
|
if(!iopsNode.IsNull())
|
|
{
|
|
m_iops = StringUtils::ConvertToInt32(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(iopsNode.GetText()).c_str()).c_str());
|
|
m_iopsHasBeenSet = 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 volumeTypeNode = resultNode.FirstChild("volumeType");
|
|
if(!volumeTypeNode.IsNull())
|
|
{
|
|
m_volumeType = VolumeTypeMapper::GetVolumeTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(volumeTypeNode.GetText()).c_str()).c_str());
|
|
m_volumeTypeHasBeenSet = true;
|
|
}
|
|
XmlNode fastRestoredNode = resultNode.FirstChild("fastRestored");
|
|
if(!fastRestoredNode.IsNull())
|
|
{
|
|
m_fastRestored = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(fastRestoredNode.GetText()).c_str()).c_str());
|
|
m_fastRestoredHasBeenSet = true;
|
|
}
|
|
XmlNode multiAttachEnabledNode = resultNode.FirstChild("multiAttachEnabled");
|
|
if(!multiAttachEnabledNode.IsNull())
|
|
{
|
|
m_multiAttachEnabled = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(multiAttachEnabledNode.GetText()).c_str()).c_str());
|
|
m_multiAttachEnabledHasBeenSet = true;
|
|
}
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
void Volume::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
|
|
{
|
|
if(m_attachmentsHasBeenSet)
|
|
{
|
|
unsigned attachmentsIdx = 1;
|
|
for(auto& item : m_attachments)
|
|
{
|
|
Aws::StringStream attachmentsSs;
|
|
attachmentsSs << location << index << locationValue << ".AttachmentSet." << attachmentsIdx++;
|
|
item.OutputToStream(oStream, attachmentsSs.str().c_str());
|
|
}
|
|
}
|
|
|
|
if(m_availabilityZoneHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".AvailabilityZone=" << StringUtils::URLEncode(m_availabilityZone.c_str()) << "&";
|
|
}
|
|
|
|
if(m_createTimeHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".CreateTime=" << StringUtils::URLEncode(m_createTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
|
|
}
|
|
|
|
if(m_encryptedHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".Encrypted=" << std::boolalpha << m_encrypted << "&";
|
|
}
|
|
|
|
if(m_kmsKeyIdHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".KmsKeyId=" << StringUtils::URLEncode(m_kmsKeyId.c_str()) << "&";
|
|
}
|
|
|
|
if(m_outpostArnHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".OutpostArn=" << StringUtils::URLEncode(m_outpostArn.c_str()) << "&";
|
|
}
|
|
|
|
if(m_sizeHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".Size=" << m_size << "&";
|
|
}
|
|
|
|
if(m_snapshotIdHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".SnapshotId=" << StringUtils::URLEncode(m_snapshotId.c_str()) << "&";
|
|
}
|
|
|
|
if(m_stateHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".State=" << VolumeStateMapper::GetNameForVolumeState(m_state) << "&";
|
|
}
|
|
|
|
if(m_volumeIdHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".VolumeId=" << StringUtils::URLEncode(m_volumeId.c_str()) << "&";
|
|
}
|
|
|
|
if(m_iopsHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".Iops=" << m_iops << "&";
|
|
}
|
|
|
|
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_volumeTypeHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".VolumeType=" << VolumeTypeMapper::GetNameForVolumeType(m_volumeType) << "&";
|
|
}
|
|
|
|
if(m_fastRestoredHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".FastRestored=" << std::boolalpha << m_fastRestored << "&";
|
|
}
|
|
|
|
if(m_multiAttachEnabledHasBeenSet)
|
|
{
|
|
oStream << location << index << locationValue << ".MultiAttachEnabled=" << std::boolalpha << m_multiAttachEnabled << "&";
|
|
}
|
|
|
|
if(m_responseMetadataHasBeenSet)
|
|
{
|
|
Aws::StringStream responseMetadataLocationAndMemberSs;
|
|
responseMetadataLocationAndMemberSs << location << index << locationValue << ".ResponseMetadata";
|
|
m_responseMetadata.OutputToStream(oStream, responseMetadataLocationAndMemberSs.str().c_str());
|
|
}
|
|
|
|
}
|
|
|
|
void Volume::OutputToStream(Aws::OStream& oStream, const char* location) const
|
|
{
|
|
if(m_attachmentsHasBeenSet)
|
|
{
|
|
unsigned attachmentsIdx = 1;
|
|
for(auto& item : m_attachments)
|
|
{
|
|
Aws::StringStream attachmentsSs;
|
|
attachmentsSs << location << ".AttachmentSet." << attachmentsIdx++;
|
|
item.OutputToStream(oStream, attachmentsSs.str().c_str());
|
|
}
|
|
}
|
|
if(m_availabilityZoneHasBeenSet)
|
|
{
|
|
oStream << location << ".AvailabilityZone=" << StringUtils::URLEncode(m_availabilityZone.c_str()) << "&";
|
|
}
|
|
if(m_createTimeHasBeenSet)
|
|
{
|
|
oStream << location << ".CreateTime=" << StringUtils::URLEncode(m_createTime.ToGmtString(DateFormat::ISO_8601).c_str()) << "&";
|
|
}
|
|
if(m_encryptedHasBeenSet)
|
|
{
|
|
oStream << location << ".Encrypted=" << std::boolalpha << m_encrypted << "&";
|
|
}
|
|
if(m_kmsKeyIdHasBeenSet)
|
|
{
|
|
oStream << location << ".KmsKeyId=" << StringUtils::URLEncode(m_kmsKeyId.c_str()) << "&";
|
|
}
|
|
if(m_outpostArnHasBeenSet)
|
|
{
|
|
oStream << location << ".OutpostArn=" << StringUtils::URLEncode(m_outpostArn.c_str()) << "&";
|
|
}
|
|
if(m_sizeHasBeenSet)
|
|
{
|
|
oStream << location << ".Size=" << m_size << "&";
|
|
}
|
|
if(m_snapshotIdHasBeenSet)
|
|
{
|
|
oStream << location << ".SnapshotId=" << StringUtils::URLEncode(m_snapshotId.c_str()) << "&";
|
|
}
|
|
if(m_stateHasBeenSet)
|
|
{
|
|
oStream << location << ".State=" << VolumeStateMapper::GetNameForVolumeState(m_state) << "&";
|
|
}
|
|
if(m_volumeIdHasBeenSet)
|
|
{
|
|
oStream << location << ".VolumeId=" << StringUtils::URLEncode(m_volumeId.c_str()) << "&";
|
|
}
|
|
if(m_iopsHasBeenSet)
|
|
{
|
|
oStream << location << ".Iops=" << m_iops << "&";
|
|
}
|
|
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_volumeTypeHasBeenSet)
|
|
{
|
|
oStream << location << ".VolumeType=" << VolumeTypeMapper::GetNameForVolumeType(m_volumeType) << "&";
|
|
}
|
|
if(m_fastRestoredHasBeenSet)
|
|
{
|
|
oStream << location << ".FastRestored=" << std::boolalpha << m_fastRestored << "&";
|
|
}
|
|
if(m_multiAttachEnabledHasBeenSet)
|
|
{
|
|
oStream << location << ".MultiAttachEnabled=" << std::boolalpha << m_multiAttachEnabled << "&";
|
|
}
|
|
if(m_responseMetadataHasBeenSet)
|
|
{
|
|
Aws::String responseMetadataLocationAndMember(location);
|
|
responseMetadataLocationAndMember += ".ResponseMetadata";
|
|
m_responseMetadata.OutputToStream(oStream, responseMetadataLocationAndMember.c_str());
|
|
}
|
|
}
|
|
|
|
} // namespace Model
|
|
} // namespace EC2
|
|
} // namespace Aws
|