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/Partition.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
Partition()21 Partition::Partition() :
22 m_valuesHasBeenSet(false),
23 m_databaseNameHasBeenSet(false),
24 m_tableNameHasBeenSet(false),
25 m_creationTimeHasBeenSet(false),
26 m_lastAccessTimeHasBeenSet(false),
27 m_storageDescriptorHasBeenSet(false),
28 m_parametersHasBeenSet(false),
29 m_lastAnalyzedTimeHasBeenSet(false),
30 m_catalogIdHasBeenSet(false)
31 {
32 }
33
Partition(JsonView jsonValue)34 Partition::Partition(JsonView jsonValue) :
35 m_valuesHasBeenSet(false),
36 m_databaseNameHasBeenSet(false),
37 m_tableNameHasBeenSet(false),
38 m_creationTimeHasBeenSet(false),
39 m_lastAccessTimeHasBeenSet(false),
40 m_storageDescriptorHasBeenSet(false),
41 m_parametersHasBeenSet(false),
42 m_lastAnalyzedTimeHasBeenSet(false),
43 m_catalogIdHasBeenSet(false)
44 {
45 *this = jsonValue;
46 }
47
operator =(JsonView jsonValue)48 Partition& Partition::operator =(JsonView jsonValue)
49 {
50 if(jsonValue.ValueExists("Values"))
51 {
52 Array<JsonView> valuesJsonList = jsonValue.GetArray("Values");
53 for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex)
54 {
55 m_values.push_back(valuesJsonList[valuesIndex].AsString());
56 }
57 m_valuesHasBeenSet = true;
58 }
59
60 if(jsonValue.ValueExists("DatabaseName"))
61 {
62 m_databaseName = jsonValue.GetString("DatabaseName");
63
64 m_databaseNameHasBeenSet = true;
65 }
66
67 if(jsonValue.ValueExists("TableName"))
68 {
69 m_tableName = jsonValue.GetString("TableName");
70
71 m_tableNameHasBeenSet = true;
72 }
73
74 if(jsonValue.ValueExists("CreationTime"))
75 {
76 m_creationTime = jsonValue.GetDouble("CreationTime");
77
78 m_creationTimeHasBeenSet = true;
79 }
80
81 if(jsonValue.ValueExists("LastAccessTime"))
82 {
83 m_lastAccessTime = jsonValue.GetDouble("LastAccessTime");
84
85 m_lastAccessTimeHasBeenSet = true;
86 }
87
88 if(jsonValue.ValueExists("StorageDescriptor"))
89 {
90 m_storageDescriptor = jsonValue.GetObject("StorageDescriptor");
91
92 m_storageDescriptorHasBeenSet = true;
93 }
94
95 if(jsonValue.ValueExists("Parameters"))
96 {
97 Aws::Map<Aws::String, JsonView> parametersJsonMap = jsonValue.GetObject("Parameters").GetAllObjects();
98 for(auto& parametersItem : parametersJsonMap)
99 {
100 m_parameters[parametersItem.first] = parametersItem.second.AsString();
101 }
102 m_parametersHasBeenSet = true;
103 }
104
105 if(jsonValue.ValueExists("LastAnalyzedTime"))
106 {
107 m_lastAnalyzedTime = jsonValue.GetDouble("LastAnalyzedTime");
108
109 m_lastAnalyzedTimeHasBeenSet = true;
110 }
111
112 if(jsonValue.ValueExists("CatalogId"))
113 {
114 m_catalogId = jsonValue.GetString("CatalogId");
115
116 m_catalogIdHasBeenSet = true;
117 }
118
119 return *this;
120 }
121
Jsonize() const122 JsonValue Partition::Jsonize() const
123 {
124 JsonValue payload;
125
126 if(m_valuesHasBeenSet)
127 {
128 Array<JsonValue> valuesJsonList(m_values.size());
129 for(unsigned valuesIndex = 0; valuesIndex < valuesJsonList.GetLength(); ++valuesIndex)
130 {
131 valuesJsonList[valuesIndex].AsString(m_values[valuesIndex]);
132 }
133 payload.WithArray("Values", std::move(valuesJsonList));
134
135 }
136
137 if(m_databaseNameHasBeenSet)
138 {
139 payload.WithString("DatabaseName", m_databaseName);
140
141 }
142
143 if(m_tableNameHasBeenSet)
144 {
145 payload.WithString("TableName", m_tableName);
146
147 }
148
149 if(m_creationTimeHasBeenSet)
150 {
151 payload.WithDouble("CreationTime", m_creationTime.SecondsWithMSPrecision());
152 }
153
154 if(m_lastAccessTimeHasBeenSet)
155 {
156 payload.WithDouble("LastAccessTime", m_lastAccessTime.SecondsWithMSPrecision());
157 }
158
159 if(m_storageDescriptorHasBeenSet)
160 {
161 payload.WithObject("StorageDescriptor", m_storageDescriptor.Jsonize());
162
163 }
164
165 if(m_parametersHasBeenSet)
166 {
167 JsonValue parametersJsonMap;
168 for(auto& parametersItem : m_parameters)
169 {
170 parametersJsonMap.WithString(parametersItem.first, parametersItem.second);
171 }
172 payload.WithObject("Parameters", std::move(parametersJsonMap));
173
174 }
175
176 if(m_lastAnalyzedTimeHasBeenSet)
177 {
178 payload.WithDouble("LastAnalyzedTime", m_lastAnalyzedTime.SecondsWithMSPrecision());
179 }
180
181 if(m_catalogIdHasBeenSet)
182 {
183 payload.WithString("CatalogId", m_catalogId);
184
185 }
186
187 return payload;
188 }
189
190 } // namespace Model
191 } // namespace Glue
192 } // namespace Aws
193