1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/codestar-connections/model/VpcConfiguration.h>
7 #include <aws/core/utils/json/JsonSerializer.h>
8 
9 #include <utility>
10 
11 using namespace Aws::Utils::Json;
12 using namespace Aws::Utils;
13 
14 namespace Aws
15 {
16 namespace CodeStarconnections
17 {
18 namespace Model
19 {
20 
VpcConfiguration()21 VpcConfiguration::VpcConfiguration() :
22     m_vpcIdHasBeenSet(false),
23     m_subnetIdsHasBeenSet(false),
24     m_securityGroupIdsHasBeenSet(false),
25     m_tlsCertificateHasBeenSet(false)
26 {
27 }
28 
VpcConfiguration(JsonView jsonValue)29 VpcConfiguration::VpcConfiguration(JsonView jsonValue) :
30     m_vpcIdHasBeenSet(false),
31     m_subnetIdsHasBeenSet(false),
32     m_securityGroupIdsHasBeenSet(false),
33     m_tlsCertificateHasBeenSet(false)
34 {
35   *this = jsonValue;
36 }
37 
operator =(JsonView jsonValue)38 VpcConfiguration& VpcConfiguration::operator =(JsonView jsonValue)
39 {
40   if(jsonValue.ValueExists("VpcId"))
41   {
42     m_vpcId = jsonValue.GetString("VpcId");
43 
44     m_vpcIdHasBeenSet = true;
45   }
46 
47   if(jsonValue.ValueExists("SubnetIds"))
48   {
49     Array<JsonView> subnetIdsJsonList = jsonValue.GetArray("SubnetIds");
50     for(unsigned subnetIdsIndex = 0; subnetIdsIndex < subnetIdsJsonList.GetLength(); ++subnetIdsIndex)
51     {
52       m_subnetIds.push_back(subnetIdsJsonList[subnetIdsIndex].AsString());
53     }
54     m_subnetIdsHasBeenSet = true;
55   }
56 
57   if(jsonValue.ValueExists("SecurityGroupIds"))
58   {
59     Array<JsonView> securityGroupIdsJsonList = jsonValue.GetArray("SecurityGroupIds");
60     for(unsigned securityGroupIdsIndex = 0; securityGroupIdsIndex < securityGroupIdsJsonList.GetLength(); ++securityGroupIdsIndex)
61     {
62       m_securityGroupIds.push_back(securityGroupIdsJsonList[securityGroupIdsIndex].AsString());
63     }
64     m_securityGroupIdsHasBeenSet = true;
65   }
66 
67   if(jsonValue.ValueExists("TlsCertificate"))
68   {
69     m_tlsCertificate = jsonValue.GetString("TlsCertificate");
70 
71     m_tlsCertificateHasBeenSet = true;
72   }
73 
74   return *this;
75 }
76 
Jsonize() const77 JsonValue VpcConfiguration::Jsonize() const
78 {
79   JsonValue payload;
80 
81   if(m_vpcIdHasBeenSet)
82   {
83    payload.WithString("VpcId", m_vpcId);
84 
85   }
86 
87   if(m_subnetIdsHasBeenSet)
88   {
89    Array<JsonValue> subnetIdsJsonList(m_subnetIds.size());
90    for(unsigned subnetIdsIndex = 0; subnetIdsIndex < subnetIdsJsonList.GetLength(); ++subnetIdsIndex)
91    {
92      subnetIdsJsonList[subnetIdsIndex].AsString(m_subnetIds[subnetIdsIndex]);
93    }
94    payload.WithArray("SubnetIds", std::move(subnetIdsJsonList));
95 
96   }
97 
98   if(m_securityGroupIdsHasBeenSet)
99   {
100    Array<JsonValue> securityGroupIdsJsonList(m_securityGroupIds.size());
101    for(unsigned securityGroupIdsIndex = 0; securityGroupIdsIndex < securityGroupIdsJsonList.GetLength(); ++securityGroupIdsIndex)
102    {
103      securityGroupIdsJsonList[securityGroupIdsIndex].AsString(m_securityGroupIds[securityGroupIdsIndex]);
104    }
105    payload.WithArray("SecurityGroupIds", std::move(securityGroupIdsJsonList));
106 
107   }
108 
109   if(m_tlsCertificateHasBeenSet)
110   {
111    payload.WithString("TlsCertificate", m_tlsCertificate);
112 
113   }
114 
115   return payload;
116 }
117 
118 } // namespace Model
119 } // namespace CodeStarconnections
120 } // namespace Aws
121