-
Notifications
You must be signed in to change notification settings - Fork 475
/
DynamoDBEvent.cs
332 lines (304 loc) · 11.7 KB
/
DynamoDBEvent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
namespace Amazon.Lambda.DynamoDBEvents
{
using System;
using System.Collections.Generic;
using System.IO;
/// <summary>
/// AWS DynamoDB event
/// http://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html
/// http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update
/// </summary>
public class DynamoDBEvent
{
/// <summary>
/// List of DynamoDB event records.
/// </summary>
public IList<DynamodbStreamRecord> Records { get; set; }
/// <summary>
/// DynamoDB stream record
/// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html
/// </summary>
public class DynamodbStreamRecord
{
/// <summary>
/// The event source arn of DynamoDB.
/// </summary>
public string EventSourceArn { get; set; }
/// <summary>
/// The region in which the <c>GetRecords</c> request was received.
/// </summary>
public string AwsRegion { get; set; }
/// <summary>
/// The main body of the stream record, containing all of the DynamoDB-specific fields.
/// </summary>
public StreamRecord Dynamodb { get; set; }
/// <summary>
/// A globally unique identifier for the event that was recorded in this stream record.
/// </summary>
public string EventID { get; set; }
/// <summary>
/// <para>
/// The type of data modification that was performed on the DynamoDB table:
/// </para>
/// <ul>
/// <li>
/// <para>
/// <c>INSERT</c> - a new item was added to the table.
/// </para>
/// </li>
///
/// <li>
/// <para>
/// <c>MODIFY</c> - one or more of an existing item's attributes were modified.
/// </para>
/// </li>
///
/// <li>
/// <para>
/// <c>REMOVE</c> - the item was deleted from the table
/// </para>
/// </li>
/// </ul>
/// </summary>
public string EventName { get; set; }
/// <summary>
/// The Amazon Web Services service from which the stream record originated. For DynamoDB
/// Streams, this is <c>aws:dynamodb</c>.
/// </summary>
public string EventSource { get; set; }
/// <summary>
/// <para>
/// The version number of the stream record format. This number is updated whenever the
/// structure of <c>Record</c> is modified.
/// </para>
///
/// <para>
/// Client applications must not assume that <c>eventVersion</c> will remain at
/// a particular value, as this number is subject to change at any time. In general, <c>eventVersion</c>
/// will only increase as the low-level DynamoDB Streams API evolves.
/// </para>
/// </summary>
public string EventVersion { get; set; }
/// <summary>
/// <para>Items that are deleted by the Time to Live process after expiration have the following fields:</para>
/// <ul>
/// <li>
/// <para>Records[].userIdentity.type</para>
/// <para>"Service"</para>
/// </li>
/// <li>
/// <para>Records[].userIdentity.principalId</para>
/// <para>"dynamodb.amazonaws.com"</para>
/// </li>
/// </ul>
/// </summary>
public Identity UserIdentity { get; set; }
}
/// <summary>
/// A description of a single data modification that was performed on an item in a DynamoDB table.
/// </summary>
public class StreamRecord
{
/// <summary>
/// The approximate date and time when the stream record was created, in <a href="http://www.epochconverter.com/">UNIX
/// epoch time</a> format and rounded down to the closest second.
/// </summary>
public DateTime ApproximateCreationDateTime { get; set; }
/// <summary>
/// The primary key attribute(s) for the DynamoDB item that was modified.
/// </summary>
public Dictionary<string, AttributeValue> Keys { get; set; }
/// <summary>
/// The item in the DynamoDB table as it appeared after it was modified.
/// </summary>
public Dictionary<string, AttributeValue> NewImage { get; set; }
/// <summary>
/// The item in the DynamoDB table as it appeared before it was modified.
/// </summary>
public Dictionary<string, AttributeValue> OldImage { get; set; }
/// <summary>
/// The sequence number of the stream record.
/// </summary>
public string SequenceNumber { get; set; }
/// <summary>
/// The size of the stream record, in bytes.
/// </summary>
public long SizeBytes { get; set; }
/// <summary>
/// <para>
/// The type of data from the modified DynamoDB item that was captured in this stream record:
/// </para>
///
/// <ul>
/// <li>
/// <para>
/// <c>KEYS_ONLY</c> - only the key attributes of the modified item.
/// </para>
/// </li>
///
/// <li>
/// <para>
/// <c>NEW_IMAGE</c> - the entire item, as it appeared after it was modified.
/// </para>
/// </li>
///
/// <li>
/// <para>
/// <c>OLD_IMAGE</c> - the entire item, as it appeared before it was modified.
/// </para>
/// </li>
///
/// <li>
/// <para>
/// <c>NEW_AND_OLD_IMAGES</c> - both the new and the old item images of the item.
/// </para>
/// </li>
/// </ul>
/// </summary>
public string StreamViewType { get; set; }
}
/// <summary>
/// Contains details about the type of identity that made the request.
/// </summary>
public class Identity
{
/// <summary>
/// A unique identifier for the entity that made the call. For Time To Live, the principalId
/// is "dynamodb.amazonaws.com".
/// </summary>
public string PrincipalId { get; set; }
/// <summary>
/// The type of the identity. For Time To Live, the type is "Service".
/// </summary>
public string Type { get; set; }
}
/// <summary>
/// Represents the data for an attribute.
///
/// <para>
/// Each attribute value is described as a name-value pair. The name is the data type,
/// and the value is the data itself.
/// </para>
///
/// <para>
/// For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes">Data
/// Types</a> in the <i>Amazon DynamoDB Developer Guide</i>.
/// </para>
/// </summary>
public class AttributeValue
{
/// <summary>
/// <para>
/// An attribute of type Binary. For example:
/// </para>
///
/// <para>
/// <c>"B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"</c>
/// </para>
/// </summary>
public MemoryStream B { get; set; }
/// <summary>
/// <para>
/// An attribute of type Boolean. For example:
/// </para>
///
/// <para>
/// <c>"BOOL": true</c>
/// </para>
/// </summary>
public bool? BOOL { get; set; }
/// <summary>
/// <para>
/// An attribute of type Binary Set. For example:
/// </para>
///
/// <para>
/// <c>"BS": ["U3Vubnk=", "UmFpbnk=", "U25vd3k="]</c>
/// </para>
/// </summary>
public List<MemoryStream> BS { get; set; }
/// <summary>
/// <para>
/// An attribute of type List. For example:
/// </para>
///
/// <para>
/// <c>"L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"N": "3.14159"}]</c>
/// </para>
/// </summary>
public List<AttributeValue> L { get; set; }
/// <summary>
/// <para>
/// An attribute of type Map. For example:
/// </para>
///
/// <para>
/// <c>"M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}</c>
/// </para>
/// </summary>
public Dictionary<string, AttributeValue> M { get; set; }
/// <summary>
/// <para>
/// An attribute of type Number. For example:
/// </para>
///
/// <para>
/// <c>"N": "123.45"</c>
/// </para>
///
/// <para>
/// Numbers are sent across the network to DynamoDB as strings, to maximize compatibility
/// across languages and libraries. However, DynamoDB treats them as number type attributes
/// for mathematical operations.
/// </para>
/// </summary>
public string N { get; set; }
/// <summary>
/// <para>
/// An attribute of type Number Set. For example:
/// </para>
///
/// <para>
/// <c>"NS": ["42.2", "-19", "7.5", "3.14"]</c>
/// </para>
///
/// <para>
/// Numbers are sent across the network to DynamoDB as strings, to maximize compatibility
/// across languages and libraries. However, DynamoDB treats them as number type attributes
/// for mathematical operations.
/// </para>
/// </summary>
public List<string> NS { get; set; }
/// <summary>
/// <para>
/// An attribute of type Null. For example:
/// </para>
///
/// <para>
/// <c>"NULL": true</c>
/// </para>
/// </summary>
public bool? NULL { get; set; }
/// <summary>
/// <para>
/// An attribute of type String. For example:
/// </para>
///
/// <para>
/// <c>"S": "Hello"</c>
/// </para>
/// </summary>
public string S { get; set; }
/// <summary>
/// <para>
/// An attribute of type String Set. For example:
/// </para>
///
/// <para>
/// <c>"SS": ["Giraffe", "Hippo" ,"Zebra"]</c>
/// </para>
/// </summary>
public List<string> SS { get; set; }
}
}
}