1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/lightsail/model/Operation.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 Lightsail
17 {
18 namespace Model
19 {
20 
Operation()21 Operation::Operation() :
22     m_idHasBeenSet(false),
23     m_resourceNameHasBeenSet(false),
24     m_resourceType(ResourceType::NOT_SET),
25     m_resourceTypeHasBeenSet(false),
26     m_createdAtHasBeenSet(false),
27     m_locationHasBeenSet(false),
28     m_isTerminal(false),
29     m_isTerminalHasBeenSet(false),
30     m_operationDetailsHasBeenSet(false),
31     m_operationType(OperationType::NOT_SET),
32     m_operationTypeHasBeenSet(false),
33     m_status(OperationStatus::NOT_SET),
34     m_statusHasBeenSet(false),
35     m_statusChangedAtHasBeenSet(false),
36     m_errorCodeHasBeenSet(false),
37     m_errorDetailsHasBeenSet(false)
38 {
39 }
40 
Operation(JsonView jsonValue)41 Operation::Operation(JsonView jsonValue) :
42     m_idHasBeenSet(false),
43     m_resourceNameHasBeenSet(false),
44     m_resourceType(ResourceType::NOT_SET),
45     m_resourceTypeHasBeenSet(false),
46     m_createdAtHasBeenSet(false),
47     m_locationHasBeenSet(false),
48     m_isTerminal(false),
49     m_isTerminalHasBeenSet(false),
50     m_operationDetailsHasBeenSet(false),
51     m_operationType(OperationType::NOT_SET),
52     m_operationTypeHasBeenSet(false),
53     m_status(OperationStatus::NOT_SET),
54     m_statusHasBeenSet(false),
55     m_statusChangedAtHasBeenSet(false),
56     m_errorCodeHasBeenSet(false),
57     m_errorDetailsHasBeenSet(false)
58 {
59   *this = jsonValue;
60 }
61 
operator =(JsonView jsonValue)62 Operation& Operation::operator =(JsonView jsonValue)
63 {
64   if(jsonValue.ValueExists("id"))
65   {
66     m_id = jsonValue.GetString("id");
67 
68     m_idHasBeenSet = true;
69   }
70 
71   if(jsonValue.ValueExists("resourceName"))
72   {
73     m_resourceName = jsonValue.GetString("resourceName");
74 
75     m_resourceNameHasBeenSet = true;
76   }
77 
78   if(jsonValue.ValueExists("resourceType"))
79   {
80     m_resourceType = ResourceTypeMapper::GetResourceTypeForName(jsonValue.GetString("resourceType"));
81 
82     m_resourceTypeHasBeenSet = true;
83   }
84 
85   if(jsonValue.ValueExists("createdAt"))
86   {
87     m_createdAt = jsonValue.GetDouble("createdAt");
88 
89     m_createdAtHasBeenSet = true;
90   }
91 
92   if(jsonValue.ValueExists("location"))
93   {
94     m_location = jsonValue.GetObject("location");
95 
96     m_locationHasBeenSet = true;
97   }
98 
99   if(jsonValue.ValueExists("isTerminal"))
100   {
101     m_isTerminal = jsonValue.GetBool("isTerminal");
102 
103     m_isTerminalHasBeenSet = true;
104   }
105 
106   if(jsonValue.ValueExists("operationDetails"))
107   {
108     m_operationDetails = jsonValue.GetString("operationDetails");
109 
110     m_operationDetailsHasBeenSet = true;
111   }
112 
113   if(jsonValue.ValueExists("operationType"))
114   {
115     m_operationType = OperationTypeMapper::GetOperationTypeForName(jsonValue.GetString("operationType"));
116 
117     m_operationTypeHasBeenSet = true;
118   }
119 
120   if(jsonValue.ValueExists("status"))
121   {
122     m_status = OperationStatusMapper::GetOperationStatusForName(jsonValue.GetString("status"));
123 
124     m_statusHasBeenSet = true;
125   }
126 
127   if(jsonValue.ValueExists("statusChangedAt"))
128   {
129     m_statusChangedAt = jsonValue.GetDouble("statusChangedAt");
130 
131     m_statusChangedAtHasBeenSet = true;
132   }
133 
134   if(jsonValue.ValueExists("errorCode"))
135   {
136     m_errorCode = jsonValue.GetString("errorCode");
137 
138     m_errorCodeHasBeenSet = true;
139   }
140 
141   if(jsonValue.ValueExists("errorDetails"))
142   {
143     m_errorDetails = jsonValue.GetString("errorDetails");
144 
145     m_errorDetailsHasBeenSet = true;
146   }
147 
148   return *this;
149 }
150 
Jsonize() const151 JsonValue Operation::Jsonize() const
152 {
153   JsonValue payload;
154 
155   if(m_idHasBeenSet)
156   {
157    payload.WithString("id", m_id);
158 
159   }
160 
161   if(m_resourceNameHasBeenSet)
162   {
163    payload.WithString("resourceName", m_resourceName);
164 
165   }
166 
167   if(m_resourceTypeHasBeenSet)
168   {
169    payload.WithString("resourceType", ResourceTypeMapper::GetNameForResourceType(m_resourceType));
170   }
171 
172   if(m_createdAtHasBeenSet)
173   {
174    payload.WithDouble("createdAt", m_createdAt.SecondsWithMSPrecision());
175   }
176 
177   if(m_locationHasBeenSet)
178   {
179    payload.WithObject("location", m_location.Jsonize());
180 
181   }
182 
183   if(m_isTerminalHasBeenSet)
184   {
185    payload.WithBool("isTerminal", m_isTerminal);
186 
187   }
188 
189   if(m_operationDetailsHasBeenSet)
190   {
191    payload.WithString("operationDetails", m_operationDetails);
192 
193   }
194 
195   if(m_operationTypeHasBeenSet)
196   {
197    payload.WithString("operationType", OperationTypeMapper::GetNameForOperationType(m_operationType));
198   }
199 
200   if(m_statusHasBeenSet)
201   {
202    payload.WithString("status", OperationStatusMapper::GetNameForOperationStatus(m_status));
203   }
204 
205   if(m_statusChangedAtHasBeenSet)
206   {
207    payload.WithDouble("statusChangedAt", m_statusChangedAt.SecondsWithMSPrecision());
208   }
209 
210   if(m_errorCodeHasBeenSet)
211   {
212    payload.WithString("errorCode", m_errorCode);
213 
214   }
215 
216   if(m_errorDetailsHasBeenSet)
217   {
218    payload.WithString("errorDetails", m_errorDetails);
219 
220   }
221 
222   return payload;
223 }
224 
225 } // namespace Model
226 } // namespace Lightsail
227 } // namespace Aws
228