1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/dms/model/Event.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 DatabaseMigrationService
17 {
18 namespace Model
19 {
20 
Event()21 Event::Event() :
22     m_sourceIdentifierHasBeenSet(false),
23     m_sourceType(SourceType::NOT_SET),
24     m_sourceTypeHasBeenSet(false),
25     m_messageHasBeenSet(false),
26     m_eventCategoriesHasBeenSet(false),
27     m_dateHasBeenSet(false)
28 {
29 }
30 
Event(JsonView jsonValue)31 Event::Event(JsonView jsonValue) :
32     m_sourceIdentifierHasBeenSet(false),
33     m_sourceType(SourceType::NOT_SET),
34     m_sourceTypeHasBeenSet(false),
35     m_messageHasBeenSet(false),
36     m_eventCategoriesHasBeenSet(false),
37     m_dateHasBeenSet(false)
38 {
39   *this = jsonValue;
40 }
41 
operator =(JsonView jsonValue)42 Event& Event::operator =(JsonView jsonValue)
43 {
44   if(jsonValue.ValueExists("SourceIdentifier"))
45   {
46     m_sourceIdentifier = jsonValue.GetString("SourceIdentifier");
47 
48     m_sourceIdentifierHasBeenSet = true;
49   }
50 
51   if(jsonValue.ValueExists("SourceType"))
52   {
53     m_sourceType = SourceTypeMapper::GetSourceTypeForName(jsonValue.GetString("SourceType"));
54 
55     m_sourceTypeHasBeenSet = true;
56   }
57 
58   if(jsonValue.ValueExists("Message"))
59   {
60     m_message = jsonValue.GetString("Message");
61 
62     m_messageHasBeenSet = true;
63   }
64 
65   if(jsonValue.ValueExists("EventCategories"))
66   {
67     Array<JsonView> eventCategoriesJsonList = jsonValue.GetArray("EventCategories");
68     for(unsigned eventCategoriesIndex = 0; eventCategoriesIndex < eventCategoriesJsonList.GetLength(); ++eventCategoriesIndex)
69     {
70       m_eventCategories.push_back(eventCategoriesJsonList[eventCategoriesIndex].AsString());
71     }
72     m_eventCategoriesHasBeenSet = true;
73   }
74 
75   if(jsonValue.ValueExists("Date"))
76   {
77     m_date = jsonValue.GetDouble("Date");
78 
79     m_dateHasBeenSet = true;
80   }
81 
82   return *this;
83 }
84 
Jsonize() const85 JsonValue Event::Jsonize() const
86 {
87   JsonValue payload;
88 
89   if(m_sourceIdentifierHasBeenSet)
90   {
91    payload.WithString("SourceIdentifier", m_sourceIdentifier);
92 
93   }
94 
95   if(m_sourceTypeHasBeenSet)
96   {
97    payload.WithString("SourceType", SourceTypeMapper::GetNameForSourceType(m_sourceType));
98   }
99 
100   if(m_messageHasBeenSet)
101   {
102    payload.WithString("Message", m_message);
103 
104   }
105 
106   if(m_eventCategoriesHasBeenSet)
107   {
108    Array<JsonValue> eventCategoriesJsonList(m_eventCategories.size());
109    for(unsigned eventCategoriesIndex = 0; eventCategoriesIndex < eventCategoriesJsonList.GetLength(); ++eventCategoriesIndex)
110    {
111      eventCategoriesJsonList[eventCategoriesIndex].AsString(m_eventCategories[eventCategoriesIndex]);
112    }
113    payload.WithArray("EventCategories", std::move(eventCategoriesJsonList));
114 
115   }
116 
117   if(m_dateHasBeenSet)
118   {
119    payload.WithDouble("Date", m_date.SecondsWithMSPrecision());
120   }
121 
122   return payload;
123 }
124 
125 } // namespace Model
126 } // namespace DatabaseMigrationService
127 } // namespace Aws
128