1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/accessanalyzer/model/FindingSummary.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 AccessAnalyzer
17 {
18 namespace Model
19 {
20
FindingSummary()21 FindingSummary::FindingSummary() :
22 m_actionHasBeenSet(false),
23 m_analyzedAtHasBeenSet(false),
24 m_conditionHasBeenSet(false),
25 m_createdAtHasBeenSet(false),
26 m_errorHasBeenSet(false),
27 m_idHasBeenSet(false),
28 m_isPublic(false),
29 m_isPublicHasBeenSet(false),
30 m_principalHasBeenSet(false),
31 m_resourceHasBeenSet(false),
32 m_resourceOwnerAccountHasBeenSet(false),
33 m_resourceType(ResourceType::NOT_SET),
34 m_resourceTypeHasBeenSet(false),
35 m_sourcesHasBeenSet(false),
36 m_status(FindingStatus::NOT_SET),
37 m_statusHasBeenSet(false),
38 m_updatedAtHasBeenSet(false)
39 {
40 }
41
FindingSummary(JsonView jsonValue)42 FindingSummary::FindingSummary(JsonView jsonValue) :
43 m_actionHasBeenSet(false),
44 m_analyzedAtHasBeenSet(false),
45 m_conditionHasBeenSet(false),
46 m_createdAtHasBeenSet(false),
47 m_errorHasBeenSet(false),
48 m_idHasBeenSet(false),
49 m_isPublic(false),
50 m_isPublicHasBeenSet(false),
51 m_principalHasBeenSet(false),
52 m_resourceHasBeenSet(false),
53 m_resourceOwnerAccountHasBeenSet(false),
54 m_resourceType(ResourceType::NOT_SET),
55 m_resourceTypeHasBeenSet(false),
56 m_sourcesHasBeenSet(false),
57 m_status(FindingStatus::NOT_SET),
58 m_statusHasBeenSet(false),
59 m_updatedAtHasBeenSet(false)
60 {
61 *this = jsonValue;
62 }
63
operator =(JsonView jsonValue)64 FindingSummary& FindingSummary::operator =(JsonView jsonValue)
65 {
66 if(jsonValue.ValueExists("action"))
67 {
68 Array<JsonView> actionJsonList = jsonValue.GetArray("action");
69 for(unsigned actionIndex = 0; actionIndex < actionJsonList.GetLength(); ++actionIndex)
70 {
71 m_action.push_back(actionJsonList[actionIndex].AsString());
72 }
73 m_actionHasBeenSet = true;
74 }
75
76 if(jsonValue.ValueExists("analyzedAt"))
77 {
78 m_analyzedAt = jsonValue.GetString("analyzedAt");
79
80 m_analyzedAtHasBeenSet = true;
81 }
82
83 if(jsonValue.ValueExists("condition"))
84 {
85 Aws::Map<Aws::String, JsonView> conditionJsonMap = jsonValue.GetObject("condition").GetAllObjects();
86 for(auto& conditionItem : conditionJsonMap)
87 {
88 m_condition[conditionItem.first] = conditionItem.second.AsString();
89 }
90 m_conditionHasBeenSet = true;
91 }
92
93 if(jsonValue.ValueExists("createdAt"))
94 {
95 m_createdAt = jsonValue.GetString("createdAt");
96
97 m_createdAtHasBeenSet = true;
98 }
99
100 if(jsonValue.ValueExists("error"))
101 {
102 m_error = jsonValue.GetString("error");
103
104 m_errorHasBeenSet = true;
105 }
106
107 if(jsonValue.ValueExists("id"))
108 {
109 m_id = jsonValue.GetString("id");
110
111 m_idHasBeenSet = true;
112 }
113
114 if(jsonValue.ValueExists("isPublic"))
115 {
116 m_isPublic = jsonValue.GetBool("isPublic");
117
118 m_isPublicHasBeenSet = true;
119 }
120
121 if(jsonValue.ValueExists("principal"))
122 {
123 Aws::Map<Aws::String, JsonView> principalJsonMap = jsonValue.GetObject("principal").GetAllObjects();
124 for(auto& principalItem : principalJsonMap)
125 {
126 m_principal[principalItem.first] = principalItem.second.AsString();
127 }
128 m_principalHasBeenSet = true;
129 }
130
131 if(jsonValue.ValueExists("resource"))
132 {
133 m_resource = jsonValue.GetString("resource");
134
135 m_resourceHasBeenSet = true;
136 }
137
138 if(jsonValue.ValueExists("resourceOwnerAccount"))
139 {
140 m_resourceOwnerAccount = jsonValue.GetString("resourceOwnerAccount");
141
142 m_resourceOwnerAccountHasBeenSet = true;
143 }
144
145 if(jsonValue.ValueExists("resourceType"))
146 {
147 m_resourceType = ResourceTypeMapper::GetResourceTypeForName(jsonValue.GetString("resourceType"));
148
149 m_resourceTypeHasBeenSet = true;
150 }
151
152 if(jsonValue.ValueExists("sources"))
153 {
154 Array<JsonView> sourcesJsonList = jsonValue.GetArray("sources");
155 for(unsigned sourcesIndex = 0; sourcesIndex < sourcesJsonList.GetLength(); ++sourcesIndex)
156 {
157 m_sources.push_back(sourcesJsonList[sourcesIndex].AsObject());
158 }
159 m_sourcesHasBeenSet = true;
160 }
161
162 if(jsonValue.ValueExists("status"))
163 {
164 m_status = FindingStatusMapper::GetFindingStatusForName(jsonValue.GetString("status"));
165
166 m_statusHasBeenSet = true;
167 }
168
169 if(jsonValue.ValueExists("updatedAt"))
170 {
171 m_updatedAt = jsonValue.GetString("updatedAt");
172
173 m_updatedAtHasBeenSet = true;
174 }
175
176 return *this;
177 }
178
Jsonize() const179 JsonValue FindingSummary::Jsonize() const
180 {
181 JsonValue payload;
182
183 if(m_actionHasBeenSet)
184 {
185 Array<JsonValue> actionJsonList(m_action.size());
186 for(unsigned actionIndex = 0; actionIndex < actionJsonList.GetLength(); ++actionIndex)
187 {
188 actionJsonList[actionIndex].AsString(m_action[actionIndex]);
189 }
190 payload.WithArray("action", std::move(actionJsonList));
191
192 }
193
194 if(m_analyzedAtHasBeenSet)
195 {
196 payload.WithString("analyzedAt", m_analyzedAt.ToGmtString(DateFormat::ISO_8601));
197 }
198
199 if(m_conditionHasBeenSet)
200 {
201 JsonValue conditionJsonMap;
202 for(auto& conditionItem : m_condition)
203 {
204 conditionJsonMap.WithString(conditionItem.first, conditionItem.second);
205 }
206 payload.WithObject("condition", std::move(conditionJsonMap));
207
208 }
209
210 if(m_createdAtHasBeenSet)
211 {
212 payload.WithString("createdAt", m_createdAt.ToGmtString(DateFormat::ISO_8601));
213 }
214
215 if(m_errorHasBeenSet)
216 {
217 payload.WithString("error", m_error);
218
219 }
220
221 if(m_idHasBeenSet)
222 {
223 payload.WithString("id", m_id);
224
225 }
226
227 if(m_isPublicHasBeenSet)
228 {
229 payload.WithBool("isPublic", m_isPublic);
230
231 }
232
233 if(m_principalHasBeenSet)
234 {
235 JsonValue principalJsonMap;
236 for(auto& principalItem : m_principal)
237 {
238 principalJsonMap.WithString(principalItem.first, principalItem.second);
239 }
240 payload.WithObject("principal", std::move(principalJsonMap));
241
242 }
243
244 if(m_resourceHasBeenSet)
245 {
246 payload.WithString("resource", m_resource);
247
248 }
249
250 if(m_resourceOwnerAccountHasBeenSet)
251 {
252 payload.WithString("resourceOwnerAccount", m_resourceOwnerAccount);
253
254 }
255
256 if(m_resourceTypeHasBeenSet)
257 {
258 payload.WithString("resourceType", ResourceTypeMapper::GetNameForResourceType(m_resourceType));
259 }
260
261 if(m_sourcesHasBeenSet)
262 {
263 Array<JsonValue> sourcesJsonList(m_sources.size());
264 for(unsigned sourcesIndex = 0; sourcesIndex < sourcesJsonList.GetLength(); ++sourcesIndex)
265 {
266 sourcesJsonList[sourcesIndex].AsObject(m_sources[sourcesIndex].Jsonize());
267 }
268 payload.WithArray("sources", std::move(sourcesJsonList));
269
270 }
271
272 if(m_statusHasBeenSet)
273 {
274 payload.WithString("status", FindingStatusMapper::GetNameForFindingStatus(m_status));
275 }
276
277 if(m_updatedAtHasBeenSet)
278 {
279 payload.WithString("updatedAt", m_updatedAt.ToGmtString(DateFormat::ISO_8601));
280 }
281
282 return payload;
283 }
284
285 } // namespace Model
286 } // namespace AccessAnalyzer
287 } // namespace Aws
288