1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/glue/model/ConnectionInput.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 Glue
17 {
18 namespace Model
19 {
20 
ConnectionInput()21 ConnectionInput::ConnectionInput() :
22     m_nameHasBeenSet(false),
23     m_descriptionHasBeenSet(false),
24     m_connectionType(ConnectionType::NOT_SET),
25     m_connectionTypeHasBeenSet(false),
26     m_matchCriteriaHasBeenSet(false),
27     m_connectionPropertiesHasBeenSet(false),
28     m_physicalConnectionRequirementsHasBeenSet(false)
29 {
30 }
31 
ConnectionInput(JsonView jsonValue)32 ConnectionInput::ConnectionInput(JsonView jsonValue) :
33     m_nameHasBeenSet(false),
34     m_descriptionHasBeenSet(false),
35     m_connectionType(ConnectionType::NOT_SET),
36     m_connectionTypeHasBeenSet(false),
37     m_matchCriteriaHasBeenSet(false),
38     m_connectionPropertiesHasBeenSet(false),
39     m_physicalConnectionRequirementsHasBeenSet(false)
40 {
41   *this = jsonValue;
42 }
43 
operator =(JsonView jsonValue)44 ConnectionInput& ConnectionInput::operator =(JsonView jsonValue)
45 {
46   if(jsonValue.ValueExists("Name"))
47   {
48     m_name = jsonValue.GetString("Name");
49 
50     m_nameHasBeenSet = true;
51   }
52 
53   if(jsonValue.ValueExists("Description"))
54   {
55     m_description = jsonValue.GetString("Description");
56 
57     m_descriptionHasBeenSet = true;
58   }
59 
60   if(jsonValue.ValueExists("ConnectionType"))
61   {
62     m_connectionType = ConnectionTypeMapper::GetConnectionTypeForName(jsonValue.GetString("ConnectionType"));
63 
64     m_connectionTypeHasBeenSet = true;
65   }
66 
67   if(jsonValue.ValueExists("MatchCriteria"))
68   {
69     Array<JsonView> matchCriteriaJsonList = jsonValue.GetArray("MatchCriteria");
70     for(unsigned matchCriteriaIndex = 0; matchCriteriaIndex < matchCriteriaJsonList.GetLength(); ++matchCriteriaIndex)
71     {
72       m_matchCriteria.push_back(matchCriteriaJsonList[matchCriteriaIndex].AsString());
73     }
74     m_matchCriteriaHasBeenSet = true;
75   }
76 
77   if(jsonValue.ValueExists("ConnectionProperties"))
78   {
79     Aws::Map<Aws::String, JsonView> connectionPropertiesJsonMap = jsonValue.GetObject("ConnectionProperties").GetAllObjects();
80     for(auto& connectionPropertiesItem : connectionPropertiesJsonMap)
81     {
82       m_connectionProperties[ConnectionPropertyKeyMapper::GetConnectionPropertyKeyForName(connectionPropertiesItem.first)] = connectionPropertiesItem.second.AsString();
83     }
84     m_connectionPropertiesHasBeenSet = true;
85   }
86 
87   if(jsonValue.ValueExists("PhysicalConnectionRequirements"))
88   {
89     m_physicalConnectionRequirements = jsonValue.GetObject("PhysicalConnectionRequirements");
90 
91     m_physicalConnectionRequirementsHasBeenSet = true;
92   }
93 
94   return *this;
95 }
96 
Jsonize() const97 JsonValue ConnectionInput::Jsonize() const
98 {
99   JsonValue payload;
100 
101   if(m_nameHasBeenSet)
102   {
103    payload.WithString("Name", m_name);
104 
105   }
106 
107   if(m_descriptionHasBeenSet)
108   {
109    payload.WithString("Description", m_description);
110 
111   }
112 
113   if(m_connectionTypeHasBeenSet)
114   {
115    payload.WithString("ConnectionType", ConnectionTypeMapper::GetNameForConnectionType(m_connectionType));
116   }
117 
118   if(m_matchCriteriaHasBeenSet)
119   {
120    Array<JsonValue> matchCriteriaJsonList(m_matchCriteria.size());
121    for(unsigned matchCriteriaIndex = 0; matchCriteriaIndex < matchCriteriaJsonList.GetLength(); ++matchCriteriaIndex)
122    {
123      matchCriteriaJsonList[matchCriteriaIndex].AsString(m_matchCriteria[matchCriteriaIndex]);
124    }
125    payload.WithArray("MatchCriteria", std::move(matchCriteriaJsonList));
126 
127   }
128 
129   if(m_connectionPropertiesHasBeenSet)
130   {
131    JsonValue connectionPropertiesJsonMap;
132    for(auto& connectionPropertiesItem : m_connectionProperties)
133    {
134      connectionPropertiesJsonMap.WithString(ConnectionPropertyKeyMapper::GetNameForConnectionPropertyKey(connectionPropertiesItem.first), connectionPropertiesItem.second);
135    }
136    payload.WithObject("ConnectionProperties", std::move(connectionPropertiesJsonMap));
137 
138   }
139 
140   if(m_physicalConnectionRequirementsHasBeenSet)
141   {
142    payload.WithObject("PhysicalConnectionRequirements", m_physicalConnectionRequirements.Jsonize());
143 
144   }
145 
146   return payload;
147 }
148 
149 } // namespace Model
150 } // namespace Glue
151 } // namespace Aws
152