1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/ecs/model/Cluster.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 ECS
17 {
18 namespace Model
19 {
20
Cluster()21 Cluster::Cluster() :
22 m_clusterArnHasBeenSet(false),
23 m_clusterNameHasBeenSet(false),
24 m_configurationHasBeenSet(false),
25 m_statusHasBeenSet(false),
26 m_registeredContainerInstancesCount(0),
27 m_registeredContainerInstancesCountHasBeenSet(false),
28 m_runningTasksCount(0),
29 m_runningTasksCountHasBeenSet(false),
30 m_pendingTasksCount(0),
31 m_pendingTasksCountHasBeenSet(false),
32 m_activeServicesCount(0),
33 m_activeServicesCountHasBeenSet(false),
34 m_statisticsHasBeenSet(false),
35 m_tagsHasBeenSet(false),
36 m_settingsHasBeenSet(false),
37 m_capacityProvidersHasBeenSet(false),
38 m_defaultCapacityProviderStrategyHasBeenSet(false),
39 m_attachmentsHasBeenSet(false),
40 m_attachmentsStatusHasBeenSet(false)
41 {
42 }
43
Cluster(JsonView jsonValue)44 Cluster::Cluster(JsonView jsonValue) :
45 m_clusterArnHasBeenSet(false),
46 m_clusterNameHasBeenSet(false),
47 m_configurationHasBeenSet(false),
48 m_statusHasBeenSet(false),
49 m_registeredContainerInstancesCount(0),
50 m_registeredContainerInstancesCountHasBeenSet(false),
51 m_runningTasksCount(0),
52 m_runningTasksCountHasBeenSet(false),
53 m_pendingTasksCount(0),
54 m_pendingTasksCountHasBeenSet(false),
55 m_activeServicesCount(0),
56 m_activeServicesCountHasBeenSet(false),
57 m_statisticsHasBeenSet(false),
58 m_tagsHasBeenSet(false),
59 m_settingsHasBeenSet(false),
60 m_capacityProvidersHasBeenSet(false),
61 m_defaultCapacityProviderStrategyHasBeenSet(false),
62 m_attachmentsHasBeenSet(false),
63 m_attachmentsStatusHasBeenSet(false)
64 {
65 *this = jsonValue;
66 }
67
operator =(JsonView jsonValue)68 Cluster& Cluster::operator =(JsonView jsonValue)
69 {
70 if(jsonValue.ValueExists("clusterArn"))
71 {
72 m_clusterArn = jsonValue.GetString("clusterArn");
73
74 m_clusterArnHasBeenSet = true;
75 }
76
77 if(jsonValue.ValueExists("clusterName"))
78 {
79 m_clusterName = jsonValue.GetString("clusterName");
80
81 m_clusterNameHasBeenSet = true;
82 }
83
84 if(jsonValue.ValueExists("configuration"))
85 {
86 m_configuration = jsonValue.GetObject("configuration");
87
88 m_configurationHasBeenSet = true;
89 }
90
91 if(jsonValue.ValueExists("status"))
92 {
93 m_status = jsonValue.GetString("status");
94
95 m_statusHasBeenSet = true;
96 }
97
98 if(jsonValue.ValueExists("registeredContainerInstancesCount"))
99 {
100 m_registeredContainerInstancesCount = jsonValue.GetInteger("registeredContainerInstancesCount");
101
102 m_registeredContainerInstancesCountHasBeenSet = true;
103 }
104
105 if(jsonValue.ValueExists("runningTasksCount"))
106 {
107 m_runningTasksCount = jsonValue.GetInteger("runningTasksCount");
108
109 m_runningTasksCountHasBeenSet = true;
110 }
111
112 if(jsonValue.ValueExists("pendingTasksCount"))
113 {
114 m_pendingTasksCount = jsonValue.GetInteger("pendingTasksCount");
115
116 m_pendingTasksCountHasBeenSet = true;
117 }
118
119 if(jsonValue.ValueExists("activeServicesCount"))
120 {
121 m_activeServicesCount = jsonValue.GetInteger("activeServicesCount");
122
123 m_activeServicesCountHasBeenSet = true;
124 }
125
126 if(jsonValue.ValueExists("statistics"))
127 {
128 Array<JsonView> statisticsJsonList = jsonValue.GetArray("statistics");
129 for(unsigned statisticsIndex = 0; statisticsIndex < statisticsJsonList.GetLength(); ++statisticsIndex)
130 {
131 m_statistics.push_back(statisticsJsonList[statisticsIndex].AsObject());
132 }
133 m_statisticsHasBeenSet = true;
134 }
135
136 if(jsonValue.ValueExists("tags"))
137 {
138 Array<JsonView> tagsJsonList = jsonValue.GetArray("tags");
139 for(unsigned tagsIndex = 0; tagsIndex < tagsJsonList.GetLength(); ++tagsIndex)
140 {
141 m_tags.push_back(tagsJsonList[tagsIndex].AsObject());
142 }
143 m_tagsHasBeenSet = true;
144 }
145
146 if(jsonValue.ValueExists("settings"))
147 {
148 Array<JsonView> settingsJsonList = jsonValue.GetArray("settings");
149 for(unsigned settingsIndex = 0; settingsIndex < settingsJsonList.GetLength(); ++settingsIndex)
150 {
151 m_settings.push_back(settingsJsonList[settingsIndex].AsObject());
152 }
153 m_settingsHasBeenSet = true;
154 }
155
156 if(jsonValue.ValueExists("capacityProviders"))
157 {
158 Array<JsonView> capacityProvidersJsonList = jsonValue.GetArray("capacityProviders");
159 for(unsigned capacityProvidersIndex = 0; capacityProvidersIndex < capacityProvidersJsonList.GetLength(); ++capacityProvidersIndex)
160 {
161 m_capacityProviders.push_back(capacityProvidersJsonList[capacityProvidersIndex].AsString());
162 }
163 m_capacityProvidersHasBeenSet = true;
164 }
165
166 if(jsonValue.ValueExists("defaultCapacityProviderStrategy"))
167 {
168 Array<JsonView> defaultCapacityProviderStrategyJsonList = jsonValue.GetArray("defaultCapacityProviderStrategy");
169 for(unsigned defaultCapacityProviderStrategyIndex = 0; defaultCapacityProviderStrategyIndex < defaultCapacityProviderStrategyJsonList.GetLength(); ++defaultCapacityProviderStrategyIndex)
170 {
171 m_defaultCapacityProviderStrategy.push_back(defaultCapacityProviderStrategyJsonList[defaultCapacityProviderStrategyIndex].AsObject());
172 }
173 m_defaultCapacityProviderStrategyHasBeenSet = true;
174 }
175
176 if(jsonValue.ValueExists("attachments"))
177 {
178 Array<JsonView> attachmentsJsonList = jsonValue.GetArray("attachments");
179 for(unsigned attachmentsIndex = 0; attachmentsIndex < attachmentsJsonList.GetLength(); ++attachmentsIndex)
180 {
181 m_attachments.push_back(attachmentsJsonList[attachmentsIndex].AsObject());
182 }
183 m_attachmentsHasBeenSet = true;
184 }
185
186 if(jsonValue.ValueExists("attachmentsStatus"))
187 {
188 m_attachmentsStatus = jsonValue.GetString("attachmentsStatus");
189
190 m_attachmentsStatusHasBeenSet = true;
191 }
192
193 return *this;
194 }
195
Jsonize() const196 JsonValue Cluster::Jsonize() const
197 {
198 JsonValue payload;
199
200 if(m_clusterArnHasBeenSet)
201 {
202 payload.WithString("clusterArn", m_clusterArn);
203
204 }
205
206 if(m_clusterNameHasBeenSet)
207 {
208 payload.WithString("clusterName", m_clusterName);
209
210 }
211
212 if(m_configurationHasBeenSet)
213 {
214 payload.WithObject("configuration", m_configuration.Jsonize());
215
216 }
217
218 if(m_statusHasBeenSet)
219 {
220 payload.WithString("status", m_status);
221
222 }
223
224 if(m_registeredContainerInstancesCountHasBeenSet)
225 {
226 payload.WithInteger("registeredContainerInstancesCount", m_registeredContainerInstancesCount);
227
228 }
229
230 if(m_runningTasksCountHasBeenSet)
231 {
232 payload.WithInteger("runningTasksCount", m_runningTasksCount);
233
234 }
235
236 if(m_pendingTasksCountHasBeenSet)
237 {
238 payload.WithInteger("pendingTasksCount", m_pendingTasksCount);
239
240 }
241
242 if(m_activeServicesCountHasBeenSet)
243 {
244 payload.WithInteger("activeServicesCount", m_activeServicesCount);
245
246 }
247
248 if(m_statisticsHasBeenSet)
249 {
250 Array<JsonValue> statisticsJsonList(m_statistics.size());
251 for(unsigned statisticsIndex = 0; statisticsIndex < statisticsJsonList.GetLength(); ++statisticsIndex)
252 {
253 statisticsJsonList[statisticsIndex].AsObject(m_statistics[statisticsIndex].Jsonize());
254 }
255 payload.WithArray("statistics", std::move(statisticsJsonList));
256
257 }
258
259 if(m_tagsHasBeenSet)
260 {
261 Array<JsonValue> tagsJsonList(m_tags.size());
262 for(unsigned tagsIndex = 0; tagsIndex < tagsJsonList.GetLength(); ++tagsIndex)
263 {
264 tagsJsonList[tagsIndex].AsObject(m_tags[tagsIndex].Jsonize());
265 }
266 payload.WithArray("tags", std::move(tagsJsonList));
267
268 }
269
270 if(m_settingsHasBeenSet)
271 {
272 Array<JsonValue> settingsJsonList(m_settings.size());
273 for(unsigned settingsIndex = 0; settingsIndex < settingsJsonList.GetLength(); ++settingsIndex)
274 {
275 settingsJsonList[settingsIndex].AsObject(m_settings[settingsIndex].Jsonize());
276 }
277 payload.WithArray("settings", std::move(settingsJsonList));
278
279 }
280
281 if(m_capacityProvidersHasBeenSet)
282 {
283 Array<JsonValue> capacityProvidersJsonList(m_capacityProviders.size());
284 for(unsigned capacityProvidersIndex = 0; capacityProvidersIndex < capacityProvidersJsonList.GetLength(); ++capacityProvidersIndex)
285 {
286 capacityProvidersJsonList[capacityProvidersIndex].AsString(m_capacityProviders[capacityProvidersIndex]);
287 }
288 payload.WithArray("capacityProviders", std::move(capacityProvidersJsonList));
289
290 }
291
292 if(m_defaultCapacityProviderStrategyHasBeenSet)
293 {
294 Array<JsonValue> defaultCapacityProviderStrategyJsonList(m_defaultCapacityProviderStrategy.size());
295 for(unsigned defaultCapacityProviderStrategyIndex = 0; defaultCapacityProviderStrategyIndex < defaultCapacityProviderStrategyJsonList.GetLength(); ++defaultCapacityProviderStrategyIndex)
296 {
297 defaultCapacityProviderStrategyJsonList[defaultCapacityProviderStrategyIndex].AsObject(m_defaultCapacityProviderStrategy[defaultCapacityProviderStrategyIndex].Jsonize());
298 }
299 payload.WithArray("defaultCapacityProviderStrategy", std::move(defaultCapacityProviderStrategyJsonList));
300
301 }
302
303 if(m_attachmentsHasBeenSet)
304 {
305 Array<JsonValue> attachmentsJsonList(m_attachments.size());
306 for(unsigned attachmentsIndex = 0; attachmentsIndex < attachmentsJsonList.GetLength(); ++attachmentsIndex)
307 {
308 attachmentsJsonList[attachmentsIndex].AsObject(m_attachments[attachmentsIndex].Jsonize());
309 }
310 payload.WithArray("attachments", std::move(attachmentsJsonList));
311
312 }
313
314 if(m_attachmentsStatusHasBeenSet)
315 {
316 payload.WithString("attachmentsStatus", m_attachmentsStatus);
317
318 }
319
320 return payload;
321 }
322
323 } // namespace Model
324 } // namespace ECS
325 } // namespace Aws
326