1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/mgn/model/Job.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 mgn
17 {
18 namespace Model
19 {
20
Job()21 Job::Job() :
22 m_arnHasBeenSet(false),
23 m_creationDateTimeHasBeenSet(false),
24 m_endDateTimeHasBeenSet(false),
25 m_initiatedBy(InitiatedBy::NOT_SET),
26 m_initiatedByHasBeenSet(false),
27 m_jobIDHasBeenSet(false),
28 m_participatingServersHasBeenSet(false),
29 m_status(JobStatus::NOT_SET),
30 m_statusHasBeenSet(false),
31 m_tagsHasBeenSet(false),
32 m_type(JobType::NOT_SET),
33 m_typeHasBeenSet(false)
34 {
35 }
36
Job(JsonView jsonValue)37 Job::Job(JsonView jsonValue) :
38 m_arnHasBeenSet(false),
39 m_creationDateTimeHasBeenSet(false),
40 m_endDateTimeHasBeenSet(false),
41 m_initiatedBy(InitiatedBy::NOT_SET),
42 m_initiatedByHasBeenSet(false),
43 m_jobIDHasBeenSet(false),
44 m_participatingServersHasBeenSet(false),
45 m_status(JobStatus::NOT_SET),
46 m_statusHasBeenSet(false),
47 m_tagsHasBeenSet(false),
48 m_type(JobType::NOT_SET),
49 m_typeHasBeenSet(false)
50 {
51 *this = jsonValue;
52 }
53
operator =(JsonView jsonValue)54 Job& Job::operator =(JsonView jsonValue)
55 {
56 if(jsonValue.ValueExists("arn"))
57 {
58 m_arn = jsonValue.GetString("arn");
59
60 m_arnHasBeenSet = true;
61 }
62
63 if(jsonValue.ValueExists("creationDateTime"))
64 {
65 m_creationDateTime = jsonValue.GetString("creationDateTime");
66
67 m_creationDateTimeHasBeenSet = true;
68 }
69
70 if(jsonValue.ValueExists("endDateTime"))
71 {
72 m_endDateTime = jsonValue.GetString("endDateTime");
73
74 m_endDateTimeHasBeenSet = true;
75 }
76
77 if(jsonValue.ValueExists("initiatedBy"))
78 {
79 m_initiatedBy = InitiatedByMapper::GetInitiatedByForName(jsonValue.GetString("initiatedBy"));
80
81 m_initiatedByHasBeenSet = true;
82 }
83
84 if(jsonValue.ValueExists("jobID"))
85 {
86 m_jobID = jsonValue.GetString("jobID");
87
88 m_jobIDHasBeenSet = true;
89 }
90
91 if(jsonValue.ValueExists("participatingServers"))
92 {
93 Array<JsonView> participatingServersJsonList = jsonValue.GetArray("participatingServers");
94 for(unsigned participatingServersIndex = 0; participatingServersIndex < participatingServersJsonList.GetLength(); ++participatingServersIndex)
95 {
96 m_participatingServers.push_back(participatingServersJsonList[participatingServersIndex].AsObject());
97 }
98 m_participatingServersHasBeenSet = true;
99 }
100
101 if(jsonValue.ValueExists("status"))
102 {
103 m_status = JobStatusMapper::GetJobStatusForName(jsonValue.GetString("status"));
104
105 m_statusHasBeenSet = true;
106 }
107
108 if(jsonValue.ValueExists("tags"))
109 {
110 Aws::Map<Aws::String, JsonView> tagsJsonMap = jsonValue.GetObject("tags").GetAllObjects();
111 for(auto& tagsItem : tagsJsonMap)
112 {
113 m_tags[tagsItem.first] = tagsItem.second.AsString();
114 }
115 m_tagsHasBeenSet = true;
116 }
117
118 if(jsonValue.ValueExists("type"))
119 {
120 m_type = JobTypeMapper::GetJobTypeForName(jsonValue.GetString("type"));
121
122 m_typeHasBeenSet = true;
123 }
124
125 return *this;
126 }
127
Jsonize() const128 JsonValue Job::Jsonize() const
129 {
130 JsonValue payload;
131
132 if(m_arnHasBeenSet)
133 {
134 payload.WithString("arn", m_arn);
135
136 }
137
138 if(m_creationDateTimeHasBeenSet)
139 {
140 payload.WithString("creationDateTime", m_creationDateTime);
141
142 }
143
144 if(m_endDateTimeHasBeenSet)
145 {
146 payload.WithString("endDateTime", m_endDateTime);
147
148 }
149
150 if(m_initiatedByHasBeenSet)
151 {
152 payload.WithString("initiatedBy", InitiatedByMapper::GetNameForInitiatedBy(m_initiatedBy));
153 }
154
155 if(m_jobIDHasBeenSet)
156 {
157 payload.WithString("jobID", m_jobID);
158
159 }
160
161 if(m_participatingServersHasBeenSet)
162 {
163 Array<JsonValue> participatingServersJsonList(m_participatingServers.size());
164 for(unsigned participatingServersIndex = 0; participatingServersIndex < participatingServersJsonList.GetLength(); ++participatingServersIndex)
165 {
166 participatingServersJsonList[participatingServersIndex].AsObject(m_participatingServers[participatingServersIndex].Jsonize());
167 }
168 payload.WithArray("participatingServers", std::move(participatingServersJsonList));
169
170 }
171
172 if(m_statusHasBeenSet)
173 {
174 payload.WithString("status", JobStatusMapper::GetNameForJobStatus(m_status));
175 }
176
177 if(m_tagsHasBeenSet)
178 {
179 JsonValue tagsJsonMap;
180 for(auto& tagsItem : m_tags)
181 {
182 tagsJsonMap.WithString(tagsItem.first, tagsItem.second);
183 }
184 payload.WithObject("tags", std::move(tagsJsonMap));
185
186 }
187
188 if(m_typeHasBeenSet)
189 {
190 payload.WithString("type", JobTypeMapper::GetNameForJobType(m_type));
191 }
192
193 return payload;
194 }
195
196 } // namespace Model
197 } // namespace mgn
198 } // namespace Aws
199