Passed
Push — master ( 2f1af3...a8e5e6 )
by eval
03:46 queued 02:09
created

dynamodb.newBillingModeSummary   A

Complexity

Conditions 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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