1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/codedeploy/model/CloudFormationTarget.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 CodeDeploy
17 {
18 namespace Model
19 {
20
CloudFormationTarget()21 CloudFormationTarget::CloudFormationTarget() :
22 m_deploymentIdHasBeenSet(false),
23 m_targetIdHasBeenSet(false),
24 m_lastUpdatedAtHasBeenSet(false),
25 m_lifecycleEventsHasBeenSet(false),
26 m_status(TargetStatus::NOT_SET),
27 m_statusHasBeenSet(false),
28 m_resourceTypeHasBeenSet(false),
29 m_targetVersionWeight(0.0),
30 m_targetVersionWeightHasBeenSet(false)
31 {
32 }
33
CloudFormationTarget(JsonView jsonValue)34 CloudFormationTarget::CloudFormationTarget(JsonView jsonValue) :
35 m_deploymentIdHasBeenSet(false),
36 m_targetIdHasBeenSet(false),
37 m_lastUpdatedAtHasBeenSet(false),
38 m_lifecycleEventsHasBeenSet(false),
39 m_status(TargetStatus::NOT_SET),
40 m_statusHasBeenSet(false),
41 m_resourceTypeHasBeenSet(false),
42 m_targetVersionWeight(0.0),
43 m_targetVersionWeightHasBeenSet(false)
44 {
45 *this = jsonValue;
46 }
47
operator =(JsonView jsonValue)48 CloudFormationTarget& CloudFormationTarget::operator =(JsonView jsonValue)
49 {
50 if(jsonValue.ValueExists("deploymentId"))
51 {
52 m_deploymentId = jsonValue.GetString("deploymentId");
53
54 m_deploymentIdHasBeenSet = true;
55 }
56
57 if(jsonValue.ValueExists("targetId"))
58 {
59 m_targetId = jsonValue.GetString("targetId");
60
61 m_targetIdHasBeenSet = true;
62 }
63
64 if(jsonValue.ValueExists("lastUpdatedAt"))
65 {
66 m_lastUpdatedAt = jsonValue.GetDouble("lastUpdatedAt");
67
68 m_lastUpdatedAtHasBeenSet = true;
69 }
70
71 if(jsonValue.ValueExists("lifecycleEvents"))
72 {
73 Array<JsonView> lifecycleEventsJsonList = jsonValue.GetArray("lifecycleEvents");
74 for(unsigned lifecycleEventsIndex = 0; lifecycleEventsIndex < lifecycleEventsJsonList.GetLength(); ++lifecycleEventsIndex)
75 {
76 m_lifecycleEvents.push_back(lifecycleEventsJsonList[lifecycleEventsIndex].AsObject());
77 }
78 m_lifecycleEventsHasBeenSet = true;
79 }
80
81 if(jsonValue.ValueExists("status"))
82 {
83 m_status = TargetStatusMapper::GetTargetStatusForName(jsonValue.GetString("status"));
84
85 m_statusHasBeenSet = true;
86 }
87
88 if(jsonValue.ValueExists("resourceType"))
89 {
90 m_resourceType = jsonValue.GetString("resourceType");
91
92 m_resourceTypeHasBeenSet = true;
93 }
94
95 if(jsonValue.ValueExists("targetVersionWeight"))
96 {
97 m_targetVersionWeight = jsonValue.GetDouble("targetVersionWeight");
98
99 m_targetVersionWeightHasBeenSet = true;
100 }
101
102 return *this;
103 }
104
Jsonize() const105 JsonValue CloudFormationTarget::Jsonize() const
106 {
107 JsonValue payload;
108
109 if(m_deploymentIdHasBeenSet)
110 {
111 payload.WithString("deploymentId", m_deploymentId);
112
113 }
114
115 if(m_targetIdHasBeenSet)
116 {
117 payload.WithString("targetId", m_targetId);
118
119 }
120
121 if(m_lastUpdatedAtHasBeenSet)
122 {
123 payload.WithDouble("lastUpdatedAt", m_lastUpdatedAt.SecondsWithMSPrecision());
124 }
125
126 if(m_lifecycleEventsHasBeenSet)
127 {
128 Array<JsonValue> lifecycleEventsJsonList(m_lifecycleEvents.size());
129 for(unsigned lifecycleEventsIndex = 0; lifecycleEventsIndex < lifecycleEventsJsonList.GetLength(); ++lifecycleEventsIndex)
130 {
131 lifecycleEventsJsonList[lifecycleEventsIndex].AsObject(m_lifecycleEvents[lifecycleEventsIndex].Jsonize());
132 }
133 payload.WithArray("lifecycleEvents", std::move(lifecycleEventsJsonList));
134
135 }
136
137 if(m_statusHasBeenSet)
138 {
139 payload.WithString("status", TargetStatusMapper::GetNameForTargetStatus(m_status));
140 }
141
142 if(m_resourceTypeHasBeenSet)
143 {
144 payload.WithString("resourceType", m_resourceType);
145
146 }
147
148 if(m_targetVersionWeightHasBeenSet)
149 {
150 payload.WithDouble("targetVersionWeight", m_targetVersionWeight);
151
152 }
153
154 return payload;
155 }
156
157 } // namespace Model
158 } // namespace CodeDeploy
159 } // namespace Aws
160