1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/elasticloadbalancingv2/model/CreateLoadBalancerRequest.h>
7 #include <aws/core/utils/StringUtils.h>
8 #include <aws/core/utils/memory/stl/AWSStringStream.h>
9 
10 using namespace Aws::ElasticLoadBalancingv2::Model;
11 using namespace Aws::Utils;
12 
CreateLoadBalancerRequest()13 CreateLoadBalancerRequest::CreateLoadBalancerRequest() :
14     m_nameHasBeenSet(false),
15     m_subnetsHasBeenSet(false),
16     m_subnetMappingsHasBeenSet(false),
17     m_securityGroupsHasBeenSet(false),
18     m_scheme(LoadBalancerSchemeEnum::NOT_SET),
19     m_schemeHasBeenSet(false),
20     m_tagsHasBeenSet(false),
21     m_type(LoadBalancerTypeEnum::NOT_SET),
22     m_typeHasBeenSet(false),
23     m_ipAddressType(IpAddressType::NOT_SET),
24     m_ipAddressTypeHasBeenSet(false),
25     m_customerOwnedIpv4PoolHasBeenSet(false)
26 {
27 }
28 
SerializePayload() const29 Aws::String CreateLoadBalancerRequest::SerializePayload() const
30 {
31   Aws::StringStream ss;
32   ss << "Action=CreateLoadBalancer&";
33   if(m_nameHasBeenSet)
34   {
35     ss << "Name=" << StringUtils::URLEncode(m_name.c_str()) << "&";
36   }
37 
38   if(m_subnetsHasBeenSet)
39   {
40     unsigned subnetsCount = 1;
41     for(auto& item : m_subnets)
42     {
43       ss << "Subnets.member." << subnetsCount << "="
44           << StringUtils::URLEncode(item.c_str()) << "&";
45       subnetsCount++;
46     }
47   }
48 
49   if(m_subnetMappingsHasBeenSet)
50   {
51     unsigned subnetMappingsCount = 1;
52     for(auto& item : m_subnetMappings)
53     {
54       item.OutputToStream(ss, "SubnetMappings.member.", subnetMappingsCount, "");
55       subnetMappingsCount++;
56     }
57   }
58 
59   if(m_securityGroupsHasBeenSet)
60   {
61     unsigned securityGroupsCount = 1;
62     for(auto& item : m_securityGroups)
63     {
64       ss << "SecurityGroups.member." << securityGroupsCount << "="
65           << StringUtils::URLEncode(item.c_str()) << "&";
66       securityGroupsCount++;
67     }
68   }
69 
70   if(m_schemeHasBeenSet)
71   {
72     ss << "Scheme=" << LoadBalancerSchemeEnumMapper::GetNameForLoadBalancerSchemeEnum(m_scheme) << "&";
73   }
74 
75   if(m_tagsHasBeenSet)
76   {
77     unsigned tagsCount = 1;
78     for(auto& item : m_tags)
79     {
80       item.OutputToStream(ss, "Tags.member.", tagsCount, "");
81       tagsCount++;
82     }
83   }
84 
85   if(m_typeHasBeenSet)
86   {
87     ss << "Type=" << LoadBalancerTypeEnumMapper::GetNameForLoadBalancerTypeEnum(m_type) << "&";
88   }
89 
90   if(m_ipAddressTypeHasBeenSet)
91   {
92     ss << "IpAddressType=" << IpAddressTypeMapper::GetNameForIpAddressType(m_ipAddressType) << "&";
93   }
94 
95   if(m_customerOwnedIpv4PoolHasBeenSet)
96   {
97     ss << "CustomerOwnedIpv4Pool=" << StringUtils::URLEncode(m_customerOwnedIpv4Pool.c_str()) << "&";
98   }
99 
100   ss << "Version=2015-12-01";
101   return ss.str();
102 }
103 
104 
DumpBodyToUrl(Aws::Http::URI & uri) const105 void  CreateLoadBalancerRequest::DumpBodyToUrl(Aws::Http::URI& uri ) const
106 {
107   uri.SetQueryString(SerializePayload());
108 }
109