1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/lambda/model/UpdateEventSourceMappingResult.h>
7 #include <aws/core/utils/json/JsonSerializer.h>
8 #include <aws/core/AmazonWebServiceResult.h>
9 #include <aws/core/utils/StringUtils.h>
10 #include <aws/core/utils/UnreferencedParam.h>
11 
12 #include <utility>
13 
14 using namespace Aws::Lambda::Model;
15 using namespace Aws::Utils::Json;
16 using namespace Aws::Utils;
17 using namespace Aws;
18 
UpdateEventSourceMappingResult()19 UpdateEventSourceMappingResult::UpdateEventSourceMappingResult() :
20     m_startingPosition(EventSourcePosition::NOT_SET),
21     m_batchSize(0),
22     m_maximumBatchingWindowInSeconds(0),
23     m_parallelizationFactor(0),
24     m_maximumRecordAgeInSeconds(0),
25     m_bisectBatchOnFunctionError(false),
26     m_maximumRetryAttempts(0),
27     m_tumblingWindowInSeconds(0)
28 {
29 }
30 
UpdateEventSourceMappingResult(const Aws::AmazonWebServiceResult<JsonValue> & result)31 UpdateEventSourceMappingResult::UpdateEventSourceMappingResult(const Aws::AmazonWebServiceResult<JsonValue>& result) :
32     m_startingPosition(EventSourcePosition::NOT_SET),
33     m_batchSize(0),
34     m_maximumBatchingWindowInSeconds(0),
35     m_parallelizationFactor(0),
36     m_maximumRecordAgeInSeconds(0),
37     m_bisectBatchOnFunctionError(false),
38     m_maximumRetryAttempts(0),
39     m_tumblingWindowInSeconds(0)
40 {
41   *this = result;
42 }
43 
operator =(const Aws::AmazonWebServiceResult<JsonValue> & result)44 UpdateEventSourceMappingResult& UpdateEventSourceMappingResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
45 {
46   JsonView jsonValue = result.GetPayload().View();
47   if(jsonValue.ValueExists("UUID"))
48   {
49     m_uUID = jsonValue.GetString("UUID");
50 
51   }
52 
53   if(jsonValue.ValueExists("StartingPosition"))
54   {
55     m_startingPosition = EventSourcePositionMapper::GetEventSourcePositionForName(jsonValue.GetString("StartingPosition"));
56 
57   }
58 
59   if(jsonValue.ValueExists("StartingPositionTimestamp"))
60   {
61     m_startingPositionTimestamp = jsonValue.GetDouble("StartingPositionTimestamp");
62 
63   }
64 
65   if(jsonValue.ValueExists("BatchSize"))
66   {
67     m_batchSize = jsonValue.GetInteger("BatchSize");
68 
69   }
70 
71   if(jsonValue.ValueExists("MaximumBatchingWindowInSeconds"))
72   {
73     m_maximumBatchingWindowInSeconds = jsonValue.GetInteger("MaximumBatchingWindowInSeconds");
74 
75   }
76 
77   if(jsonValue.ValueExists("ParallelizationFactor"))
78   {
79     m_parallelizationFactor = jsonValue.GetInteger("ParallelizationFactor");
80 
81   }
82 
83   if(jsonValue.ValueExists("EventSourceArn"))
84   {
85     m_eventSourceArn = jsonValue.GetString("EventSourceArn");
86 
87   }
88 
89   if(jsonValue.ValueExists("FunctionArn"))
90   {
91     m_functionArn = jsonValue.GetString("FunctionArn");
92 
93   }
94 
95   if(jsonValue.ValueExists("LastModified"))
96   {
97     m_lastModified = jsonValue.GetDouble("LastModified");
98 
99   }
100 
101   if(jsonValue.ValueExists("LastProcessingResult"))
102   {
103     m_lastProcessingResult = jsonValue.GetString("LastProcessingResult");
104 
105   }
106 
107   if(jsonValue.ValueExists("State"))
108   {
109     m_state = jsonValue.GetString("State");
110 
111   }
112 
113   if(jsonValue.ValueExists("StateTransitionReason"))
114   {
115     m_stateTransitionReason = jsonValue.GetString("StateTransitionReason");
116 
117   }
118 
119   if(jsonValue.ValueExists("DestinationConfig"))
120   {
121     m_destinationConfig = jsonValue.GetObject("DestinationConfig");
122 
123   }
124 
125   if(jsonValue.ValueExists("Topics"))
126   {
127     Array<JsonView> topicsJsonList = jsonValue.GetArray("Topics");
128     for(unsigned topicsIndex = 0; topicsIndex < topicsJsonList.GetLength(); ++topicsIndex)
129     {
130       m_topics.push_back(topicsJsonList[topicsIndex].AsString());
131     }
132   }
133 
134   if(jsonValue.ValueExists("Queues"))
135   {
136     Array<JsonView> queuesJsonList = jsonValue.GetArray("Queues");
137     for(unsigned queuesIndex = 0; queuesIndex < queuesJsonList.GetLength(); ++queuesIndex)
138     {
139       m_queues.push_back(queuesJsonList[queuesIndex].AsString());
140     }
141   }
142 
143   if(jsonValue.ValueExists("SourceAccessConfigurations"))
144   {
145     Array<JsonView> sourceAccessConfigurationsJsonList = jsonValue.GetArray("SourceAccessConfigurations");
146     for(unsigned sourceAccessConfigurationsIndex = 0; sourceAccessConfigurationsIndex < sourceAccessConfigurationsJsonList.GetLength(); ++sourceAccessConfigurationsIndex)
147     {
148       m_sourceAccessConfigurations.push_back(sourceAccessConfigurationsJsonList[sourceAccessConfigurationsIndex].AsObject());
149     }
150   }
151 
152   if(jsonValue.ValueExists("SelfManagedEventSource"))
153   {
154     m_selfManagedEventSource = jsonValue.GetObject("SelfManagedEventSource");
155 
156   }
157 
158   if(jsonValue.ValueExists("MaximumRecordAgeInSeconds"))
159   {
160     m_maximumRecordAgeInSeconds = jsonValue.GetInteger("MaximumRecordAgeInSeconds");
161 
162   }
163 
164   if(jsonValue.ValueExists("BisectBatchOnFunctionError"))
165   {
166     m_bisectBatchOnFunctionError = jsonValue.GetBool("BisectBatchOnFunctionError");
167 
168   }
169 
170   if(jsonValue.ValueExists("MaximumRetryAttempts"))
171   {
172     m_maximumRetryAttempts = jsonValue.GetInteger("MaximumRetryAttempts");
173 
174   }
175 
176   if(jsonValue.ValueExists("TumblingWindowInSeconds"))
177   {
178     m_tumblingWindowInSeconds = jsonValue.GetInteger("TumblingWindowInSeconds");
179 
180   }
181 
182   if(jsonValue.ValueExists("FunctionResponseTypes"))
183   {
184     Array<JsonView> functionResponseTypesJsonList = jsonValue.GetArray("FunctionResponseTypes");
185     for(unsigned functionResponseTypesIndex = 0; functionResponseTypesIndex < functionResponseTypesJsonList.GetLength(); ++functionResponseTypesIndex)
186     {
187       m_functionResponseTypes.push_back(FunctionResponseTypeMapper::GetFunctionResponseTypeForName(functionResponseTypesJsonList[functionResponseTypesIndex].AsString()));
188     }
189   }
190 
191 
192 
193   return *this;
194 }
195