1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/glue/model/Crawler.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 Glue
17 {
18 namespace Model
19 {
20 
Crawler()21 Crawler::Crawler() :
22     m_nameHasBeenSet(false),
23     m_roleHasBeenSet(false),
24     m_targetsHasBeenSet(false),
25     m_databaseNameHasBeenSet(false),
26     m_descriptionHasBeenSet(false),
27     m_classifiersHasBeenSet(false),
28     m_recrawlPolicyHasBeenSet(false),
29     m_schemaChangePolicyHasBeenSet(false),
30     m_lineageConfigurationHasBeenSet(false),
31     m_state(CrawlerState::NOT_SET),
32     m_stateHasBeenSet(false),
33     m_tablePrefixHasBeenSet(false),
34     m_scheduleHasBeenSet(false),
35     m_crawlElapsedTime(0),
36     m_crawlElapsedTimeHasBeenSet(false),
37     m_creationTimeHasBeenSet(false),
38     m_lastUpdatedHasBeenSet(false),
39     m_lastCrawlHasBeenSet(false),
40     m_version(0),
41     m_versionHasBeenSet(false),
42     m_configurationHasBeenSet(false),
43     m_crawlerSecurityConfigurationHasBeenSet(false)
44 {
45 }
46 
Crawler(JsonView jsonValue)47 Crawler::Crawler(JsonView jsonValue) :
48     m_nameHasBeenSet(false),
49     m_roleHasBeenSet(false),
50     m_targetsHasBeenSet(false),
51     m_databaseNameHasBeenSet(false),
52     m_descriptionHasBeenSet(false),
53     m_classifiersHasBeenSet(false),
54     m_recrawlPolicyHasBeenSet(false),
55     m_schemaChangePolicyHasBeenSet(false),
56     m_lineageConfigurationHasBeenSet(false),
57     m_state(CrawlerState::NOT_SET),
58     m_stateHasBeenSet(false),
59     m_tablePrefixHasBeenSet(false),
60     m_scheduleHasBeenSet(false),
61     m_crawlElapsedTime(0),
62     m_crawlElapsedTimeHasBeenSet(false),
63     m_creationTimeHasBeenSet(false),
64     m_lastUpdatedHasBeenSet(false),
65     m_lastCrawlHasBeenSet(false),
66     m_version(0),
67     m_versionHasBeenSet(false),
68     m_configurationHasBeenSet(false),
69     m_crawlerSecurityConfigurationHasBeenSet(false)
70 {
71   *this = jsonValue;
72 }
73 
operator =(JsonView jsonValue)74 Crawler& Crawler::operator =(JsonView jsonValue)
75 {
76   if(jsonValue.ValueExists("Name"))
77   {
78     m_name = jsonValue.GetString("Name");
79 
80     m_nameHasBeenSet = true;
81   }
82 
83   if(jsonValue.ValueExists("Role"))
84   {
85     m_role = jsonValue.GetString("Role");
86 
87     m_roleHasBeenSet = true;
88   }
89 
90   if(jsonValue.ValueExists("Targets"))
91   {
92     m_targets = jsonValue.GetObject("Targets");
93 
94     m_targetsHasBeenSet = true;
95   }
96 
97   if(jsonValue.ValueExists("DatabaseName"))
98   {
99     m_databaseName = jsonValue.GetString("DatabaseName");
100 
101     m_databaseNameHasBeenSet = true;
102   }
103 
104   if(jsonValue.ValueExists("Description"))
105   {
106     m_description = jsonValue.GetString("Description");
107 
108     m_descriptionHasBeenSet = true;
109   }
110 
111   if(jsonValue.ValueExists("Classifiers"))
112   {
113     Array<JsonView> classifiersJsonList = jsonValue.GetArray("Classifiers");
114     for(unsigned classifiersIndex = 0; classifiersIndex < classifiersJsonList.GetLength(); ++classifiersIndex)
115     {
116       m_classifiers.push_back(classifiersJsonList[classifiersIndex].AsString());
117     }
118     m_classifiersHasBeenSet = true;
119   }
120 
121   if(jsonValue.ValueExists("RecrawlPolicy"))
122   {
123     m_recrawlPolicy = jsonValue.GetObject("RecrawlPolicy");
124 
125     m_recrawlPolicyHasBeenSet = true;
126   }
127 
128   if(jsonValue.ValueExists("SchemaChangePolicy"))
129   {
130     m_schemaChangePolicy = jsonValue.GetObject("SchemaChangePolicy");
131 
132     m_schemaChangePolicyHasBeenSet = true;
133   }
134 
135   if(jsonValue.ValueExists("LineageConfiguration"))
136   {
137     m_lineageConfiguration = jsonValue.GetObject("LineageConfiguration");
138 
139     m_lineageConfigurationHasBeenSet = true;
140   }
141 
142   if(jsonValue.ValueExists("State"))
143   {
144     m_state = CrawlerStateMapper::GetCrawlerStateForName(jsonValue.GetString("State"));
145 
146     m_stateHasBeenSet = true;
147   }
148 
149   if(jsonValue.ValueExists("TablePrefix"))
150   {
151     m_tablePrefix = jsonValue.GetString("TablePrefix");
152 
153     m_tablePrefixHasBeenSet = true;
154   }
155 
156   if(jsonValue.ValueExists("Schedule"))
157   {
158     m_schedule = jsonValue.GetObject("Schedule");
159 
160     m_scheduleHasBeenSet = true;
161   }
162 
163   if(jsonValue.ValueExists("CrawlElapsedTime"))
164   {
165     m_crawlElapsedTime = jsonValue.GetInt64("CrawlElapsedTime");
166 
167     m_crawlElapsedTimeHasBeenSet = true;
168   }
169 
170   if(jsonValue.ValueExists("CreationTime"))
171   {
172     m_creationTime = jsonValue.GetDouble("CreationTime");
173 
174     m_creationTimeHasBeenSet = true;
175   }
176 
177   if(jsonValue.ValueExists("LastUpdated"))
178   {
179     m_lastUpdated = jsonValue.GetDouble("LastUpdated");
180 
181     m_lastUpdatedHasBeenSet = true;
182   }
183 
184   if(jsonValue.ValueExists("LastCrawl"))
185   {
186     m_lastCrawl = jsonValue.GetObject("LastCrawl");
187 
188     m_lastCrawlHasBeenSet = true;
189   }
190 
191   if(jsonValue.ValueExists("Version"))
192   {
193     m_version = jsonValue.GetInt64("Version");
194 
195     m_versionHasBeenSet = true;
196   }
197 
198   if(jsonValue.ValueExists("Configuration"))
199   {
200     m_configuration = jsonValue.GetString("Configuration");
201 
202     m_configurationHasBeenSet = true;
203   }
204 
205   if(jsonValue.ValueExists("CrawlerSecurityConfiguration"))
206   {
207     m_crawlerSecurityConfiguration = jsonValue.GetString("CrawlerSecurityConfiguration");
208 
209     m_crawlerSecurityConfigurationHasBeenSet = true;
210   }
211 
212   return *this;
213 }
214 
Jsonize() const215 JsonValue Crawler::Jsonize() const
216 {
217   JsonValue payload;
218 
219   if(m_nameHasBeenSet)
220   {
221    payload.WithString("Name", m_name);
222 
223   }
224 
225   if(m_roleHasBeenSet)
226   {
227    payload.WithString("Role", m_role);
228 
229   }
230 
231   if(m_targetsHasBeenSet)
232   {
233    payload.WithObject("Targets", m_targets.Jsonize());
234 
235   }
236 
237   if(m_databaseNameHasBeenSet)
238   {
239    payload.WithString("DatabaseName", m_databaseName);
240 
241   }
242 
243   if(m_descriptionHasBeenSet)
244   {
245    payload.WithString("Description", m_description);
246 
247   }
248 
249   if(m_classifiersHasBeenSet)
250   {
251    Array<JsonValue> classifiersJsonList(m_classifiers.size());
252    for(unsigned classifiersIndex = 0; classifiersIndex < classifiersJsonList.GetLength(); ++classifiersIndex)
253    {
254      classifiersJsonList[classifiersIndex].AsString(m_classifiers[classifiersIndex]);
255    }
256    payload.WithArray("Classifiers", std::move(classifiersJsonList));
257 
258   }
259 
260   if(m_recrawlPolicyHasBeenSet)
261   {
262    payload.WithObject("RecrawlPolicy", m_recrawlPolicy.Jsonize());
263 
264   }
265 
266   if(m_schemaChangePolicyHasBeenSet)
267   {
268    payload.WithObject("SchemaChangePolicy", m_schemaChangePolicy.Jsonize());
269 
270   }
271 
272   if(m_lineageConfigurationHasBeenSet)
273   {
274    payload.WithObject("LineageConfiguration", m_lineageConfiguration.Jsonize());
275 
276   }
277 
278   if(m_stateHasBeenSet)
279   {
280    payload.WithString("State", CrawlerStateMapper::GetNameForCrawlerState(m_state));
281   }
282 
283   if(m_tablePrefixHasBeenSet)
284   {
285    payload.WithString("TablePrefix", m_tablePrefix);
286 
287   }
288 
289   if(m_scheduleHasBeenSet)
290   {
291    payload.WithObject("Schedule", m_schedule.Jsonize());
292 
293   }
294 
295   if(m_crawlElapsedTimeHasBeenSet)
296   {
297    payload.WithInt64("CrawlElapsedTime", m_crawlElapsedTime);
298 
299   }
300 
301   if(m_creationTimeHasBeenSet)
302   {
303    payload.WithDouble("CreationTime", m_creationTime.SecondsWithMSPrecision());
304   }
305 
306   if(m_lastUpdatedHasBeenSet)
307   {
308    payload.WithDouble("LastUpdated", m_lastUpdated.SecondsWithMSPrecision());
309   }
310 
311   if(m_lastCrawlHasBeenSet)
312   {
313    payload.WithObject("LastCrawl", m_lastCrawl.Jsonize());
314 
315   }
316 
317   if(m_versionHasBeenSet)
318   {
319    payload.WithInt64("Version", m_version);
320 
321   }
322 
323   if(m_configurationHasBeenSet)
324   {
325    payload.WithString("Configuration", m_configuration);
326 
327   }
328 
329   if(m_crawlerSecurityConfigurationHasBeenSet)
330   {
331    payload.WithString("CrawlerSecurityConfiguration", m_crawlerSecurityConfiguration);
332 
333   }
334 
335   return payload;
336 }
337 
338 } // namespace Model
339 } // namespace Glue
340 } // namespace Aws
341