1
|
|
|
package dynamodb |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"fmt" |
5
|
|
|
"strconv" |
6
|
|
|
"time" |
7
|
|
|
|
8
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/dynamodb" |
9
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
10
|
|
|
) |
11
|
|
|
|
12
|
|
|
type ArchivalSummary struct { |
|
|
|
|
13
|
|
|
ArchivalBackupARN string |
14
|
|
|
ArchivalDateTime time.Time |
15
|
|
|
ArchivalReason string |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
func newArchivalSummary(o *SDK.ArchivalSummary) ArchivalSummary { |
19
|
|
|
result := ArchivalSummary{} |
20
|
|
|
if o == nil { |
21
|
|
|
return result |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
if o.ArchivalBackupArn != nil { |
25
|
|
|
result.ArchivalBackupARN = *o.ArchivalBackupArn |
26
|
|
|
} |
27
|
|
|
if o.ArchivalDateTime != nil { |
28
|
|
|
result.ArchivalDateTime = *o.ArchivalDateTime |
29
|
|
|
} |
30
|
|
|
if o.ArchivalReason != nil { |
31
|
|
|
result.ArchivalReason = *o.ArchivalReason |
32
|
|
|
} |
33
|
|
|
return result |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
type AttributeDefinition struct { |
|
|
|
|
37
|
|
|
AttributeName string |
38
|
|
|
AttributeType ScalarAttributeType |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
func newAttributeDefinitions(list []SDK.AttributeDefinition) []AttributeDefinition { |
42
|
|
|
if len(list) == 0 { |
43
|
|
|
return nil |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
results := make([]AttributeDefinition, len(list)) |
47
|
|
|
for i, v := range list { |
48
|
|
|
results[i] = newAttributeDefinition(v) |
49
|
|
|
} |
50
|
|
|
return results |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
func newAttributeDefinition(o SDK.AttributeDefinition) AttributeDefinition { |
54
|
|
|
result := AttributeDefinition{} |
55
|
|
|
|
56
|
|
|
if o.AttributeName != nil { |
57
|
|
|
result.AttributeName = *o.AttributeName |
58
|
|
|
} |
59
|
|
|
result.AttributeType = ScalarAttributeType(o.AttributeType) |
60
|
|
|
return result |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
func (r AttributeDefinition) ToSDK() SDK.AttributeDefinition { |
|
|
|
|
64
|
|
|
o := SDK.AttributeDefinition{} |
65
|
|
|
|
66
|
|
|
if r.AttributeName != "" { |
67
|
|
|
o.AttributeName = pointers.String(r.AttributeName) |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
o.AttributeType = SDK.ScalarAttributeType(r.AttributeType) |
71
|
|
|
return o |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
type AttributeValue struct { |
|
|
|
|
75
|
|
|
Binary []byte |
76
|
|
|
BinarySet [][]byte |
77
|
|
|
List []AttributeValue |
78
|
|
|
Map map[string]AttributeValue |
79
|
|
|
Number string |
80
|
|
|
NumberInt int64 |
81
|
|
|
NumberFloat float64 |
82
|
|
|
NumberSet []string |
83
|
|
|
NumberSetInt []int64 |
84
|
|
|
NumberSetFloat []float64 |
85
|
|
|
Null bool |
86
|
|
|
String string |
87
|
|
|
StringSet []string |
88
|
|
|
|
89
|
|
|
Bool bool |
90
|
|
|
HasBool bool |
91
|
|
|
HasNumber bool |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
// MustNewAttributeValue creates AttributeValue from given value, or emits panic. |
95
|
|
|
func MustNewAttributeValue(v interface{}) AttributeValue { |
96
|
|
|
result, err := NewAttributeValue(v) |
97
|
|
|
if err != nil { |
98
|
|
|
panic(err) |
99
|
|
|
} |
100
|
|
|
return result |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
// NewAttributeValue creates AttributeValue from given value. |
104
|
|
|
func NewAttributeValue(v interface{}) (AttributeValue, error) { |
105
|
|
|
result := AttributeValue{} |
106
|
|
|
|
107
|
|
|
switch vv := v.(type) { |
108
|
|
|
case []byte: |
109
|
|
|
result.Binary = vv |
110
|
|
|
case [][]byte: |
111
|
|
|
result.BinarySet = vv |
112
|
|
|
case string: |
113
|
|
|
result.String = vv |
114
|
|
|
case []string: |
115
|
|
|
result.StringSet = vv |
116
|
|
|
case bool: |
117
|
|
|
result.Bool = vv |
118
|
|
|
result.HasBool = true |
119
|
|
|
case int: |
120
|
|
|
result.NumberInt = int64(vv) |
121
|
|
|
result.HasNumber = true |
122
|
|
|
case int32: |
123
|
|
|
result.NumberInt = int64(vv) |
124
|
|
|
result.HasNumber = true |
125
|
|
|
case int64: |
126
|
|
|
result.NumberInt = vv |
127
|
|
|
result.HasNumber = true |
128
|
|
|
case float32: |
129
|
|
|
result.NumberFloat = float64(vv) |
130
|
|
|
result.HasNumber = true |
131
|
|
|
case float64: |
132
|
|
|
result.NumberFloat = vv |
133
|
|
|
result.HasNumber = true |
134
|
|
|
case []int64: |
135
|
|
|
result.NumberSetInt = vv |
136
|
|
|
case []float64: |
137
|
|
|
result.NumberSetFloat = vv |
138
|
|
|
case map[string]interface{}: |
139
|
|
|
m := make(map[string]AttributeValue, len(vv)) |
140
|
|
|
for k, v := range vv { |
141
|
|
|
m[k] = MustNewAttributeValue(v) |
142
|
|
|
} |
143
|
|
|
result.Map = m |
144
|
|
|
default: |
145
|
|
|
if v == nil { |
146
|
|
|
result.Null = true |
147
|
|
|
return result, nil |
148
|
|
|
} |
149
|
|
|
return result, fmt.Errorf("[MustNewAttributeValue] cannot parse the given value type: [%t]", v) |
150
|
|
|
} |
151
|
|
|
return result, nil |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
func newAttributeValue(o SDK.AttributeValue) AttributeValue { |
155
|
|
|
result := AttributeValue{} |
156
|
|
|
|
157
|
|
|
switch { |
158
|
|
|
case len(o.B) != 0: |
159
|
|
|
result.Binary = o.B |
160
|
|
|
case len(o.BS) != 0: |
161
|
|
|
result.BinarySet = o.BS |
162
|
|
|
case len(o.L) != 0: |
163
|
|
|
result.List = newAttributeValueList(o.L) |
164
|
|
|
case len(o.M) != 0: |
165
|
|
|
result.Map = newAttributeValueMap(o.M) |
166
|
|
|
case o.N != nil: |
167
|
|
|
result.Number = *o.N |
168
|
|
|
result.HasNumber = true |
169
|
|
|
case len(o.NS) != 0: |
170
|
|
|
result.NumberSet = o.NS |
171
|
|
|
case o.NULL != nil: |
172
|
|
|
result.Null = *o.NULL |
173
|
|
|
case o.S != nil: |
174
|
|
|
result.String = *o.S |
175
|
|
|
case len(o.SS) != 0: |
176
|
|
|
result.StringSet = o.SS |
177
|
|
|
case o.BOOL != nil: |
178
|
|
|
result.Bool = *o.BOOL |
179
|
|
|
result.HasBool = true |
180
|
|
|
} |
181
|
|
|
return result |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
func newAttributeValueList(list []SDK.AttributeValue) []AttributeValue { |
185
|
|
|
if len(list) == 0 { |
186
|
|
|
return nil |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
results := make([]AttributeValue, len(list)) |
190
|
|
|
for i, v := range list { |
191
|
|
|
results[i] = newAttributeValue(v) |
192
|
|
|
} |
193
|
|
|
return results |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
func newAttributeValueMap(o map[string]SDK.AttributeValue) map[string]AttributeValue { |
197
|
|
|
if len(o) == 0 { |
198
|
|
|
return nil |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
m := make(map[string]AttributeValue, len(o)) |
202
|
|
|
for key, val := range o { |
203
|
|
|
m[key] = newAttributeValue(val) |
204
|
|
|
} |
205
|
|
|
return m |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
func (r AttributeValue) ToSDK() SDK.AttributeValue { |
|
|
|
|
209
|
|
|
o := SDK.AttributeValue{} |
210
|
|
|
|
211
|
|
|
switch { |
212
|
|
|
case len(r.Binary) != 0: |
213
|
|
|
o.B = r.Binary |
214
|
|
|
case len(r.BinarySet) != 0: |
215
|
|
|
o.BS = r.BinarySet |
216
|
|
|
case len(r.List) != 0: |
217
|
|
|
list := make([]SDK.AttributeValue, len(r.List)) |
218
|
|
|
for i, v := range r.List { |
219
|
|
|
list[i] = v.ToSDK() |
220
|
|
|
} |
221
|
|
|
o.L = list |
222
|
|
|
case len(r.Map) != 0: |
223
|
|
|
m := make(map[string]SDK.AttributeValue, len(r.Map)) |
224
|
|
|
for key, val := range r.Map { |
225
|
|
|
m[key] = val.ToSDK() |
226
|
|
|
} |
227
|
|
|
o.M = m |
228
|
|
|
case r.Number != "": |
229
|
|
|
o.N = pointers.String(r.Number) |
230
|
|
|
case r.NumberInt != 0: |
231
|
|
|
o.N = pointers.String(strconv.FormatInt(r.NumberInt, 10)) |
232
|
|
|
case r.NumberFloat != 0: |
233
|
|
|
o.N = pointers.String(strconv.FormatFloat(r.NumberFloat, 'f', -1, 64)) |
234
|
|
|
case r.HasNumber: |
235
|
|
|
o.N = pointers.String("0") |
236
|
|
|
case len(r.NumberSet) != 0: |
237
|
|
|
o.NS = r.NumberSet |
238
|
|
|
case len(r.NumberSetInt) != 0: |
239
|
|
|
list := make([]string, len(r.NumberSetInt)) |
240
|
|
|
for i, v := range r.NumberSetInt { |
241
|
|
|
list[i] = strconv.FormatInt(v, 10) |
242
|
|
|
} |
243
|
|
|
o.NS = list |
244
|
|
|
case len(r.NumberSetFloat) != 0: |
245
|
|
|
list := make([]string, len(r.NumberSetFloat)) |
246
|
|
|
for i, v := range r.NumberSetFloat { |
247
|
|
|
list[i] = strconv.FormatFloat(v, 'f', -1, 64) |
248
|
|
|
} |
249
|
|
|
o.NS = list |
250
|
|
|
case r.String != "": |
251
|
|
|
o.S = pointers.String(r.String) |
252
|
|
|
case len(r.StringSet) != 0: |
253
|
|
|
o.SS = r.StringSet |
254
|
|
|
case r.HasBool, |
255
|
|
|
r.Bool: |
256
|
|
|
o.BOOL = pointers.Bool(r.Bool) |
257
|
|
|
case r.Null: |
258
|
|
|
o.NULL = pointers.Bool(r.Null) |
259
|
|
|
} |
260
|
|
|
return o |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
func (r AttributeValue) GetValue() interface{} { |
|
|
|
|
264
|
|
|
switch { |
265
|
|
|
case len(r.Binary) != 0: |
266
|
|
|
return r.Binary |
267
|
|
|
case len(r.BinarySet) != 0: |
268
|
|
|
return r.BinarySet |
269
|
|
|
case len(r.List) != 0: |
270
|
|
|
list := make([]interface{}, len(r.List)) |
271
|
|
|
for i, v := range r.List { |
272
|
|
|
list[i] = v.GetValue() |
273
|
|
|
} |
274
|
|
|
return list |
275
|
|
|
case len(r.Map) != 0: |
276
|
|
|
m := make(map[string]interface{}, len(r.Map)) |
277
|
|
|
for key, val := range r.Map { |
278
|
|
|
m[key] = val.GetValue() |
279
|
|
|
} |
280
|
|
|
return m |
281
|
|
|
case r.Number != "": |
282
|
|
|
v, _ := strconv.Atoi(r.Number) |
283
|
|
|
return v |
284
|
|
|
case r.NumberInt != 0: |
285
|
|
|
return r.NumberInt |
286
|
|
|
case r.NumberFloat != 0: |
287
|
|
|
return r.NumberFloat |
288
|
|
|
case r.HasNumber: |
289
|
|
|
return 0 |
290
|
|
|
case len(r.NumberSet) != 0: |
291
|
|
|
list := make([]int, len(r.NumberSet)) |
292
|
|
|
for i, v := range r.NumberSet { |
293
|
|
|
list[i], _ = strconv.Atoi(v) |
294
|
|
|
} |
295
|
|
|
return list |
296
|
|
|
case len(r.NumberSetInt) != 0: |
297
|
|
|
return r.NumberSetInt |
298
|
|
|
case len(r.NumberSetFloat) != 0: |
299
|
|
|
return r.NumberSetFloat |
300
|
|
|
case r.String != "": |
301
|
|
|
return r.String |
302
|
|
|
case len(r.StringSet) != 0: |
303
|
|
|
return r.StringSet |
304
|
|
|
case r.HasBool, |
305
|
|
|
r.Bool: |
306
|
|
|
return r.Bool |
307
|
|
|
case r.Null: |
308
|
|
|
return newArchivalSummary |
309
|
|
|
} |
310
|
|
|
return nil |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
func (r AttributeValue) hasValue() bool { |
314
|
|
|
switch { |
315
|
|
|
case r.HasNumber, |
316
|
|
|
r.HasBool, |
317
|
|
|
r.Bool, |
318
|
|
|
r.Null, |
319
|
|
|
r.Number != "", |
320
|
|
|
r.NumberInt != 0, |
321
|
|
|
r.NumberFloat != 0, |
322
|
|
|
r.String != "", |
323
|
|
|
len(r.Binary) != 0, |
324
|
|
|
len(r.BinarySet) != 0, |
325
|
|
|
len(r.List) != 0, |
326
|
|
|
len(r.Map) != 0, |
327
|
|
|
len(r.NumberSet) != 0, |
328
|
|
|
len(r.NumberSetInt) != 0, |
329
|
|
|
len(r.NumberSetFloat) != 0, |
330
|
|
|
len(r.StringSet) != 0: |
331
|
|
|
return true |
332
|
|
|
} |
333
|
|
|
return false |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
type BillingModeSummary struct { |
|
|
|
|
337
|
|
|
BillingMode BillingMode |
338
|
|
|
LastUpdateToPayPerRequestDateTime time.Time |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
func newBillingModeSummary(o *SDK.BillingModeSummary) BillingModeSummary { |
342
|
|
|
result := BillingModeSummary{} |
343
|
|
|
if o == nil { |
344
|
|
|
return result |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
if o.LastUpdateToPayPerRequestDateTime != nil { |
348
|
|
|
result.LastUpdateToPayPerRequestDateTime = *o.LastUpdateToPayPerRequestDateTime |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
result.BillingMode = BillingMode(o.BillingMode) |
352
|
|
|
return result |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
type Capacity struct { |
|
|
|
|
356
|
|
|
CapacityUnits float64 |
357
|
|
|
ReadCapacityUnits float64 |
358
|
|
|
WriteCapacityUnits float64 |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
func newCapacity(o *SDK.Capacity) Capacity { |
362
|
|
|
result := Capacity{} |
363
|
|
|
if o == nil { |
364
|
|
|
return result |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
if o.CapacityUnits != nil { |
368
|
|
|
result.CapacityUnits = *o.CapacityUnits |
369
|
|
|
} |
370
|
|
|
if o.ReadCapacityUnits != nil { |
371
|
|
|
result.ReadCapacityUnits = *o.ReadCapacityUnits |
372
|
|
|
} |
373
|
|
|
if o.WriteCapacityUnits != nil { |
374
|
|
|
result.WriteCapacityUnits = *o.WriteCapacityUnits |
375
|
|
|
} |
376
|
|
|
return result |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
func newCapacityMap(m map[string]SDK.Capacity) map[string]Capacity { |
380
|
|
|
if m == nil { |
381
|
|
|
return nil |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
result := make(map[string]Capacity, len(m)) |
385
|
|
|
for key, val := range m { |
386
|
|
|
val := val |
387
|
|
|
result[key] = newCapacity(&val) |
388
|
|
|
} |
389
|
|
|
return result |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
type Condition struct { |
|
|
|
|
393
|
|
|
ComparisonOperator ComparisonOperator |
394
|
|
|
|
395
|
|
|
// optional |
396
|
|
|
AttributeValueList []AttributeValue |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
func (r Condition) ToSDK() SDK.Condition { |
|
|
|
|
400
|
|
|
o := SDK.Condition{} |
401
|
|
|
|
402
|
|
|
o.ComparisonOperator = SDK.ComparisonOperator(r.ComparisonOperator) |
403
|
|
|
|
404
|
|
|
if len(r.AttributeValueList) != 0 { |
405
|
|
|
list := make([]SDK.AttributeValue, len(r.AttributeValueList)) |
406
|
|
|
for i, v := range r.AttributeValueList { |
407
|
|
|
list[i] = v.ToSDK() |
408
|
|
|
} |
409
|
|
|
o.AttributeValueList = list |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
return o |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
type ConsumedCapacity struct { |
|
|
|
|
416
|
|
|
CapacityUnits float64 |
417
|
|
|
GlobalSecondaryIndexes map[string]Capacity |
418
|
|
|
LocalSecondaryIndexes map[string]Capacity |
419
|
|
|
ReadCapacityUnits float64 |
420
|
|
|
Table Capacity |
421
|
|
|
TableName string |
422
|
|
|
WriteCapacityUnits float64 |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
func newConsumedCapacities(list []SDK.ConsumedCapacity) []ConsumedCapacity { |
426
|
|
|
if len(list) == 0 { |
427
|
|
|
return nil |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
result := make([]ConsumedCapacity, len(list)) |
431
|
|
|
for i, v := range list { |
432
|
|
|
result[i] = newConsumedCapacity(v) |
433
|
|
|
} |
434
|
|
|
return result |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
func newConsumedCapacity(o SDK.ConsumedCapacity) ConsumedCapacity { |
438
|
|
|
result := ConsumedCapacity{} |
439
|
|
|
|
440
|
|
|
if o.CapacityUnits != nil { |
441
|
|
|
result.CapacityUnits = *o.CapacityUnits |
442
|
|
|
} |
443
|
|
|
if o.ReadCapacityUnits != nil { |
444
|
|
|
result.ReadCapacityUnits = *o.ReadCapacityUnits |
445
|
|
|
} |
446
|
|
|
if o.TableName != nil { |
447
|
|
|
result.TableName = *o.TableName |
448
|
|
|
} |
449
|
|
|
if o.WriteCapacityUnits != nil { |
450
|
|
|
result.WriteCapacityUnits = *o.WriteCapacityUnits |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
result.GlobalSecondaryIndexes = newCapacityMap(o.GlobalSecondaryIndexes) |
454
|
|
|
result.LocalSecondaryIndexes = newCapacityMap(o.LocalSecondaryIndexes) |
455
|
|
|
result.Table = newCapacity(o.Table) |
456
|
|
|
return result |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
type ExpectedAttributeValue struct { |
|
|
|
|
460
|
|
|
AttributeValueList []AttributeValue `type:"list"` |
461
|
|
|
ComparisonOperator ComparisonOperator `type:"string" enum:"true"` |
462
|
|
|
Exists bool `type:"boolean"` |
463
|
|
|
Value AttributeValue `type:"structure"` |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
func (r ExpectedAttributeValue) ToSDK() SDK.ExpectedAttributeValue { |
|
|
|
|
467
|
|
|
o := SDK.ExpectedAttributeValue{} |
468
|
|
|
|
469
|
|
|
if len(r.AttributeValueList) != 0 { |
470
|
|
|
list := make([]SDK.AttributeValue, 0, len(r.AttributeValueList)) |
471
|
|
|
for _, v := range r.AttributeValueList { |
472
|
|
|
if v.hasValue() { |
473
|
|
|
list = append(list, v.ToSDK()) |
474
|
|
|
} |
475
|
|
|
} |
476
|
|
|
o.AttributeValueList = list |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
if r.Exists { |
480
|
|
|
o.Exists = pointers.Bool(r.Exists) |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
o.ComparisonOperator = SDK.ComparisonOperator(r.ComparisonOperator) |
484
|
|
|
|
485
|
|
|
if r.Value.hasValue() { |
486
|
|
|
v := r.Value.ToSDK() |
487
|
|
|
o.Value = &v |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
return o |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
type GlobalSecondaryIndex struct { |
|
|
|
|
494
|
|
|
IndexName string |
495
|
|
|
KeySchema []KeySchemaElement |
496
|
|
|
Projection Projection |
497
|
|
|
|
498
|
|
|
// optional |
499
|
|
|
ProvisionedThroughput ProvisionedThroughput |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
func (r GlobalSecondaryIndex) ToSDK() SDK.GlobalSecondaryIndex { |
|
|
|
|
503
|
|
|
o := SDK.GlobalSecondaryIndex{} |
504
|
|
|
|
505
|
|
|
if r.IndexName != "" { |
506
|
|
|
o.IndexName = pointers.String(r.IndexName) |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
if r.Projection.hasValue() { |
510
|
|
|
v := r.Projection.ToSDK() |
511
|
|
|
o.Projection = &v |
512
|
|
|
} |
513
|
|
|
if r.ProvisionedThroughput.hasValue() { |
514
|
|
|
v := r.ProvisionedThroughput.ToSDK() |
515
|
|
|
o.ProvisionedThroughput = &v |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
if len(r.KeySchema) != 0 { |
519
|
|
|
list := make([]SDK.KeySchemaElement, len(r.KeySchema)) |
520
|
|
|
for i, v := range r.KeySchema { |
521
|
|
|
list[i] = v.ToSDK() |
522
|
|
|
} |
523
|
|
|
o.KeySchema = list |
524
|
|
|
} |
525
|
|
|
return o |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
// Represents the properties of a global secondary index. |
|
|
|
|
529
|
|
|
type GlobalSecondaryIndexDescription struct { |
530
|
|
|
Backfilling bool |
531
|
|
|
IndexARN string |
532
|
|
|
IndexName string |
533
|
|
|
IndexSizeBytes int64 |
534
|
|
|
IndexStatus IndexStatus |
535
|
|
|
ItemCount int64 |
536
|
|
|
KeySchema []KeySchemaElement |
537
|
|
|
Projection Projection |
538
|
|
|
ProvisionedThroughput ProvisionedThroughputDescription |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
func newGlobalSecondaryIndexDescriptions(list []SDK.GlobalSecondaryIndexDescription) []GlobalSecondaryIndexDescription { |
542
|
|
|
if len(list) == 0 { |
543
|
|
|
return nil |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
result := make([]GlobalSecondaryIndexDescription, len(list)) |
547
|
|
|
for i, v := range list { |
548
|
|
|
result[i] = newGlobalSecondaryIndexDescription(v) |
549
|
|
|
} |
550
|
|
|
return result |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
func newGlobalSecondaryIndexDescription(o SDK.GlobalSecondaryIndexDescription) GlobalSecondaryIndexDescription { |
554
|
|
|
result := GlobalSecondaryIndexDescription{} |
555
|
|
|
|
556
|
|
|
if o.Backfilling != nil { |
557
|
|
|
result.Backfilling = *o.Backfilling |
558
|
|
|
} |
559
|
|
|
if o.IndexArn != nil { |
560
|
|
|
result.IndexARN = *o.IndexArn |
561
|
|
|
} |
562
|
|
|
if o.IndexName != nil { |
563
|
|
|
result.IndexName = *o.IndexName |
564
|
|
|
} |
565
|
|
|
if o.IndexSizeBytes != nil { |
566
|
|
|
result.IndexSizeBytes = *o.IndexSizeBytes |
567
|
|
|
} |
568
|
|
|
if o.ItemCount != nil { |
569
|
|
|
result.ItemCount = *o.ItemCount |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
result.IndexStatus = IndexStatus(o.IndexStatus) |
573
|
|
|
|
574
|
|
|
result.KeySchema = newKeySchemaElements(o.KeySchema) |
575
|
|
|
result.Projection = newProjection(o.Projection) |
576
|
|
|
result.ProvisionedThroughput = newProvisionedThroughputDescription(o.ProvisionedThroughput) |
577
|
|
|
return result |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
type ItemCollectionMetrics struct { |
|
|
|
|
581
|
|
|
ItemCollectionKey map[string]AttributeValue `type:"map"` |
582
|
|
|
SizeEstimateRangeGB []float64 `type:"list"` |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
func newItemCollectionMetrics(o SDK.ItemCollectionMetrics) ItemCollectionMetrics { |
586
|
|
|
result := ItemCollectionMetrics{} |
587
|
|
|
|
588
|
|
|
m := make(map[string]AttributeValue, len(o.ItemCollectionKey)) |
589
|
|
|
for key, val := range o.ItemCollectionKey { |
590
|
|
|
m[key] = newAttributeValue(val) |
591
|
|
|
} |
592
|
|
|
result.ItemCollectionKey = m |
593
|
|
|
|
594
|
|
|
result.SizeEstimateRangeGB = o.SizeEstimateRangeGB |
595
|
|
|
return result |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
type KeysAndAttributes struct { |
|
|
|
|
599
|
|
|
Keys []map[string]AttributeValue |
600
|
|
|
|
601
|
|
|
// optional |
602
|
|
|
AttributesToGet []string |
603
|
|
|
ConsistentRead bool |
604
|
|
|
ExpressionAttributeNames map[string]string |
605
|
|
|
ProjectionExpression string |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
func newKeysAndAttributes(o SDK.KeysAndAttributes) KeysAndAttributes { |
609
|
|
|
result := KeysAndAttributes{} |
610
|
|
|
|
611
|
|
|
result.AttributesToGet = o.AttributesToGet |
612
|
|
|
result.ExpressionAttributeNames = o.ExpressionAttributeNames |
613
|
|
|
|
614
|
|
|
if o.ConsistentRead != nil { |
615
|
|
|
result.ConsistentRead = *o.ConsistentRead |
616
|
|
|
} |
617
|
|
|
if o.ProjectionExpression != nil { |
618
|
|
|
result.ProjectionExpression = *o.ProjectionExpression |
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
if len(o.Keys) != 0 { |
622
|
|
|
list := make([]map[string]AttributeValue, len(o.Keys)) |
623
|
|
|
for i, v := range o.Keys { |
624
|
|
|
list[i] = newAttributeValueMap(v) |
625
|
|
|
} |
626
|
|
|
result.Keys = list |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
return result |
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
func (r KeysAndAttributes) ToSDK() SDK.KeysAndAttributes { |
|
|
|
|
633
|
|
|
o := SDK.KeysAndAttributes{} |
634
|
|
|
|
635
|
|
|
if len(r.Keys) != 0 { |
636
|
|
|
list := make([]map[string]SDK.AttributeValue, len(r.Keys)) |
637
|
|
|
for i, v := range r.Keys { |
638
|
|
|
m := make(map[string]SDK.AttributeValue, len(v)) |
639
|
|
|
for key, val := range v { |
640
|
|
|
m[key] = val.ToSDK() |
641
|
|
|
} |
642
|
|
|
list[i] = m |
643
|
|
|
} |
644
|
|
|
o.Keys = list |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
if r.ConsistentRead { |
648
|
|
|
o.ConsistentRead = pointers.Bool(r.ConsistentRead) |
649
|
|
|
} |
650
|
|
|
if r.ProjectionExpression != "" { |
651
|
|
|
o.ProjectionExpression = pointers.String(r.ProjectionExpression) |
652
|
|
|
} |
653
|
|
|
|
654
|
|
|
o.AttributesToGet = r.AttributesToGet |
655
|
|
|
o.ExpressionAttributeNames = r.ExpressionAttributeNames |
656
|
|
|
return o |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
type KeySchemaElement struct { |
|
|
|
|
660
|
|
|
AttributeName string |
661
|
|
|
KeyType KeyType |
662
|
|
|
} |
663
|
|
|
|
664
|
|
|
func newKeySchemaElements(list []SDK.KeySchemaElement) []KeySchemaElement { |
665
|
|
|
if len(list) == 0 { |
666
|
|
|
return nil |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
results := make([]KeySchemaElement, len(list)) |
670
|
|
|
for i, v := range list { |
671
|
|
|
results[i] = newKeySchemaElement(v) |
672
|
|
|
} |
673
|
|
|
return results |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
func newKeySchemaElement(o SDK.KeySchemaElement) KeySchemaElement { |
677
|
|
|
result := KeySchemaElement{} |
678
|
|
|
|
679
|
|
|
if o.AttributeName != nil { |
680
|
|
|
result.AttributeName = *o.AttributeName |
681
|
|
|
} |
682
|
|
|
|
683
|
|
|
result.KeyType = KeyType(o.KeyType) |
684
|
|
|
return result |
685
|
|
|
} |
686
|
|
|
|
687
|
|
|
func (r KeySchemaElement) ToSDK() SDK.KeySchemaElement { |
|
|
|
|
688
|
|
|
o := SDK.KeySchemaElement{} |
689
|
|
|
|
690
|
|
|
if r.AttributeName != "" { |
691
|
|
|
o.AttributeName = pointers.String(r.AttributeName) |
692
|
|
|
} |
693
|
|
|
o.KeyType = SDK.KeyType(r.KeyType) |
694
|
|
|
return o |
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
type LocalSecondaryIndex struct { |
|
|
|
|
698
|
|
|
IndexName string |
699
|
|
|
KeySchema []KeySchemaElement |
700
|
|
|
Projection Projection |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
func (r LocalSecondaryIndex) ToSDK() SDK.LocalSecondaryIndex { |
|
|
|
|
704
|
|
|
o := SDK.LocalSecondaryIndex{} |
705
|
|
|
|
706
|
|
|
if r.IndexName != "" { |
707
|
|
|
o.IndexName = pointers.String(r.IndexName) |
708
|
|
|
} |
709
|
|
|
|
710
|
|
|
if r.Projection.hasValue() { |
711
|
|
|
v := r.Projection.ToSDK() |
712
|
|
|
o.Projection = &v |
713
|
|
|
} |
714
|
|
|
|
715
|
|
|
if len(r.KeySchema) != 0 { |
716
|
|
|
list := make([]SDK.KeySchemaElement, len(r.KeySchema)) |
717
|
|
|
for i, v := range r.KeySchema { |
718
|
|
|
list[i] = v.ToSDK() |
719
|
|
|
} |
720
|
|
|
o.KeySchema = list |
721
|
|
|
} |
722
|
|
|
return o |
723
|
|
|
} |
724
|
|
|
|
725
|
|
|
type LocalSecondaryIndexDescription struct { |
|
|
|
|
726
|
|
|
IndexARN string |
727
|
|
|
IndexName string |
728
|
|
|
IndexSizeBytes int64 |
729
|
|
|
ItemCount int64 |
730
|
|
|
KeySchema []KeySchemaElement |
731
|
|
|
Projection Projection |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
func newLocalSecondaryIndexDescriptions(list []SDK.LocalSecondaryIndexDescription) []LocalSecondaryIndexDescription { |
735
|
|
|
if len(list) == 0 { |
736
|
|
|
return nil |
737
|
|
|
} |
738
|
|
|
|
739
|
|
|
result := make([]LocalSecondaryIndexDescription, len(list)) |
740
|
|
|
for i, v := range list { |
741
|
|
|
result[i] = newLocalSecondaryIndexDescription(v) |
742
|
|
|
} |
743
|
|
|
return result |
744
|
|
|
} |
745
|
|
|
|
746
|
|
|
func newLocalSecondaryIndexDescription(o SDK.LocalSecondaryIndexDescription) LocalSecondaryIndexDescription { |
747
|
|
|
result := LocalSecondaryIndexDescription{} |
748
|
|
|
|
749
|
|
|
if o.IndexArn != nil { |
750
|
|
|
result.IndexARN = *o.IndexArn |
751
|
|
|
} |
752
|
|
|
if o.IndexName != nil { |
753
|
|
|
result.IndexName = *o.IndexName |
754
|
|
|
} |
755
|
|
|
if o.IndexSizeBytes != nil { |
756
|
|
|
result.IndexSizeBytes = *o.IndexSizeBytes |
757
|
|
|
} |
758
|
|
|
if o.ItemCount != nil { |
759
|
|
|
result.ItemCount = *o.ItemCount |
760
|
|
|
} |
761
|
|
|
|
762
|
|
|
result.KeySchema = newKeySchemaElements(o.KeySchema) |
763
|
|
|
result.Projection = newProjection(o.Projection) |
764
|
|
|
return result |
765
|
|
|
} |
766
|
|
|
|
767
|
|
|
type Projection struct { |
|
|
|
|
768
|
|
|
NonKeyAttributes []string |
769
|
|
|
ProjectionType ProjectionType |
770
|
|
|
} |
771
|
|
|
|
772
|
|
|
func newProjection(o *SDK.Projection) Projection { |
773
|
|
|
result := Projection{} |
774
|
|
|
if o == nil { |
775
|
|
|
return result |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
result.NonKeyAttributes = o.NonKeyAttributes |
779
|
|
|
result.ProjectionType = ProjectionType(o.ProjectionType) |
780
|
|
|
return result |
781
|
|
|
} |
782
|
|
|
|
783
|
|
|
func (r Projection) ToSDK() SDK.Projection { |
|
|
|
|
784
|
|
|
o := SDK.Projection{} |
785
|
|
|
o.NonKeyAttributes = r.NonKeyAttributes |
786
|
|
|
o.ProjectionType = SDK.ProjectionType(r.ProjectionType) |
787
|
|
|
return o |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
func (r Projection) hasValue() bool { |
791
|
|
|
switch { |
792
|
|
|
case r.ProjectionType != "", |
793
|
|
|
len(r.NonKeyAttributes) != 0: |
794
|
|
|
return true |
795
|
|
|
} |
796
|
|
|
return false |
797
|
|
|
} |
798
|
|
|
|
799
|
|
|
type ProvisionedThroughput struct { |
|
|
|
|
800
|
|
|
ReadCapacityUnits int64 |
801
|
|
|
WriteCapacityUnits int64 |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
func (r ProvisionedThroughput) ToSDK() SDK.ProvisionedThroughput { |
|
|
|
|
805
|
|
|
return SDK.ProvisionedThroughput{ |
806
|
|
|
ReadCapacityUnits: pointers.Long64(r.ReadCapacityUnits), |
807
|
|
|
WriteCapacityUnits: pointers.Long64(r.WriteCapacityUnits), |
808
|
|
|
} |
809
|
|
|
} |
810
|
|
|
|
811
|
|
|
func (r ProvisionedThroughput) hasValue() bool { |
812
|
|
|
switch { |
813
|
|
|
case r.ReadCapacityUnits != 0, |
814
|
|
|
r.WriteCapacityUnits != 0: |
815
|
|
|
return true |
816
|
|
|
} |
817
|
|
|
return false |
818
|
|
|
} |
819
|
|
|
|
820
|
|
|
type ProvisionedThroughputDescription struct { |
|
|
|
|
821
|
|
|
LastDecreaseDateTime time.Time |
822
|
|
|
LastIncreaseDateTime time.Time |
823
|
|
|
NumberOfDecreasesToday int64 |
824
|
|
|
ReadCapacityUnits int64 |
825
|
|
|
WriteCapacityUnits int64 |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
func newProvisionedThroughputDescription(o *SDK.ProvisionedThroughputDescription) ProvisionedThroughputDescription { |
829
|
|
|
result := ProvisionedThroughputDescription{} |
830
|
|
|
if o == nil { |
831
|
|
|
return result |
832
|
|
|
} |
833
|
|
|
|
834
|
|
|
if o.LastDecreaseDateTime != nil { |
835
|
|
|
result.LastDecreaseDateTime = *o.LastDecreaseDateTime |
836
|
|
|
} |
837
|
|
|
if o.LastIncreaseDateTime != nil { |
838
|
|
|
result.LastIncreaseDateTime = *o.LastIncreaseDateTime |
839
|
|
|
} |
840
|
|
|
if o.NumberOfDecreasesToday != nil { |
841
|
|
|
result.NumberOfDecreasesToday = *o.NumberOfDecreasesToday |
842
|
|
|
} |
843
|
|
|
if o.ReadCapacityUnits != nil { |
844
|
|
|
result.ReadCapacityUnits = *o.ReadCapacityUnits |
845
|
|
|
} |
846
|
|
|
if o.WriteCapacityUnits != nil { |
847
|
|
|
result.WriteCapacityUnits = *o.WriteCapacityUnits |
848
|
|
|
} |
849
|
|
|
return result |
850
|
|
|
} |
851
|
|
|
|
852
|
|
|
type ReplicaDescription struct { |
|
|
|
|
853
|
|
|
GlobalSecondaryIndexes []ReplicaGlobalSecondaryIndexDescription |
854
|
|
|
KMSMasterKeyID string |
855
|
|
|
RegionName string |
856
|
|
|
ReplicaStatus ReplicaStatus |
857
|
|
|
ReplicaStatusDescription string |
858
|
|
|
ReplicaStatusPercentProgress string |
859
|
|
|
|
860
|
|
|
ProvisionedThroughputOverrideRCU int64 |
861
|
|
|
} |
862
|
|
|
|
863
|
|
|
func newReplicaDescriptions(list []SDK.ReplicaDescription) []ReplicaDescription { |
864
|
|
|
if len(list) == 0 { |
865
|
|
|
return nil |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
result := make([]ReplicaDescription, len(list)) |
869
|
|
|
for i, v := range list { |
870
|
|
|
result[i] = newReplicaDescription(v) |
871
|
|
|
} |
872
|
|
|
return result |
873
|
|
|
} |
874
|
|
|
|
875
|
|
|
func newReplicaDescription(o SDK.ReplicaDescription) ReplicaDescription { |
876
|
|
|
result := ReplicaDescription{} |
877
|
|
|
|
878
|
|
|
if o.KMSMasterKeyId != nil { |
879
|
|
|
result.KMSMasterKeyID = *o.KMSMasterKeyId |
880
|
|
|
} |
881
|
|
|
if o.RegionName != nil { |
882
|
|
|
result.RegionName = *o.RegionName |
883
|
|
|
} |
884
|
|
|
if o.ReplicaStatusDescription != nil { |
885
|
|
|
result.ReplicaStatusDescription = *o.ReplicaStatusDescription |
886
|
|
|
} |
887
|
|
|
if o.ReplicaStatusPercentProgress != nil { |
888
|
|
|
result.ReplicaStatusPercentProgress = *o.ReplicaStatusPercentProgress |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
result.ReplicaStatus = ReplicaStatus(o.ReplicaStatus) |
892
|
|
|
|
893
|
|
|
result.GlobalSecondaryIndexes = newReplicaGlobalSecondaryIndexDescriptions(o.GlobalSecondaryIndexes) |
894
|
|
|
if v := o.ProvisionedThroughputOverride; v != nil { |
895
|
|
|
if v.ReadCapacityUnits != nil { |
896
|
|
|
result.ProvisionedThroughputOverrideRCU = *v.ReadCapacityUnits |
897
|
|
|
} |
898
|
|
|
} |
899
|
|
|
return result |
900
|
|
|
} |
901
|
|
|
|
902
|
|
|
type ReplicaGlobalSecondaryIndexDescription struct { |
|
|
|
|
903
|
|
|
IndexName string |
904
|
|
|
ProvisionedThroughputOverrideRCU int64 |
905
|
|
|
} |
906
|
|
|
|
907
|
|
|
func newReplicaGlobalSecondaryIndexDescriptions(list []SDK.ReplicaGlobalSecondaryIndexDescription) []ReplicaGlobalSecondaryIndexDescription { |
908
|
|
|
if len(list) == 0 { |
909
|
|
|
return nil |
910
|
|
|
} |
911
|
|
|
|
912
|
|
|
result := make([]ReplicaGlobalSecondaryIndexDescription, len(list)) |
913
|
|
|
for i, v := range list { |
914
|
|
|
result[i] = newReplicaGlobalSecondaryIndexDescription(v) |
915
|
|
|
} |
916
|
|
|
return result |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
func newReplicaGlobalSecondaryIndexDescription(o SDK.ReplicaGlobalSecondaryIndexDescription) ReplicaGlobalSecondaryIndexDescription { |
920
|
|
|
result := ReplicaGlobalSecondaryIndexDescription{} |
921
|
|
|
|
922
|
|
|
if o.IndexName != nil { |
923
|
|
|
result.IndexName = *o.IndexName |
924
|
|
|
} |
925
|
|
|
if v := o.ProvisionedThroughputOverride; v != nil { |
926
|
|
|
if v.ReadCapacityUnits != nil { |
927
|
|
|
result.ProvisionedThroughputOverrideRCU = *v.ReadCapacityUnits |
928
|
|
|
} |
929
|
|
|
} |
930
|
|
|
return result |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
type RestoreSummary struct { |
|
|
|
|
934
|
|
|
RestoreDateTime time.Time |
935
|
|
|
RestoreInProgress bool |
936
|
|
|
|
937
|
|
|
// optional |
938
|
|
|
SourceBackupARN string |
939
|
|
|
SourceTableARN string |
940
|
|
|
} |
941
|
|
|
|
942
|
|
|
func newRestoreSummary(o *SDK.RestoreSummary) RestoreSummary { |
943
|
|
|
result := RestoreSummary{} |
944
|
|
|
if o == nil { |
945
|
|
|
return result |
946
|
|
|
} |
947
|
|
|
|
948
|
|
|
if o.RestoreDateTime != nil { |
949
|
|
|
result.RestoreDateTime = *o.RestoreDateTime |
950
|
|
|
} |
951
|
|
|
if o.RestoreInProgress != nil { |
952
|
|
|
result.RestoreInProgress = *o.RestoreInProgress |
953
|
|
|
} |
954
|
|
|
if o.SourceBackupArn != nil { |
955
|
|
|
result.SourceBackupARN = *o.SourceBackupArn |
956
|
|
|
} |
957
|
|
|
if o.SourceTableArn != nil { |
958
|
|
|
result.SourceTableARN = *o.SourceTableArn |
959
|
|
|
} |
960
|
|
|
return result |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
type SSEDescription struct { |
|
|
|
|
964
|
|
|
InaccessibleEncryptionDateTime time.Time |
965
|
|
|
KMSMasterKeyArn string |
966
|
|
|
SSEType SSEType |
967
|
|
|
Status SSEStatus |
968
|
|
|
} |
969
|
|
|
|
970
|
|
|
func newSSEDescription(o *SDK.SSEDescription) SSEDescription { |
971
|
|
|
result := SSEDescription{} |
972
|
|
|
if o == nil { |
973
|
|
|
return result |
974
|
|
|
} |
975
|
|
|
|
976
|
|
|
if o.InaccessibleEncryptionDateTime != nil { |
977
|
|
|
result.InaccessibleEncryptionDateTime = *o.InaccessibleEncryptionDateTime |
978
|
|
|
} |
979
|
|
|
if o.KMSMasterKeyArn != nil { |
980
|
|
|
result.KMSMasterKeyArn = *o.KMSMasterKeyArn |
981
|
|
|
} |
982
|
|
|
result.SSEType = SSEType(o.SSEType) |
983
|
|
|
result.Status = SSEStatus(o.Status) |
984
|
|
|
return result |
985
|
|
|
} |
986
|
|
|
|
987
|
|
|
type SSESpecification struct { |
|
|
|
|
988
|
|
|
Enabled bool |
989
|
|
|
KMSMasterKeyID string |
990
|
|
|
SSEType SSEType |
991
|
|
|
} |
992
|
|
|
|
993
|
|
|
func (r SSESpecification) ToSDK() SDK.SSESpecification { |
|
|
|
|
994
|
|
|
o := SDK.SSESpecification{} |
995
|
|
|
|
996
|
|
|
if r.Enabled { |
997
|
|
|
o.Enabled = pointers.Bool(r.Enabled) |
998
|
|
|
} |
999
|
|
|
if r.KMSMasterKeyID != "" { |
1000
|
|
|
o.KMSMasterKeyId = pointers.String(r.KMSMasterKeyID) |
1001
|
|
|
} |
1002
|
|
|
o.SSEType = SDK.SSEType(r.SSEType) |
1003
|
|
|
return o |
1004
|
|
|
} |
1005
|
|
|
|
1006
|
|
|
func (r SSESpecification) hasValue() bool { |
1007
|
|
|
switch { |
1008
|
|
|
case r.Enabled, |
1009
|
|
|
r.KMSMasterKeyID != "", |
1010
|
|
|
r.SSEType != "": |
1011
|
|
|
return true |
1012
|
|
|
} |
1013
|
|
|
return false |
1014
|
|
|
} |
1015
|
|
|
|
1016
|
|
|
type StreamSpecification struct { |
|
|
|
|
1017
|
|
|
StreamEnabled bool |
1018
|
|
|
|
1019
|
|
|
// optional |
1020
|
|
|
StreamViewType StreamViewType |
1021
|
|
|
} |
1022
|
|
|
|
1023
|
|
|
func newStreamSpecification(o *SDK.StreamSpecification) StreamSpecification { |
1024
|
|
|
result := StreamSpecification{} |
1025
|
|
|
if o == nil { |
1026
|
|
|
return result |
1027
|
|
|
} |
1028
|
|
|
|
1029
|
|
|
if o.StreamEnabled != nil { |
1030
|
|
|
result.StreamEnabled = *o.StreamEnabled |
1031
|
|
|
} |
1032
|
|
|
result.StreamViewType = StreamViewType(o.StreamViewType) |
1033
|
|
|
return result |
1034
|
|
|
} |
1035
|
|
|
|
1036
|
|
|
func (r StreamSpecification) ToSDK() SDK.StreamSpecification { |
|
|
|
|
1037
|
|
|
o := SDK.StreamSpecification{} |
1038
|
|
|
|
1039
|
|
|
if r.StreamEnabled { |
1040
|
|
|
o.StreamEnabled = pointers.Bool(r.StreamEnabled) |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
o.StreamViewType = SDK.StreamViewType(r.StreamViewType) |
1044
|
|
|
return o |
1045
|
|
|
} |
1046
|
|
|
|
1047
|
|
|
func (r StreamSpecification) hasValue() bool { |
1048
|
|
|
switch { |
1049
|
|
|
case r.StreamEnabled, |
1050
|
|
|
r.StreamViewType != "": |
1051
|
|
|
return true |
1052
|
|
|
} |
1053
|
|
|
return false |
1054
|
|
|
} |
1055
|
|
|
|
1056
|
|
|
type TableDescription struct { |
|
|
|
|
1057
|
|
|
ArchivalSummary ArchivalSummary |
1058
|
|
|
AttributeDefinitions []AttributeDefinition |
1059
|
|
|
BillingModeSummary BillingModeSummary |
1060
|
|
|
CreationDateTime time.Time |
1061
|
|
|
GlobalSecondaryIndexes []GlobalSecondaryIndexDescription |
1062
|
|
|
GlobalTableVersion string |
1063
|
|
|
ItemCount int64 |
1064
|
|
|
KeySchema []KeySchemaElement |
1065
|
|
|
LatestStreamARN string |
1066
|
|
|
LatestStreamLabel string |
1067
|
|
|
LocalSecondaryIndexes []LocalSecondaryIndexDescription |
1068
|
|
|
ProvisionedThroughput ProvisionedThroughputDescription |
1069
|
|
|
Replicas []ReplicaDescription |
1070
|
|
|
RestoreSummary RestoreSummary |
1071
|
|
|
SSEDescription SSEDescription |
1072
|
|
|
StreamSpecification StreamSpecification |
1073
|
|
|
TableARN string |
1074
|
|
|
TableID string |
1075
|
|
|
TableName string |
1076
|
|
|
TableSizeBytes int64 |
1077
|
|
|
TableStatus TableStatus |
1078
|
|
|
} |
1079
|
|
|
|
1080
|
|
|
func newTableDescription(o SDK.TableDescription) TableDescription { |
1081
|
|
|
result := TableDescription{} |
1082
|
|
|
|
1083
|
|
|
if o.CreationDateTime != nil { |
1084
|
|
|
result.CreationDateTime = *o.CreationDateTime |
1085
|
|
|
} |
1086
|
|
|
if o.GlobalTableVersion != nil { |
1087
|
|
|
result.GlobalTableVersion = *o.GlobalTableVersion |
1088
|
|
|
} |
1089
|
|
|
if o.ItemCount != nil { |
1090
|
|
|
result.ItemCount = *o.ItemCount |
1091
|
|
|
} |
1092
|
|
|
if o.LatestStreamArn != nil { |
1093
|
|
|
result.LatestStreamARN = *o.LatestStreamArn |
1094
|
|
|
} |
1095
|
|
|
if o.LatestStreamLabel != nil { |
1096
|
|
|
result.LatestStreamLabel = *o.LatestStreamLabel |
1097
|
|
|
} |
1098
|
|
|
if o.TableArn != nil { |
1099
|
|
|
result.TableARN = *o.TableArn |
1100
|
|
|
} |
1101
|
|
|
if o.TableId != nil { |
1102
|
|
|
result.TableID = *o.TableId |
1103
|
|
|
} |
1104
|
|
|
if o.TableName != nil { |
1105
|
|
|
result.TableName = *o.TableName |
1106
|
|
|
} |
1107
|
|
|
if o.TableSizeBytes != nil { |
1108
|
|
|
result.TableSizeBytes = *o.TableSizeBytes |
1109
|
|
|
} |
1110
|
|
|
|
1111
|
|
|
result.TableStatus = TableStatus(o.TableStatus) |
1112
|
|
|
|
1113
|
|
|
result.ArchivalSummary = newArchivalSummary(o.ArchivalSummary) |
1114
|
|
|
result.BillingModeSummary = newBillingModeSummary(o.BillingModeSummary) |
1115
|
|
|
result.ProvisionedThroughput = newProvisionedThroughputDescription(o.ProvisionedThroughput) |
1116
|
|
|
result.RestoreSummary = newRestoreSummary(o.RestoreSummary) |
1117
|
|
|
result.SSEDescription = newSSEDescription(o.SSEDescription) |
1118
|
|
|
result.StreamSpecification = newStreamSpecification(o.StreamSpecification) |
1119
|
|
|
|
1120
|
|
|
result.AttributeDefinitions = newAttributeDefinitions(o.AttributeDefinitions) |
1121
|
|
|
result.GlobalSecondaryIndexes = newGlobalSecondaryIndexDescriptions(o.GlobalSecondaryIndexes) |
1122
|
|
|
result.LocalSecondaryIndexes = newLocalSecondaryIndexDescriptions(o.LocalSecondaryIndexes) |
1123
|
|
|
result.KeySchema = newKeySchemaElements(o.KeySchema) |
1124
|
|
|
result.Replicas = newReplicaDescriptions(o.Replicas) |
1125
|
|
|
return result |
1126
|
|
|
} |
1127
|
|
|
|
1128
|
|
|
type Tag struct { |
|
|
|
|
1129
|
|
|
Key string |
1130
|
|
|
Value string |
1131
|
|
|
} |
1132
|
|
|
|
1133
|
|
|
func (r Tag) ToSDK() SDK.Tag { |
|
|
|
|
1134
|
|
|
o := SDK.Tag{} |
1135
|
|
|
|
1136
|
|
|
if r.Key != "" { |
1137
|
|
|
o.Key = pointers.String(r.Key) |
1138
|
|
|
} |
1139
|
|
|
if r.Value != "" { |
1140
|
|
|
o.Value = pointers.String(r.Value) |
1141
|
|
|
} |
1142
|
|
|
return o |
1143
|
|
|
} |
1144
|
|
|
|
1145
|
|
|
type WriteRequest struct { |
|
|
|
|
1146
|
|
|
DeleteKeys map[string]AttributeValue |
1147
|
|
|
PutItems map[string]AttributeValue |
1148
|
|
|
} |
1149
|
|
|
|
1150
|
|
|
func newWriteRequest(o SDK.WriteRequest) WriteRequest { |
1151
|
|
|
result := WriteRequest{ |
1152
|
|
|
DeleteKeys: make(map[string]AttributeValue), |
1153
|
|
|
PutItems: make(map[string]AttributeValue), |
1154
|
|
|
} |
1155
|
|
|
|
1156
|
|
|
if o.DeleteRequest != nil { |
1157
|
|
|
m := make(map[string]AttributeValue, len(o.DeleteRequest.Key)) |
1158
|
|
|
for key, val := range o.DeleteRequest.Key { |
1159
|
|
|
m[key] = newAttributeValue(val) |
1160
|
|
|
} |
1161
|
|
|
result.DeleteKeys = m |
1162
|
|
|
} |
1163
|
|
|
|
1164
|
|
|
if o.PutRequest != nil { |
1165
|
|
|
m := make(map[string]AttributeValue, len(o.PutRequest.Item)) |
1166
|
|
|
for key, val := range o.PutRequest.Item { |
1167
|
|
|
m[key] = newAttributeValue(val) |
1168
|
|
|
} |
1169
|
|
|
result.DeleteKeys = m |
1170
|
|
|
} |
1171
|
|
|
|
1172
|
|
|
return result |
1173
|
|
|
} |
1174
|
|
|
|
1175
|
|
|
func (r WriteRequest) ToSDK() SDK.WriteRequest { |
|
|
|
|
1176
|
|
|
o := SDK.WriteRequest{} |
1177
|
|
|
|
1178
|
|
|
if len(r.DeleteKeys) != 0 { |
1179
|
|
|
m := make(map[string]SDK.AttributeValue, len(r.DeleteKeys)) |
1180
|
|
|
for key, val := range r.DeleteKeys { |
1181
|
|
|
m[key] = val.ToSDK() |
1182
|
|
|
} |
1183
|
|
|
o.DeleteRequest = &SDK.DeleteRequest{ |
1184
|
|
|
Key: m, |
1185
|
|
|
} |
1186
|
|
|
} |
1187
|
|
|
|
1188
|
|
|
if len(r.PutItems) != 0 { |
1189
|
|
|
m := make(map[string]SDK.AttributeValue, len(r.PutItems)) |
1190
|
|
|
for key, val := range r.PutItems { |
1191
|
|
|
m[key] = val.ToSDK() |
1192
|
|
|
} |
1193
|
|
|
o.PutRequest = &SDK.PutRequest{ |
1194
|
|
|
Item: m, |
1195
|
|
|
} |
1196
|
|
|
} |
1197
|
|
|
|
1198
|
|
|
return o |
1199
|
|
|
} |
1200
|
|
|
|