379 lines
13 KiB
C++
379 lines
13 KiB
C++
|
|
/**
|
|||
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|||
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#include <aws/ec2/model/LaunchSpecification.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
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
LaunchSpecification::LaunchSpecification() :
|
|||
|
|
m_userDataHasBeenSet(false),
|
|||
|
|
m_securityGroupsHasBeenSet(false),
|
|||
|
|
m_addressingTypeHasBeenSet(false),
|
|||
|
|
m_blockDeviceMappingsHasBeenSet(false),
|
|||
|
|
m_ebsOptimized(false),
|
|||
|
|
m_ebsOptimizedHasBeenSet(false),
|
|||
|
|
m_iamInstanceProfileHasBeenSet(false),
|
|||
|
|
m_imageIdHasBeenSet(false),
|
|||
|
|
m_instanceType(InstanceType::NOT_SET),
|
|||
|
|
m_instanceTypeHasBeenSet(false),
|
|||
|
|
m_kernelIdHasBeenSet(false),
|
|||
|
|
m_keyNameHasBeenSet(false),
|
|||
|
|
m_networkInterfacesHasBeenSet(false),
|
|||
|
|
m_placementHasBeenSet(false),
|
|||
|
|
m_ramdiskIdHasBeenSet(false),
|
|||
|
|
m_subnetIdHasBeenSet(false),
|
|||
|
|
m_monitoringHasBeenSet(false)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LaunchSpecification::LaunchSpecification(const XmlNode& xmlNode) :
|
|||
|
|
m_userDataHasBeenSet(false),
|
|||
|
|
m_securityGroupsHasBeenSet(false),
|
|||
|
|
m_addressingTypeHasBeenSet(false),
|
|||
|
|
m_blockDeviceMappingsHasBeenSet(false),
|
|||
|
|
m_ebsOptimized(false),
|
|||
|
|
m_ebsOptimizedHasBeenSet(false),
|
|||
|
|
m_iamInstanceProfileHasBeenSet(false),
|
|||
|
|
m_imageIdHasBeenSet(false),
|
|||
|
|
m_instanceType(InstanceType::NOT_SET),
|
|||
|
|
m_instanceTypeHasBeenSet(false),
|
|||
|
|
m_kernelIdHasBeenSet(false),
|
|||
|
|
m_keyNameHasBeenSet(false),
|
|||
|
|
m_networkInterfacesHasBeenSet(false),
|
|||
|
|
m_placementHasBeenSet(false),
|
|||
|
|
m_ramdiskIdHasBeenSet(false),
|
|||
|
|
m_subnetIdHasBeenSet(false),
|
|||
|
|
m_monitoringHasBeenSet(false)
|
|||
|
|
{
|
|||
|
|
*this = xmlNode;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
LaunchSpecification& LaunchSpecification::operator =(const XmlNode& xmlNode)
|
|||
|
|
{
|
|||
|
|
XmlNode resultNode = xmlNode;
|
|||
|
|
|
|||
|
|
if(!resultNode.IsNull())
|
|||
|
|
{
|
|||
|
|
XmlNode userDataNode = resultNode.FirstChild("userData");
|
|||
|
|
if(!userDataNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_userData = Aws::Utils::Xml::DecodeEscapedXmlText(userDataNode.GetText());
|
|||
|
|
m_userDataHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode securityGroupsNode = resultNode.FirstChild("groupSet");
|
|||
|
|
if(!securityGroupsNode.IsNull())
|
|||
|
|
{
|
|||
|
|
XmlNode securityGroupsMember = securityGroupsNode.FirstChild("item");
|
|||
|
|
while(!securityGroupsMember.IsNull())
|
|||
|
|
{
|
|||
|
|
m_securityGroups.push_back(securityGroupsMember);
|
|||
|
|
securityGroupsMember = securityGroupsMember.NextNode("item");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_securityGroupsHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode addressingTypeNode = resultNode.FirstChild("addressingType");
|
|||
|
|
if(!addressingTypeNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_addressingType = Aws::Utils::Xml::DecodeEscapedXmlText(addressingTypeNode.GetText());
|
|||
|
|
m_addressingTypeHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode blockDeviceMappingsNode = resultNode.FirstChild("blockDeviceMapping");
|
|||
|
|
if(!blockDeviceMappingsNode.IsNull())
|
|||
|
|
{
|
|||
|
|
XmlNode blockDeviceMappingsMember = blockDeviceMappingsNode.FirstChild("item");
|
|||
|
|
while(!blockDeviceMappingsMember.IsNull())
|
|||
|
|
{
|
|||
|
|
m_blockDeviceMappings.push_back(blockDeviceMappingsMember);
|
|||
|
|
blockDeviceMappingsMember = blockDeviceMappingsMember.NextNode("item");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_blockDeviceMappingsHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode ebsOptimizedNode = resultNode.FirstChild("ebsOptimized");
|
|||
|
|
if(!ebsOptimizedNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_ebsOptimized = StringUtils::ConvertToBool(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(ebsOptimizedNode.GetText()).c_str()).c_str());
|
|||
|
|
m_ebsOptimizedHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode iamInstanceProfileNode = resultNode.FirstChild("iamInstanceProfile");
|
|||
|
|
if(!iamInstanceProfileNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_iamInstanceProfile = iamInstanceProfileNode;
|
|||
|
|
m_iamInstanceProfileHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode imageIdNode = resultNode.FirstChild("imageId");
|
|||
|
|
if(!imageIdNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_imageId = Aws::Utils::Xml::DecodeEscapedXmlText(imageIdNode.GetText());
|
|||
|
|
m_imageIdHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode instanceTypeNode = resultNode.FirstChild("instanceType");
|
|||
|
|
if(!instanceTypeNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_instanceType = InstanceTypeMapper::GetInstanceTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(instanceTypeNode.GetText()).c_str()).c_str());
|
|||
|
|
m_instanceTypeHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode kernelIdNode = resultNode.FirstChild("kernelId");
|
|||
|
|
if(!kernelIdNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_kernelId = Aws::Utils::Xml::DecodeEscapedXmlText(kernelIdNode.GetText());
|
|||
|
|
m_kernelIdHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode keyNameNode = resultNode.FirstChild("keyName");
|
|||
|
|
if(!keyNameNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_keyName = Aws::Utils::Xml::DecodeEscapedXmlText(keyNameNode.GetText());
|
|||
|
|
m_keyNameHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode networkInterfacesNode = resultNode.FirstChild("networkInterfaceSet");
|
|||
|
|
if(!networkInterfacesNode.IsNull())
|
|||
|
|
{
|
|||
|
|
XmlNode networkInterfacesMember = networkInterfacesNode.FirstChild("item");
|
|||
|
|
while(!networkInterfacesMember.IsNull())
|
|||
|
|
{
|
|||
|
|
m_networkInterfaces.push_back(networkInterfacesMember);
|
|||
|
|
networkInterfacesMember = networkInterfacesMember.NextNode("item");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_networkInterfacesHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode placementNode = resultNode.FirstChild("placement");
|
|||
|
|
if(!placementNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_placement = placementNode;
|
|||
|
|
m_placementHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode ramdiskIdNode = resultNode.FirstChild("ramdiskId");
|
|||
|
|
if(!ramdiskIdNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_ramdiskId = Aws::Utils::Xml::DecodeEscapedXmlText(ramdiskIdNode.GetText());
|
|||
|
|
m_ramdiskIdHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode subnetIdNode = resultNode.FirstChild("subnetId");
|
|||
|
|
if(!subnetIdNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_subnetId = Aws::Utils::Xml::DecodeEscapedXmlText(subnetIdNode.GetText());
|
|||
|
|
m_subnetIdHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
XmlNode monitoringNode = resultNode.FirstChild("monitoring");
|
|||
|
|
if(!monitoringNode.IsNull())
|
|||
|
|
{
|
|||
|
|
m_monitoring = monitoringNode;
|
|||
|
|
m_monitoringHasBeenSet = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return *this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LaunchSpecification::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
|
|||
|
|
{
|
|||
|
|
if(m_userDataHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".UserData=" << StringUtils::URLEncode(m_userData.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_securityGroupsHasBeenSet)
|
|||
|
|
{
|
|||
|
|
unsigned securityGroupsIdx = 1;
|
|||
|
|
for(auto& item : m_securityGroups)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream securityGroupsSs;
|
|||
|
|
securityGroupsSs << location << index << locationValue << ".GroupSet." << securityGroupsIdx++;
|
|||
|
|
item.OutputToStream(oStream, securityGroupsSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_addressingTypeHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".AddressingType=" << StringUtils::URLEncode(m_addressingType.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_blockDeviceMappingsHasBeenSet)
|
|||
|
|
{
|
|||
|
|
unsigned blockDeviceMappingsIdx = 1;
|
|||
|
|
for(auto& item : m_blockDeviceMappings)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream blockDeviceMappingsSs;
|
|||
|
|
blockDeviceMappingsSs << location << index << locationValue << ".BlockDeviceMapping." << blockDeviceMappingsIdx++;
|
|||
|
|
item.OutputToStream(oStream, blockDeviceMappingsSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_ebsOptimizedHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".EbsOptimized=" << std::boolalpha << m_ebsOptimized << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_iamInstanceProfileHasBeenSet)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream iamInstanceProfileLocationAndMemberSs;
|
|||
|
|
iamInstanceProfileLocationAndMemberSs << location << index << locationValue << ".IamInstanceProfile";
|
|||
|
|
m_iamInstanceProfile.OutputToStream(oStream, iamInstanceProfileLocationAndMemberSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_imageIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".ImageId=" << StringUtils::URLEncode(m_imageId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_instanceTypeHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".InstanceType=" << InstanceTypeMapper::GetNameForInstanceType(m_instanceType) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_kernelIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".KernelId=" << StringUtils::URLEncode(m_kernelId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_keyNameHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".KeyName=" << StringUtils::URLEncode(m_keyName.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_networkInterfacesHasBeenSet)
|
|||
|
|
{
|
|||
|
|
unsigned networkInterfacesIdx = 1;
|
|||
|
|
for(auto& item : m_networkInterfaces)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream networkInterfacesSs;
|
|||
|
|
networkInterfacesSs << location << index << locationValue << ".NetworkInterfaceSet." << networkInterfacesIdx++;
|
|||
|
|
item.OutputToStream(oStream, networkInterfacesSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_placementHasBeenSet)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream placementLocationAndMemberSs;
|
|||
|
|
placementLocationAndMemberSs << location << index << locationValue << ".Placement";
|
|||
|
|
m_placement.OutputToStream(oStream, placementLocationAndMemberSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_ramdiskIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".RamdiskId=" << StringUtils::URLEncode(m_ramdiskId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_subnetIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << index << locationValue << ".SubnetId=" << StringUtils::URLEncode(m_subnetId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(m_monitoringHasBeenSet)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream monitoringLocationAndMemberSs;
|
|||
|
|
monitoringLocationAndMemberSs << location << index << locationValue << ".Monitoring";
|
|||
|
|
m_monitoring.OutputToStream(oStream, monitoringLocationAndMemberSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LaunchSpecification::OutputToStream(Aws::OStream& oStream, const char* location) const
|
|||
|
|
{
|
|||
|
|
if(m_userDataHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".UserData=" << StringUtils::URLEncode(m_userData.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_securityGroupsHasBeenSet)
|
|||
|
|
{
|
|||
|
|
unsigned securityGroupsIdx = 1;
|
|||
|
|
for(auto& item : m_securityGroups)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream securityGroupsSs;
|
|||
|
|
securityGroupsSs << location << ".GroupSet." << securityGroupsIdx++;
|
|||
|
|
item.OutputToStream(oStream, securityGroupsSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(m_addressingTypeHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".AddressingType=" << StringUtils::URLEncode(m_addressingType.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_blockDeviceMappingsHasBeenSet)
|
|||
|
|
{
|
|||
|
|
unsigned blockDeviceMappingsIdx = 1;
|
|||
|
|
for(auto& item : m_blockDeviceMappings)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream blockDeviceMappingsSs;
|
|||
|
|
blockDeviceMappingsSs << location << ".BlockDeviceMapping." << blockDeviceMappingsIdx++;
|
|||
|
|
item.OutputToStream(oStream, blockDeviceMappingsSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(m_ebsOptimizedHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".EbsOptimized=" << std::boolalpha << m_ebsOptimized << "&";
|
|||
|
|
}
|
|||
|
|
if(m_iamInstanceProfileHasBeenSet)
|
|||
|
|
{
|
|||
|
|
Aws::String iamInstanceProfileLocationAndMember(location);
|
|||
|
|
iamInstanceProfileLocationAndMember += ".IamInstanceProfile";
|
|||
|
|
m_iamInstanceProfile.OutputToStream(oStream, iamInstanceProfileLocationAndMember.c_str());
|
|||
|
|
}
|
|||
|
|
if(m_imageIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".ImageId=" << StringUtils::URLEncode(m_imageId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_instanceTypeHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".InstanceType=" << InstanceTypeMapper::GetNameForInstanceType(m_instanceType) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_kernelIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".KernelId=" << StringUtils::URLEncode(m_kernelId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_keyNameHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".KeyName=" << StringUtils::URLEncode(m_keyName.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_networkInterfacesHasBeenSet)
|
|||
|
|
{
|
|||
|
|
unsigned networkInterfacesIdx = 1;
|
|||
|
|
for(auto& item : m_networkInterfaces)
|
|||
|
|
{
|
|||
|
|
Aws::StringStream networkInterfacesSs;
|
|||
|
|
networkInterfacesSs << location << ".NetworkInterfaceSet." << networkInterfacesIdx++;
|
|||
|
|
item.OutputToStream(oStream, networkInterfacesSs.str().c_str());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(m_placementHasBeenSet)
|
|||
|
|
{
|
|||
|
|
Aws::String placementLocationAndMember(location);
|
|||
|
|
placementLocationAndMember += ".Placement";
|
|||
|
|
m_placement.OutputToStream(oStream, placementLocationAndMember.c_str());
|
|||
|
|
}
|
|||
|
|
if(m_ramdiskIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".RamdiskId=" << StringUtils::URLEncode(m_ramdiskId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_subnetIdHasBeenSet)
|
|||
|
|
{
|
|||
|
|
oStream << location << ".SubnetId=" << StringUtils::URLEncode(m_subnetId.c_str()) << "&";
|
|||
|
|
}
|
|||
|
|
if(m_monitoringHasBeenSet)
|
|||
|
|
{
|
|||
|
|
Aws::String monitoringLocationAndMember(location);
|
|||
|
|
monitoringLocationAndMember += ".Monitoring";
|
|||
|
|
m_monitoring.OutputToStream(oStream, monitoringLocationAndMember.c_str());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} // namespace Model
|
|||
|
|
} // namespace EC2
|
|||
|
|
} // namespace Aws
|