1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/lookoutmetrics/model/AlertSummary.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 LookoutMetrics
17 {
18 namespace Model
19 {
20 
AlertSummary()21 AlertSummary::AlertSummary() :
22     m_alertArnHasBeenSet(false),
23     m_anomalyDetectorArnHasBeenSet(false),
24     m_alertNameHasBeenSet(false),
25     m_alertSensitivityThreshold(0),
26     m_alertSensitivityThresholdHasBeenSet(false),
27     m_alertType(AlertType::NOT_SET),
28     m_alertTypeHasBeenSet(false),
29     m_alertStatus(AlertStatus::NOT_SET),
30     m_alertStatusHasBeenSet(false),
31     m_lastModificationTimeHasBeenSet(false),
32     m_creationTimeHasBeenSet(false),
33     m_tagsHasBeenSet(false)
34 {
35 }
36 
AlertSummary(JsonView jsonValue)37 AlertSummary::AlertSummary(JsonView jsonValue) :
38     m_alertArnHasBeenSet(false),
39     m_anomalyDetectorArnHasBeenSet(false),
40     m_alertNameHasBeenSet(false),
41     m_alertSensitivityThreshold(0),
42     m_alertSensitivityThresholdHasBeenSet(false),
43     m_alertType(AlertType::NOT_SET),
44     m_alertTypeHasBeenSet(false),
45     m_alertStatus(AlertStatus::NOT_SET),
46     m_alertStatusHasBeenSet(false),
47     m_lastModificationTimeHasBeenSet(false),
48     m_creationTimeHasBeenSet(false),
49     m_tagsHasBeenSet(false)
50 {
51   *this = jsonValue;
52 }
53 
operator =(JsonView jsonValue)54 AlertSummary& AlertSummary::operator =(JsonView jsonValue)
55 {
56   if(jsonValue.ValueExists("AlertArn"))
57   {
58     m_alertArn = jsonValue.GetString("AlertArn");
59 
60     m_alertArnHasBeenSet = true;
61   }
62 
63   if(jsonValue.ValueExists("AnomalyDetectorArn"))
64   {
65     m_anomalyDetectorArn = jsonValue.GetString("AnomalyDetectorArn");
66 
67     m_anomalyDetectorArnHasBeenSet = true;
68   }
69 
70   if(jsonValue.ValueExists("AlertName"))
71   {
72     m_alertName = jsonValue.GetString("AlertName");
73 
74     m_alertNameHasBeenSet = true;
75   }
76 
77   if(jsonValue.ValueExists("AlertSensitivityThreshold"))
78   {
79     m_alertSensitivityThreshold = jsonValue.GetInteger("AlertSensitivityThreshold");
80 
81     m_alertSensitivityThresholdHasBeenSet = true;
82   }
83 
84   if(jsonValue.ValueExists("AlertType"))
85   {
86     m_alertType = AlertTypeMapper::GetAlertTypeForName(jsonValue.GetString("AlertType"));
87 
88     m_alertTypeHasBeenSet = true;
89   }
90 
91   if(jsonValue.ValueExists("AlertStatus"))
92   {
93     m_alertStatus = AlertStatusMapper::GetAlertStatusForName(jsonValue.GetString("AlertStatus"));
94 
95     m_alertStatusHasBeenSet = true;
96   }
97 
98   if(jsonValue.ValueExists("LastModificationTime"))
99   {
100     m_lastModificationTime = jsonValue.GetDouble("LastModificationTime");
101 
102     m_lastModificationTimeHasBeenSet = true;
103   }
104 
105   if(jsonValue.ValueExists("CreationTime"))
106   {
107     m_creationTime = jsonValue.GetDouble("CreationTime");
108 
109     m_creationTimeHasBeenSet = true;
110   }
111 
112   if(jsonValue.ValueExists("Tags"))
113   {
114     Aws::Map<Aws::String, JsonView> tagsJsonMap = jsonValue.GetObject("Tags").GetAllObjects();
115     for(auto& tagsItem : tagsJsonMap)
116     {
117       m_tags[tagsItem.first] = tagsItem.second.AsString();
118     }
119     m_tagsHasBeenSet = true;
120   }
121 
122   return *this;
123 }
124 
Jsonize() const125 JsonValue AlertSummary::Jsonize() const
126 {
127   JsonValue payload;
128 
129   if(m_alertArnHasBeenSet)
130   {
131    payload.WithString("AlertArn", m_alertArn);
132 
133   }
134 
135   if(m_anomalyDetectorArnHasBeenSet)
136   {
137    payload.WithString("AnomalyDetectorArn", m_anomalyDetectorArn);
138 
139   }
140 
141   if(m_alertNameHasBeenSet)
142   {
143    payload.WithString("AlertName", m_alertName);
144 
145   }
146 
147   if(m_alertSensitivityThresholdHasBeenSet)
148   {
149    payload.WithInteger("AlertSensitivityThreshold", m_alertSensitivityThreshold);
150 
151   }
152 
153   if(m_alertTypeHasBeenSet)
154   {
155    payload.WithString("AlertType", AlertTypeMapper::GetNameForAlertType(m_alertType));
156   }
157 
158   if(m_alertStatusHasBeenSet)
159   {
160    payload.WithString("AlertStatus", AlertStatusMapper::GetNameForAlertStatus(m_alertStatus));
161   }
162 
163   if(m_lastModificationTimeHasBeenSet)
164   {
165    payload.WithDouble("LastModificationTime", m_lastModificationTime.SecondsWithMSPrecision());
166   }
167 
168   if(m_creationTimeHasBeenSet)
169   {
170    payload.WithDouble("CreationTime", m_creationTime.SecondsWithMSPrecision());
171   }
172 
173   if(m_tagsHasBeenSet)
174   {
175    JsonValue tagsJsonMap;
176    for(auto& tagsItem : m_tags)
177    {
178      tagsJsonMap.WithString(tagsItem.first, tagsItem.second);
179    }
180    payload.WithObject("Tags", std::move(tagsJsonMap));
181 
182   }
183 
184   return payload;
185 }
186 
187 } // namespace Model
188 } // namespace LookoutMetrics
189 } // namespace Aws
190