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/Attachment.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
Attachment()21 Attachment::Attachment() :
22 m_idHasBeenSet(false),
23 m_typeHasBeenSet(false),
24 m_statusHasBeenSet(false),
25 m_detailsHasBeenSet(false)
26 {
27 }
28
Attachment(JsonView jsonValue)29 Attachment::Attachment(JsonView jsonValue) :
30 m_idHasBeenSet(false),
31 m_typeHasBeenSet(false),
32 m_statusHasBeenSet(false),
33 m_detailsHasBeenSet(false)
34 {
35 *this = jsonValue;
36 }
37
operator =(JsonView jsonValue)38 Attachment& Attachment::operator =(JsonView jsonValue)
39 {
40 if(jsonValue.ValueExists("id"))
41 {
42 m_id = jsonValue.GetString("id");
43
44 m_idHasBeenSet = true;
45 }
46
47 if(jsonValue.ValueExists("type"))
48 {
49 m_type = jsonValue.GetString("type");
50
51 m_typeHasBeenSet = true;
52 }
53
54 if(jsonValue.ValueExists("status"))
55 {
56 m_status = jsonValue.GetString("status");
57
58 m_statusHasBeenSet = true;
59 }
60
61 if(jsonValue.ValueExists("details"))
62 {
63 Array<JsonView> detailsJsonList = jsonValue.GetArray("details");
64 for(unsigned detailsIndex = 0; detailsIndex < detailsJsonList.GetLength(); ++detailsIndex)
65 {
66 m_details.push_back(detailsJsonList[detailsIndex].AsObject());
67 }
68 m_detailsHasBeenSet = true;
69 }
70
71 return *this;
72 }
73
Jsonize() const74 JsonValue Attachment::Jsonize() const
75 {
76 JsonValue payload;
77
78 if(m_idHasBeenSet)
79 {
80 payload.WithString("id", m_id);
81
82 }
83
84 if(m_typeHasBeenSet)
85 {
86 payload.WithString("type", m_type);
87
88 }
89
90 if(m_statusHasBeenSet)
91 {
92 payload.WithString("status", m_status);
93
94 }
95
96 if(m_detailsHasBeenSet)
97 {
98 Array<JsonValue> detailsJsonList(m_details.size());
99 for(unsigned detailsIndex = 0; detailsIndex < detailsJsonList.GetLength(); ++detailsIndex)
100 {
101 detailsJsonList[detailsIndex].AsObject(m_details[detailsIndex].Jsonize());
102 }
103 payload.WithArray("details", std::move(detailsJsonList));
104
105 }
106
107 return payload;
108 }
109
110 } // namespace Model
111 } // namespace ECS
112 } // namespace Aws
113