1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/securityhub/model/AwsS3BucketNotificationConfigurationDetail.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 SecurityHub
17 {
18 namespace Model
19 {
20 
AwsS3BucketNotificationConfigurationDetail()21 AwsS3BucketNotificationConfigurationDetail::AwsS3BucketNotificationConfigurationDetail() :
22     m_eventsHasBeenSet(false),
23     m_filterHasBeenSet(false),
24     m_destinationHasBeenSet(false),
25     m_typeHasBeenSet(false)
26 {
27 }
28 
AwsS3BucketNotificationConfigurationDetail(JsonView jsonValue)29 AwsS3BucketNotificationConfigurationDetail::AwsS3BucketNotificationConfigurationDetail(JsonView jsonValue) :
30     m_eventsHasBeenSet(false),
31     m_filterHasBeenSet(false),
32     m_destinationHasBeenSet(false),
33     m_typeHasBeenSet(false)
34 {
35   *this = jsonValue;
36 }
37 
operator =(JsonView jsonValue)38 AwsS3BucketNotificationConfigurationDetail& AwsS3BucketNotificationConfigurationDetail::operator =(JsonView jsonValue)
39 {
40   if(jsonValue.ValueExists("Events"))
41   {
42     Array<JsonView> eventsJsonList = jsonValue.GetArray("Events");
43     for(unsigned eventsIndex = 0; eventsIndex < eventsJsonList.GetLength(); ++eventsIndex)
44     {
45       m_events.push_back(eventsJsonList[eventsIndex].AsString());
46     }
47     m_eventsHasBeenSet = true;
48   }
49 
50   if(jsonValue.ValueExists("Filter"))
51   {
52     m_filter = jsonValue.GetObject("Filter");
53 
54     m_filterHasBeenSet = true;
55   }
56 
57   if(jsonValue.ValueExists("Destination"))
58   {
59     m_destination = jsonValue.GetString("Destination");
60 
61     m_destinationHasBeenSet = true;
62   }
63 
64   if(jsonValue.ValueExists("Type"))
65   {
66     m_type = jsonValue.GetString("Type");
67 
68     m_typeHasBeenSet = true;
69   }
70 
71   return *this;
72 }
73 
Jsonize() const74 JsonValue AwsS3BucketNotificationConfigurationDetail::Jsonize() const
75 {
76   JsonValue payload;
77 
78   if(m_eventsHasBeenSet)
79   {
80    Array<JsonValue> eventsJsonList(m_events.size());
81    for(unsigned eventsIndex = 0; eventsIndex < eventsJsonList.GetLength(); ++eventsIndex)
82    {
83      eventsJsonList[eventsIndex].AsString(m_events[eventsIndex]);
84    }
85    payload.WithArray("Events", std::move(eventsJsonList));
86 
87   }
88 
89   if(m_filterHasBeenSet)
90   {
91    payload.WithObject("Filter", m_filter.Jsonize());
92 
93   }
94 
95   if(m_destinationHasBeenSet)
96   {
97    payload.WithString("Destination", m_destination);
98 
99   }
100 
101   if(m_typeHasBeenSet)
102   {
103    payload.WithString("Type", m_type);
104 
105   }
106 
107   return payload;
108 }
109 
110 } // namespace Model
111 } // namespace SecurityHub
112 } // namespace Aws
113