1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/quicksight/model/TemplateVersion.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 QuickSight
17 {
18 namespace Model
19 {
20 
TemplateVersion()21 TemplateVersion::TemplateVersion() :
22     m_createdTimeHasBeenSet(false),
23     m_errorsHasBeenSet(false),
24     m_versionNumber(0),
25     m_versionNumberHasBeenSet(false),
26     m_status(ResourceStatus::NOT_SET),
27     m_statusHasBeenSet(false),
28     m_dataSetConfigurationsHasBeenSet(false),
29     m_descriptionHasBeenSet(false),
30     m_sourceEntityArnHasBeenSet(false),
31     m_themeArnHasBeenSet(false),
32     m_sheetsHasBeenSet(false)
33 {
34 }
35 
TemplateVersion(JsonView jsonValue)36 TemplateVersion::TemplateVersion(JsonView jsonValue) :
37     m_createdTimeHasBeenSet(false),
38     m_errorsHasBeenSet(false),
39     m_versionNumber(0),
40     m_versionNumberHasBeenSet(false),
41     m_status(ResourceStatus::NOT_SET),
42     m_statusHasBeenSet(false),
43     m_dataSetConfigurationsHasBeenSet(false),
44     m_descriptionHasBeenSet(false),
45     m_sourceEntityArnHasBeenSet(false),
46     m_themeArnHasBeenSet(false),
47     m_sheetsHasBeenSet(false)
48 {
49   *this = jsonValue;
50 }
51 
operator =(JsonView jsonValue)52 TemplateVersion& TemplateVersion::operator =(JsonView jsonValue)
53 {
54   if(jsonValue.ValueExists("CreatedTime"))
55   {
56     m_createdTime = jsonValue.GetDouble("CreatedTime");
57 
58     m_createdTimeHasBeenSet = true;
59   }
60 
61   if(jsonValue.ValueExists("Errors"))
62   {
63     Array<JsonView> errorsJsonList = jsonValue.GetArray("Errors");
64     for(unsigned errorsIndex = 0; errorsIndex < errorsJsonList.GetLength(); ++errorsIndex)
65     {
66       m_errors.push_back(errorsJsonList[errorsIndex].AsObject());
67     }
68     m_errorsHasBeenSet = true;
69   }
70 
71   if(jsonValue.ValueExists("VersionNumber"))
72   {
73     m_versionNumber = jsonValue.GetInt64("VersionNumber");
74 
75     m_versionNumberHasBeenSet = true;
76   }
77 
78   if(jsonValue.ValueExists("Status"))
79   {
80     m_status = ResourceStatusMapper::GetResourceStatusForName(jsonValue.GetString("Status"));
81 
82     m_statusHasBeenSet = true;
83   }
84 
85   if(jsonValue.ValueExists("DataSetConfigurations"))
86   {
87     Array<JsonView> dataSetConfigurationsJsonList = jsonValue.GetArray("DataSetConfigurations");
88     for(unsigned dataSetConfigurationsIndex = 0; dataSetConfigurationsIndex < dataSetConfigurationsJsonList.GetLength(); ++dataSetConfigurationsIndex)
89     {
90       m_dataSetConfigurations.push_back(dataSetConfigurationsJsonList[dataSetConfigurationsIndex].AsObject());
91     }
92     m_dataSetConfigurationsHasBeenSet = true;
93   }
94 
95   if(jsonValue.ValueExists("Description"))
96   {
97     m_description = jsonValue.GetString("Description");
98 
99     m_descriptionHasBeenSet = true;
100   }
101 
102   if(jsonValue.ValueExists("SourceEntityArn"))
103   {
104     m_sourceEntityArn = jsonValue.GetString("SourceEntityArn");
105 
106     m_sourceEntityArnHasBeenSet = true;
107   }
108 
109   if(jsonValue.ValueExists("ThemeArn"))
110   {
111     m_themeArn = jsonValue.GetString("ThemeArn");
112 
113     m_themeArnHasBeenSet = true;
114   }
115 
116   if(jsonValue.ValueExists("Sheets"))
117   {
118     Array<JsonView> sheetsJsonList = jsonValue.GetArray("Sheets");
119     for(unsigned sheetsIndex = 0; sheetsIndex < sheetsJsonList.GetLength(); ++sheetsIndex)
120     {
121       m_sheets.push_back(sheetsJsonList[sheetsIndex].AsObject());
122     }
123     m_sheetsHasBeenSet = true;
124   }
125 
126   return *this;
127 }
128 
Jsonize() const129 JsonValue TemplateVersion::Jsonize() const
130 {
131   JsonValue payload;
132 
133   if(m_createdTimeHasBeenSet)
134   {
135    payload.WithDouble("CreatedTime", m_createdTime.SecondsWithMSPrecision());
136   }
137 
138   if(m_errorsHasBeenSet)
139   {
140    Array<JsonValue> errorsJsonList(m_errors.size());
141    for(unsigned errorsIndex = 0; errorsIndex < errorsJsonList.GetLength(); ++errorsIndex)
142    {
143      errorsJsonList[errorsIndex].AsObject(m_errors[errorsIndex].Jsonize());
144    }
145    payload.WithArray("Errors", std::move(errorsJsonList));
146 
147   }
148 
149   if(m_versionNumberHasBeenSet)
150   {
151    payload.WithInt64("VersionNumber", m_versionNumber);
152 
153   }
154 
155   if(m_statusHasBeenSet)
156   {
157    payload.WithString("Status", ResourceStatusMapper::GetNameForResourceStatus(m_status));
158   }
159 
160   if(m_dataSetConfigurationsHasBeenSet)
161   {
162    Array<JsonValue> dataSetConfigurationsJsonList(m_dataSetConfigurations.size());
163    for(unsigned dataSetConfigurationsIndex = 0; dataSetConfigurationsIndex < dataSetConfigurationsJsonList.GetLength(); ++dataSetConfigurationsIndex)
164    {
165      dataSetConfigurationsJsonList[dataSetConfigurationsIndex].AsObject(m_dataSetConfigurations[dataSetConfigurationsIndex].Jsonize());
166    }
167    payload.WithArray("DataSetConfigurations", std::move(dataSetConfigurationsJsonList));
168 
169   }
170 
171   if(m_descriptionHasBeenSet)
172   {
173    payload.WithString("Description", m_description);
174 
175   }
176 
177   if(m_sourceEntityArnHasBeenSet)
178   {
179    payload.WithString("SourceEntityArn", m_sourceEntityArn);
180 
181   }
182 
183   if(m_themeArnHasBeenSet)
184   {
185    payload.WithString("ThemeArn", m_themeArn);
186 
187   }
188 
189   if(m_sheetsHasBeenSet)
190   {
191    Array<JsonValue> sheetsJsonList(m_sheets.size());
192    for(unsigned sheetsIndex = 0; sheetsIndex < sheetsJsonList.GetLength(); ++sheetsIndex)
193    {
194      sheetsJsonList[sheetsIndex].AsObject(m_sheets[sheetsIndex].Jsonize());
195    }
196    payload.WithArray("Sheets", std::move(sheetsJsonList));
197 
198   }
199 
200   return payload;
201 }
202 
203 } // namespace Model
204 } // namespace QuickSight
205 } // namespace Aws
206