1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/awstransfer/model/DescribedServer.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 Transfer
17 {
18 namespace Model
19 {
20 
DescribedServer()21 DescribedServer::DescribedServer() :
22     m_arnHasBeenSet(false),
23     m_certificateHasBeenSet(false),
24     m_protocolDetailsHasBeenSet(false),
25     m_domain(Domain::NOT_SET),
26     m_domainHasBeenSet(false),
27     m_endpointDetailsHasBeenSet(false),
28     m_endpointType(EndpointType::NOT_SET),
29     m_endpointTypeHasBeenSet(false),
30     m_hostKeyFingerprintHasBeenSet(false),
31     m_identityProviderDetailsHasBeenSet(false),
32     m_identityProviderType(IdentityProviderType::NOT_SET),
33     m_identityProviderTypeHasBeenSet(false),
34     m_loggingRoleHasBeenSet(false),
35     m_protocolsHasBeenSet(false),
36     m_securityPolicyNameHasBeenSet(false),
37     m_serverIdHasBeenSet(false),
38     m_state(State::NOT_SET),
39     m_stateHasBeenSet(false),
40     m_tagsHasBeenSet(false),
41     m_userCount(0),
42     m_userCountHasBeenSet(false),
43     m_workflowDetailsHasBeenSet(false)
44 {
45 }
46 
DescribedServer(JsonView jsonValue)47 DescribedServer::DescribedServer(JsonView jsonValue) :
48     m_arnHasBeenSet(false),
49     m_certificateHasBeenSet(false),
50     m_protocolDetailsHasBeenSet(false),
51     m_domain(Domain::NOT_SET),
52     m_domainHasBeenSet(false),
53     m_endpointDetailsHasBeenSet(false),
54     m_endpointType(EndpointType::NOT_SET),
55     m_endpointTypeHasBeenSet(false),
56     m_hostKeyFingerprintHasBeenSet(false),
57     m_identityProviderDetailsHasBeenSet(false),
58     m_identityProviderType(IdentityProviderType::NOT_SET),
59     m_identityProviderTypeHasBeenSet(false),
60     m_loggingRoleHasBeenSet(false),
61     m_protocolsHasBeenSet(false),
62     m_securityPolicyNameHasBeenSet(false),
63     m_serverIdHasBeenSet(false),
64     m_state(State::NOT_SET),
65     m_stateHasBeenSet(false),
66     m_tagsHasBeenSet(false),
67     m_userCount(0),
68     m_userCountHasBeenSet(false),
69     m_workflowDetailsHasBeenSet(false)
70 {
71   *this = jsonValue;
72 }
73 
operator =(JsonView jsonValue)74 DescribedServer& DescribedServer::operator =(JsonView jsonValue)
75 {
76   if(jsonValue.ValueExists("Arn"))
77   {
78     m_arn = jsonValue.GetString("Arn");
79 
80     m_arnHasBeenSet = true;
81   }
82 
83   if(jsonValue.ValueExists("Certificate"))
84   {
85     m_certificate = jsonValue.GetString("Certificate");
86 
87     m_certificateHasBeenSet = true;
88   }
89 
90   if(jsonValue.ValueExists("ProtocolDetails"))
91   {
92     m_protocolDetails = jsonValue.GetObject("ProtocolDetails");
93 
94     m_protocolDetailsHasBeenSet = true;
95   }
96 
97   if(jsonValue.ValueExists("Domain"))
98   {
99     m_domain = DomainMapper::GetDomainForName(jsonValue.GetString("Domain"));
100 
101     m_domainHasBeenSet = true;
102   }
103 
104   if(jsonValue.ValueExists("EndpointDetails"))
105   {
106     m_endpointDetails = jsonValue.GetObject("EndpointDetails");
107 
108     m_endpointDetailsHasBeenSet = true;
109   }
110 
111   if(jsonValue.ValueExists("EndpointType"))
112   {
113     m_endpointType = EndpointTypeMapper::GetEndpointTypeForName(jsonValue.GetString("EndpointType"));
114 
115     m_endpointTypeHasBeenSet = true;
116   }
117 
118   if(jsonValue.ValueExists("HostKeyFingerprint"))
119   {
120     m_hostKeyFingerprint = jsonValue.GetString("HostKeyFingerprint");
121 
122     m_hostKeyFingerprintHasBeenSet = true;
123   }
124 
125   if(jsonValue.ValueExists("IdentityProviderDetails"))
126   {
127     m_identityProviderDetails = jsonValue.GetObject("IdentityProviderDetails");
128 
129     m_identityProviderDetailsHasBeenSet = true;
130   }
131 
132   if(jsonValue.ValueExists("IdentityProviderType"))
133   {
134     m_identityProviderType = IdentityProviderTypeMapper::GetIdentityProviderTypeForName(jsonValue.GetString("IdentityProviderType"));
135 
136     m_identityProviderTypeHasBeenSet = true;
137   }
138 
139   if(jsonValue.ValueExists("LoggingRole"))
140   {
141     m_loggingRole = jsonValue.GetString("LoggingRole");
142 
143     m_loggingRoleHasBeenSet = true;
144   }
145 
146   if(jsonValue.ValueExists("Protocols"))
147   {
148     Array<JsonView> protocolsJsonList = jsonValue.GetArray("Protocols");
149     for(unsigned protocolsIndex = 0; protocolsIndex < protocolsJsonList.GetLength(); ++protocolsIndex)
150     {
151       m_protocols.push_back(ProtocolMapper::GetProtocolForName(protocolsJsonList[protocolsIndex].AsString()));
152     }
153     m_protocolsHasBeenSet = true;
154   }
155 
156   if(jsonValue.ValueExists("SecurityPolicyName"))
157   {
158     m_securityPolicyName = jsonValue.GetString("SecurityPolicyName");
159 
160     m_securityPolicyNameHasBeenSet = true;
161   }
162 
163   if(jsonValue.ValueExists("ServerId"))
164   {
165     m_serverId = jsonValue.GetString("ServerId");
166 
167     m_serverIdHasBeenSet = true;
168   }
169 
170   if(jsonValue.ValueExists("State"))
171   {
172     m_state = StateMapper::GetStateForName(jsonValue.GetString("State"));
173 
174     m_stateHasBeenSet = true;
175   }
176 
177   if(jsonValue.ValueExists("Tags"))
178   {
179     Array<JsonView> tagsJsonList = jsonValue.GetArray("Tags");
180     for(unsigned tagsIndex = 0; tagsIndex < tagsJsonList.GetLength(); ++tagsIndex)
181     {
182       m_tags.push_back(tagsJsonList[tagsIndex].AsObject());
183     }
184     m_tagsHasBeenSet = true;
185   }
186 
187   if(jsonValue.ValueExists("UserCount"))
188   {
189     m_userCount = jsonValue.GetInteger("UserCount");
190 
191     m_userCountHasBeenSet = true;
192   }
193 
194   if(jsonValue.ValueExists("WorkflowDetails"))
195   {
196     m_workflowDetails = jsonValue.GetObject("WorkflowDetails");
197 
198     m_workflowDetailsHasBeenSet = true;
199   }
200 
201   return *this;
202 }
203 
Jsonize() const204 JsonValue DescribedServer::Jsonize() const
205 {
206   JsonValue payload;
207 
208   if(m_arnHasBeenSet)
209   {
210    payload.WithString("Arn", m_arn);
211 
212   }
213 
214   if(m_certificateHasBeenSet)
215   {
216    payload.WithString("Certificate", m_certificate);
217 
218   }
219 
220   if(m_protocolDetailsHasBeenSet)
221   {
222    payload.WithObject("ProtocolDetails", m_protocolDetails.Jsonize());
223 
224   }
225 
226   if(m_domainHasBeenSet)
227   {
228    payload.WithString("Domain", DomainMapper::GetNameForDomain(m_domain));
229   }
230 
231   if(m_endpointDetailsHasBeenSet)
232   {
233    payload.WithObject("EndpointDetails", m_endpointDetails.Jsonize());
234 
235   }
236 
237   if(m_endpointTypeHasBeenSet)
238   {
239    payload.WithString("EndpointType", EndpointTypeMapper::GetNameForEndpointType(m_endpointType));
240   }
241 
242   if(m_hostKeyFingerprintHasBeenSet)
243   {
244    payload.WithString("HostKeyFingerprint", m_hostKeyFingerprint);
245 
246   }
247 
248   if(m_identityProviderDetailsHasBeenSet)
249   {
250    payload.WithObject("IdentityProviderDetails", m_identityProviderDetails.Jsonize());
251 
252   }
253 
254   if(m_identityProviderTypeHasBeenSet)
255   {
256    payload.WithString("IdentityProviderType", IdentityProviderTypeMapper::GetNameForIdentityProviderType(m_identityProviderType));
257   }
258 
259   if(m_loggingRoleHasBeenSet)
260   {
261    payload.WithString("LoggingRole", m_loggingRole);
262 
263   }
264 
265   if(m_protocolsHasBeenSet)
266   {
267    Array<JsonValue> protocolsJsonList(m_protocols.size());
268    for(unsigned protocolsIndex = 0; protocolsIndex < protocolsJsonList.GetLength(); ++protocolsIndex)
269    {
270      protocolsJsonList[protocolsIndex].AsString(ProtocolMapper::GetNameForProtocol(m_protocols[protocolsIndex]));
271    }
272    payload.WithArray("Protocols", std::move(protocolsJsonList));
273 
274   }
275 
276   if(m_securityPolicyNameHasBeenSet)
277   {
278    payload.WithString("SecurityPolicyName", m_securityPolicyName);
279 
280   }
281 
282   if(m_serverIdHasBeenSet)
283   {
284    payload.WithString("ServerId", m_serverId);
285 
286   }
287 
288   if(m_stateHasBeenSet)
289   {
290    payload.WithString("State", StateMapper::GetNameForState(m_state));
291   }
292 
293   if(m_tagsHasBeenSet)
294   {
295    Array<JsonValue> tagsJsonList(m_tags.size());
296    for(unsigned tagsIndex = 0; tagsIndex < tagsJsonList.GetLength(); ++tagsIndex)
297    {
298      tagsJsonList[tagsIndex].AsObject(m_tags[tagsIndex].Jsonize());
299    }
300    payload.WithArray("Tags", std::move(tagsJsonList));
301 
302   }
303 
304   if(m_userCountHasBeenSet)
305   {
306    payload.WithInteger("UserCount", m_userCount);
307 
308   }
309 
310   if(m_workflowDetailsHasBeenSet)
311   {
312    payload.WithObject("WorkflowDetails", m_workflowDetails.Jsonize());
313 
314   }
315 
316   return payload;
317 }
318 
319 } // namespace Model
320 } // namespace Transfer
321 } // namespace Aws
322