1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/memorydb/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 MemoryDB
17 {
18 namespace Model
19 {
20 
Event()21 Event::Event() :
22     m_sourceNameHasBeenSet(false),
23     m_sourceType(SourceType::NOT_SET),
24     m_sourceTypeHasBeenSet(false),
25     m_messageHasBeenSet(false),
26     m_dateHasBeenSet(false)
27 {
28 }
29 
Event(JsonView jsonValue)30 Event::Event(JsonView jsonValue) :
31     m_sourceNameHasBeenSet(false),
32     m_sourceType(SourceType::NOT_SET),
33     m_sourceTypeHasBeenSet(false),
34     m_messageHasBeenSet(false),
35     m_dateHasBeenSet(false)
36 {
37   *this = jsonValue;
38 }
39 
operator =(JsonView jsonValue)40 Event& Event::operator =(JsonView jsonValue)
41 {
42   if(jsonValue.ValueExists("SourceName"))
43   {
44     m_sourceName = jsonValue.GetString("SourceName");
45 
46     m_sourceNameHasBeenSet = true;
47   }
48 
49   if(jsonValue.ValueExists("SourceType"))
50   {
51     m_sourceType = SourceTypeMapper::GetSourceTypeForName(jsonValue.GetString("SourceType"));
52 
53     m_sourceTypeHasBeenSet = true;
54   }
55 
56   if(jsonValue.ValueExists("Message"))
57   {
58     m_message = jsonValue.GetString("Message");
59 
60     m_messageHasBeenSet = true;
61   }
62 
63   if(jsonValue.ValueExists("Date"))
64   {
65     m_date = jsonValue.GetDouble("Date");
66 
67     m_dateHasBeenSet = true;
68   }
69 
70   return *this;
71 }
72 
Jsonize() const73 JsonValue Event::Jsonize() const
74 {
75   JsonValue payload;
76 
77   if(m_sourceNameHasBeenSet)
78   {
79    payload.WithString("SourceName", m_sourceName);
80 
81   }
82 
83   if(m_sourceTypeHasBeenSet)
84   {
85    payload.WithString("SourceType", SourceTypeMapper::GetNameForSourceType(m_sourceType));
86   }
87 
88   if(m_messageHasBeenSet)
89   {
90    payload.WithString("Message", m_message);
91 
92   }
93 
94   if(m_dateHasBeenSet)
95   {
96    payload.WithDouble("Date", m_date.SecondsWithMSPrecision());
97   }
98 
99   return payload;
100 }
101 
102 } // namespace Model
103 } // namespace MemoryDB
104 } // namespace Aws
105