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