1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/medialive/model/Reservation.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 MediaLive
17 {
18 namespace Model
19 {
20 
Reservation()21 Reservation::Reservation() :
22     m_arnHasBeenSet(false),
23     m_count(0),
24     m_countHasBeenSet(false),
25     m_currencyCodeHasBeenSet(false),
26     m_duration(0),
27     m_durationHasBeenSet(false),
28     m_durationUnits(OfferingDurationUnits::NOT_SET),
29     m_durationUnitsHasBeenSet(false),
30     m_endHasBeenSet(false),
31     m_fixedPrice(0.0),
32     m_fixedPriceHasBeenSet(false),
33     m_nameHasBeenSet(false),
34     m_offeringDescriptionHasBeenSet(false),
35     m_offeringIdHasBeenSet(false),
36     m_offeringType(OfferingType::NOT_SET),
37     m_offeringTypeHasBeenSet(false),
38     m_regionHasBeenSet(false),
39     m_reservationIdHasBeenSet(false),
40     m_resourceSpecificationHasBeenSet(false),
41     m_startHasBeenSet(false),
42     m_state(ReservationState::NOT_SET),
43     m_stateHasBeenSet(false),
44     m_tagsHasBeenSet(false),
45     m_usagePrice(0.0),
46     m_usagePriceHasBeenSet(false)
47 {
48 }
49 
Reservation(JsonView jsonValue)50 Reservation::Reservation(JsonView jsonValue) :
51     m_arnHasBeenSet(false),
52     m_count(0),
53     m_countHasBeenSet(false),
54     m_currencyCodeHasBeenSet(false),
55     m_duration(0),
56     m_durationHasBeenSet(false),
57     m_durationUnits(OfferingDurationUnits::NOT_SET),
58     m_durationUnitsHasBeenSet(false),
59     m_endHasBeenSet(false),
60     m_fixedPrice(0.0),
61     m_fixedPriceHasBeenSet(false),
62     m_nameHasBeenSet(false),
63     m_offeringDescriptionHasBeenSet(false),
64     m_offeringIdHasBeenSet(false),
65     m_offeringType(OfferingType::NOT_SET),
66     m_offeringTypeHasBeenSet(false),
67     m_regionHasBeenSet(false),
68     m_reservationIdHasBeenSet(false),
69     m_resourceSpecificationHasBeenSet(false),
70     m_startHasBeenSet(false),
71     m_state(ReservationState::NOT_SET),
72     m_stateHasBeenSet(false),
73     m_tagsHasBeenSet(false),
74     m_usagePrice(0.0),
75     m_usagePriceHasBeenSet(false)
76 {
77   *this = jsonValue;
78 }
79 
operator =(JsonView jsonValue)80 Reservation& Reservation::operator =(JsonView jsonValue)
81 {
82   if(jsonValue.ValueExists("arn"))
83   {
84     m_arn = jsonValue.GetString("arn");
85 
86     m_arnHasBeenSet = true;
87   }
88 
89   if(jsonValue.ValueExists("count"))
90   {
91     m_count = jsonValue.GetInteger("count");
92 
93     m_countHasBeenSet = true;
94   }
95 
96   if(jsonValue.ValueExists("currencyCode"))
97   {
98     m_currencyCode = jsonValue.GetString("currencyCode");
99 
100     m_currencyCodeHasBeenSet = true;
101   }
102 
103   if(jsonValue.ValueExists("duration"))
104   {
105     m_duration = jsonValue.GetInteger("duration");
106 
107     m_durationHasBeenSet = true;
108   }
109 
110   if(jsonValue.ValueExists("durationUnits"))
111   {
112     m_durationUnits = OfferingDurationUnitsMapper::GetOfferingDurationUnitsForName(jsonValue.GetString("durationUnits"));
113 
114     m_durationUnitsHasBeenSet = true;
115   }
116 
117   if(jsonValue.ValueExists("end"))
118   {
119     m_end = jsonValue.GetString("end");
120 
121     m_endHasBeenSet = true;
122   }
123 
124   if(jsonValue.ValueExists("fixedPrice"))
125   {
126     m_fixedPrice = jsonValue.GetDouble("fixedPrice");
127 
128     m_fixedPriceHasBeenSet = true;
129   }
130 
131   if(jsonValue.ValueExists("name"))
132   {
133     m_name = jsonValue.GetString("name");
134 
135     m_nameHasBeenSet = true;
136   }
137 
138   if(jsonValue.ValueExists("offeringDescription"))
139   {
140     m_offeringDescription = jsonValue.GetString("offeringDescription");
141 
142     m_offeringDescriptionHasBeenSet = true;
143   }
144 
145   if(jsonValue.ValueExists("offeringId"))
146   {
147     m_offeringId = jsonValue.GetString("offeringId");
148 
149     m_offeringIdHasBeenSet = true;
150   }
151 
152   if(jsonValue.ValueExists("offeringType"))
153   {
154     m_offeringType = OfferingTypeMapper::GetOfferingTypeForName(jsonValue.GetString("offeringType"));
155 
156     m_offeringTypeHasBeenSet = true;
157   }
158 
159   if(jsonValue.ValueExists("region"))
160   {
161     m_region = jsonValue.GetString("region");
162 
163     m_regionHasBeenSet = true;
164   }
165 
166   if(jsonValue.ValueExists("reservationId"))
167   {
168     m_reservationId = jsonValue.GetString("reservationId");
169 
170     m_reservationIdHasBeenSet = true;
171   }
172 
173   if(jsonValue.ValueExists("resourceSpecification"))
174   {
175     m_resourceSpecification = jsonValue.GetObject("resourceSpecification");
176 
177     m_resourceSpecificationHasBeenSet = true;
178   }
179 
180   if(jsonValue.ValueExists("start"))
181   {
182     m_start = jsonValue.GetString("start");
183 
184     m_startHasBeenSet = true;
185   }
186 
187   if(jsonValue.ValueExists("state"))
188   {
189     m_state = ReservationStateMapper::GetReservationStateForName(jsonValue.GetString("state"));
190 
191     m_stateHasBeenSet = true;
192   }
193 
194   if(jsonValue.ValueExists("tags"))
195   {
196     Aws::Map<Aws::String, JsonView> tagsJsonMap = jsonValue.GetObject("tags").GetAllObjects();
197     for(auto& tagsItem : tagsJsonMap)
198     {
199       m_tags[tagsItem.first] = tagsItem.second.AsString();
200     }
201     m_tagsHasBeenSet = true;
202   }
203 
204   if(jsonValue.ValueExists("usagePrice"))
205   {
206     m_usagePrice = jsonValue.GetDouble("usagePrice");
207 
208     m_usagePriceHasBeenSet = true;
209   }
210 
211   return *this;
212 }
213 
Jsonize() const214 JsonValue Reservation::Jsonize() const
215 {
216   JsonValue payload;
217 
218   if(m_arnHasBeenSet)
219   {
220    payload.WithString("arn", m_arn);
221 
222   }
223 
224   if(m_countHasBeenSet)
225   {
226    payload.WithInteger("count", m_count);
227 
228   }
229 
230   if(m_currencyCodeHasBeenSet)
231   {
232    payload.WithString("currencyCode", m_currencyCode);
233 
234   }
235 
236   if(m_durationHasBeenSet)
237   {
238    payload.WithInteger("duration", m_duration);
239 
240   }
241 
242   if(m_durationUnitsHasBeenSet)
243   {
244    payload.WithString("durationUnits", OfferingDurationUnitsMapper::GetNameForOfferingDurationUnits(m_durationUnits));
245   }
246 
247   if(m_endHasBeenSet)
248   {
249    payload.WithString("end", m_end);
250 
251   }
252 
253   if(m_fixedPriceHasBeenSet)
254   {
255    payload.WithDouble("fixedPrice", m_fixedPrice);
256 
257   }
258 
259   if(m_nameHasBeenSet)
260   {
261    payload.WithString("name", m_name);
262 
263   }
264 
265   if(m_offeringDescriptionHasBeenSet)
266   {
267    payload.WithString("offeringDescription", m_offeringDescription);
268 
269   }
270 
271   if(m_offeringIdHasBeenSet)
272   {
273    payload.WithString("offeringId", m_offeringId);
274 
275   }
276 
277   if(m_offeringTypeHasBeenSet)
278   {
279    payload.WithString("offeringType", OfferingTypeMapper::GetNameForOfferingType(m_offeringType));
280   }
281 
282   if(m_regionHasBeenSet)
283   {
284    payload.WithString("region", m_region);
285 
286   }
287 
288   if(m_reservationIdHasBeenSet)
289   {
290    payload.WithString("reservationId", m_reservationId);
291 
292   }
293 
294   if(m_resourceSpecificationHasBeenSet)
295   {
296    payload.WithObject("resourceSpecification", m_resourceSpecification.Jsonize());
297 
298   }
299 
300   if(m_startHasBeenSet)
301   {
302    payload.WithString("start", m_start);
303 
304   }
305 
306   if(m_stateHasBeenSet)
307   {
308    payload.WithString("state", ReservationStateMapper::GetNameForReservationState(m_state));
309   }
310 
311   if(m_tagsHasBeenSet)
312   {
313    JsonValue tagsJsonMap;
314    for(auto& tagsItem : m_tags)
315    {
316      tagsJsonMap.WithString(tagsItem.first, tagsItem.second);
317    }
318    payload.WithObject("tags", std::move(tagsJsonMap));
319 
320   }
321 
322   if(m_usagePriceHasBeenSet)
323   {
324    payload.WithDouble("usagePrice", m_usagePrice);
325 
326   }
327 
328   return payload;
329 }
330 
331 } // namespace Model
332 } // namespace MediaLive
333 } // namespace Aws
334