Passed
Pull Request — master (#10)
by eval
01:42
created

dynamodb.AttributeValue.GetValue   F

Complexity

Conditions 19

Size

Total Lines 48
Code Lines 44

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 19
eloc 44
nop 0
dl 0
loc 48
rs 0.5999
c 0
b 0
f 0

How to fix   Complexity   

Complexity

Complex classes like dynamodb.AttributeValue.GetValue often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

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) GetValue() interface{} {
0 ignored issues
show
introduced by
exported method AttributeValue.GetValue should have comment or be unexported
Loading history...
203
	switch {
204
	case len(r.Binary) != 0:
205
		return r.Binary
206
	case len(r.BinarySet) != 0:
207
		return r.BinarySet
208
	case len(r.List) != 0:
209
		list := make([]interface{}, len(r.List))
210
		for i, v := range r.List {
211
			list[i] = v.GetValue()
212
		}
213
		return list
214
	case len(r.Map) != 0:
215
		m := make(map[string]interface{}, len(r.Map))
216
		for key, val := range r.Map {
217
			m[key] = val.GetValue()
218
		}
219
		return m
220
	case r.Number != "":
221
		v, _ := strconv.Atoi(r.Number)
222
		return v
223
	case r.NumberInt != 0:
224
		return r.NumberInt
225
	case r.NumberFloat != 0:
226
		return r.NumberFloat
227
	case r.HasNumber:
228
		return 0
229
	case len(r.NumberSet) != 0:
230
		list := make([]int, len(r.NumberSet))
231
		for i, v := range r.NumberSet {
232
			list[i], _ = strconv.Atoi(v)
233
		}
234
		return list
235
	case len(r.NumberSetInt) != 0:
236
		return r.NumberSetInt
237
	case len(r.NumberSetFloat) != 0:
238
		return r.NumberSetFloat
239
	case r.String != "":
240
		return r.String
241
	case len(r.StringSet) != 0:
242
		return r.StringSet
243
	case r.HasBool,
244
		r.Bool:
245
		return r.Bool
246
	case r.Null:
247
		return newArchivalSummary
248
	}
249
	return nil
250
}
251
252
func (r AttributeValue) hasValue() bool {
253
	switch {
254
	case r.HasNumber,
255
		r.HasBool,
256
		r.Bool,
257
		r.Null,
258
		r.Number != "",
259
		r.NumberInt != 0,
260
		r.NumberFloat != 0,
261
		r.String != "",
262
		len(r.Binary) != 0,
263
		len(r.BinarySet) != 0,
264
		len(r.List) != 0,
265
		len(r.Map) != 0,
266
		len(r.NumberSet) != 0,
267
		len(r.NumberSetInt) != 0,
268
		len(r.NumberSetFloat) != 0,
269
		len(r.StringSet) != 0:
270
		return true
271
	}
272
	return false
273
}
274
275
type BillingModeSummary struct {
0 ignored issues
show
introduced by
exported type BillingModeSummary should have comment or be unexported
Loading history...
276
	BillingMode                       BillingMode
277
	LastUpdateToPayPerRequestDateTime time.Time
278
}
279
280
func newBillingModeSummary(o *SDK.BillingModeSummary) BillingModeSummary {
281
	result := BillingModeSummary{}
282
	if o == nil {
283
		return result
284
	}
285
286
	if o.LastUpdateToPayPerRequestDateTime != nil {
287
		result.LastUpdateToPayPerRequestDateTime = *o.LastUpdateToPayPerRequestDateTime
288
	}
289
290
	result.BillingMode = BillingMode(o.BillingMode)
291
	return result
292
}
293
294
type Capacity struct {
0 ignored issues
show
introduced by
exported type Capacity should have comment or be unexported
Loading history...
295
	CapacityUnits      float64
296
	ReadCapacityUnits  float64
297
	WriteCapacityUnits float64
298
}
299
300
func newCapacity(o *SDK.Capacity) Capacity {
301
	result := Capacity{}
302
	if o == nil {
303
		return result
304
	}
305
306
	if o.CapacityUnits != nil {
307
		result.CapacityUnits = *o.CapacityUnits
308
	}
309
	if o.ReadCapacityUnits != nil {
310
		result.ReadCapacityUnits = *o.ReadCapacityUnits
311
	}
312
	if o.WriteCapacityUnits != nil {
313
		result.WriteCapacityUnits = *o.WriteCapacityUnits
314
	}
315
	return result
316
}
317
318
func newCapacityMap(m map[string]SDK.Capacity) map[string]Capacity {
319
	if m == nil {
320
		return nil
321
	}
322
323
	result := make(map[string]Capacity, len(m))
324
	for key, val := range m {
325
		val := val
326
		result[key] = newCapacity(&val)
327
	}
328
	return result
329
}
330
331
type Condition struct {
0 ignored issues
show
introduced by
exported type Condition should have comment or be unexported
Loading history...
332
	ComparisonOperator ComparisonOperator
333
334
	// optional
335
	AttributeValueList []AttributeValue
336
}
337
338
func (r Condition) ToSDK() SDK.Condition {
0 ignored issues
show
introduced by
exported method Condition.ToSDK should have comment or be unexported
Loading history...
339
	o := SDK.Condition{}
340
341
	o.ComparisonOperator = SDK.ComparisonOperator(r.ComparisonOperator)
342
343
	if len(r.AttributeValueList) != 0 {
344
		list := make([]SDK.AttributeValue, len(r.AttributeValueList))
345
		for i, v := range r.AttributeValueList {
346
			list[i] = v.ToSDK()
347
		}
348
		o.AttributeValueList = list
349
	}
350
351
	return o
352
}
353
354
type ConsumedCapacity struct {
0 ignored issues
show
introduced by
exported type ConsumedCapacity should have comment or be unexported
Loading history...
355
	CapacityUnits          float64
356
	GlobalSecondaryIndexes map[string]Capacity
357
	LocalSecondaryIndexes  map[string]Capacity
358
	ReadCapacityUnits      float64
359
	Table                  Capacity
360
	TableName              string
361
	WriteCapacityUnits     float64
362
}
363
364
func newConsumedCapacities(list []SDK.ConsumedCapacity) []ConsumedCapacity {
365
	if len(list) == 0 {
366
		return nil
367
	}
368
369
	result := make([]ConsumedCapacity, len(list))
370
	for i, v := range list {
371
		result[i] = newConsumedCapacity(v)
372
	}
373
	return result
374
}
375
376
func newConsumedCapacity(o SDK.ConsumedCapacity) ConsumedCapacity {
377
	result := ConsumedCapacity{}
378
379
	if o.CapacityUnits != nil {
380
		result.CapacityUnits = *o.CapacityUnits
381
	}
382
	if o.ReadCapacityUnits != nil {
383
		result.ReadCapacityUnits = *o.ReadCapacityUnits
384
	}
385
	if o.TableName != nil {
386
		result.TableName = *o.TableName
387
	}
388
	if o.WriteCapacityUnits != nil {
389
		result.WriteCapacityUnits = *o.WriteCapacityUnits
390
	}
391
392
	result.GlobalSecondaryIndexes = newCapacityMap(o.GlobalSecondaryIndexes)
393
	result.LocalSecondaryIndexes = newCapacityMap(o.LocalSecondaryIndexes)
394
	result.Table = newCapacity(o.Table)
395
	return result
396
}
397
398
type ExpectedAttributeValue struct {
0 ignored issues
show
introduced by
exported type ExpectedAttributeValue should have comment or be unexported
Loading history...
399
	AttributeValueList []AttributeValue   `type:"list"`
400
	ComparisonOperator ComparisonOperator `type:"string" enum:"true"`
401
	Exists             bool               `type:"boolean"`
402
	Value              AttributeValue     `type:"structure"`
403
}
404
405
func (r ExpectedAttributeValue) ToSDK() SDK.ExpectedAttributeValue {
0 ignored issues
show
introduced by
exported method ExpectedAttributeValue.ToSDK should have comment or be unexported
Loading history...
406
	o := SDK.ExpectedAttributeValue{}
407
408
	if len(r.AttributeValueList) != 0 {
409
		list := make([]SDK.AttributeValue, 0, len(r.AttributeValueList))
410
		for _, v := range r.AttributeValueList {
411
			if v.hasValue() {
412
				list = append(list, v.ToSDK())
413
			}
414
		}
415
		o.AttributeValueList = list
416
	}
417
418
	if r.Exists {
419
		o.Exists = pointers.Bool(r.Exists)
420
	}
421
422
	o.ComparisonOperator = SDK.ComparisonOperator(r.ComparisonOperator)
423
424
	if r.Value.hasValue() {
425
		v := r.Value.ToSDK()
426
		o.Value = &v
427
	}
428
429
	return o
430
}
431
432
type GlobalSecondaryIndex struct {
0 ignored issues
show
introduced by
exported type GlobalSecondaryIndex should have comment or be unexported
Loading history...
433
	IndexName  string
434
	KeySchema  []KeySchemaElement
435
	Projection Projection
436
437
	// optional
438
	ProvisionedThroughput ProvisionedThroughput
439
}
440
441
func (r GlobalSecondaryIndex) ToSDK() SDK.GlobalSecondaryIndex {
0 ignored issues
show
introduced by
exported method GlobalSecondaryIndex.ToSDK should have comment or be unexported
Loading history...
442
	o := SDK.GlobalSecondaryIndex{}
443
444
	if r.IndexName != "" {
445
		o.IndexName = pointers.String(r.IndexName)
446
	}
447
448
	if r.Projection.hasValue() {
449
		v := r.Projection.ToSDK()
450
		o.Projection = &v
451
	}
452
	if r.ProvisionedThroughput.hasValue() {
453
		v := r.ProvisionedThroughput.ToSDK()
454
		o.ProvisionedThroughput = &v
455
	}
456
457
	if len(r.KeySchema) != 0 {
458
		list := make([]SDK.KeySchemaElement, len(r.KeySchema))
459
		for i, v := range r.KeySchema {
460
			list[i] = v.ToSDK()
461
		}
462
		o.KeySchema = list
463
	}
464
	return o
465
}
466
467
// 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...
468
type GlobalSecondaryIndexDescription struct {
469
	Backfilling           bool
470
	IndexARN              string
471
	IndexName             string
472
	IndexSizeBytes        int64
473
	IndexStatus           IndexStatus
474
	ItemCount             int64
475
	KeySchema             []KeySchemaElement
476
	Projection            Projection
477
	ProvisionedThroughput ProvisionedThroughputDescription
478
}
479
480
func newGlobalSecondaryIndexDescriptions(list []SDK.GlobalSecondaryIndexDescription) []GlobalSecondaryIndexDescription {
481
	if len(list) == 0 {
482
		return nil
483
	}
484
485
	result := make([]GlobalSecondaryIndexDescription, len(list))
486
	for i, v := range list {
487
		result[i] = newGlobalSecondaryIndexDescription(v)
488
	}
489
	return result
490
}
491
492
func newGlobalSecondaryIndexDescription(o SDK.GlobalSecondaryIndexDescription) GlobalSecondaryIndexDescription {
493
	result := GlobalSecondaryIndexDescription{}
494
495
	if o.Backfilling != nil {
496
		result.Backfilling = *o.Backfilling
497
	}
498
	if o.IndexArn != nil {
499
		result.IndexARN = *o.IndexArn
500
	}
501
	if o.IndexName != nil {
502
		result.IndexName = *o.IndexName
503
	}
504
	if o.IndexSizeBytes != nil {
505
		result.IndexSizeBytes = *o.IndexSizeBytes
506
	}
507
	if o.ItemCount != nil {
508
		result.ItemCount = *o.ItemCount
509
	}
510
511
	result.IndexStatus = IndexStatus(o.IndexStatus)
512
513
	result.KeySchema = newKeySchemaElements(o.KeySchema)
514
	result.Projection = newProjection(o.Projection)
515
	result.ProvisionedThroughput = newProvisionedThroughputDescription(o.ProvisionedThroughput)
516
	return result
517
}
518
519
type ItemCollectionMetrics struct {
0 ignored issues
show
introduced by
exported type ItemCollectionMetrics should have comment or be unexported
Loading history...
520
	ItemCollectionKey   map[string]AttributeValue `type:"map"`
521
	SizeEstimateRangeGB []float64                 `type:"list"`
522
}
523
524
func newItemCollectionMetrics(o SDK.ItemCollectionMetrics) ItemCollectionMetrics {
525
	result := ItemCollectionMetrics{}
526
527
	m := make(map[string]AttributeValue, len(o.ItemCollectionKey))
528
	for key, val := range o.ItemCollectionKey {
529
		m[key] = newAttributeValue(val)
530
	}
531
	result.ItemCollectionKey = m
532
533
	result.SizeEstimateRangeGB = o.SizeEstimateRangeGB
534
	return result
535
}
536
537
type KeysAndAttributes struct {
0 ignored issues
show
introduced by
exported type KeysAndAttributes should have comment or be unexported
Loading history...
538
	Keys []map[string]AttributeValue
539
540
	// optional
541
	AttributesToGet          []string
542
	ConsistentRead           bool
543
	ExpressionAttributeNames map[string]string
544
	ProjectionExpression     string
545
}
546
547
func newKeysAndAttributes(o SDK.KeysAndAttributes) KeysAndAttributes {
548
	result := KeysAndAttributes{}
549
550
	result.AttributesToGet = o.AttributesToGet
551
	result.ExpressionAttributeNames = o.ExpressionAttributeNames
552
553
	if o.ConsistentRead != nil {
554
		result.ConsistentRead = *o.ConsistentRead
555
	}
556
	if o.ProjectionExpression != nil {
557
		result.ProjectionExpression = *o.ProjectionExpression
558
	}
559
560
	if len(o.Keys) != 0 {
561
		list := make([]map[string]AttributeValue, len(o.Keys))
562
		for i, v := range o.Keys {
563
			list[i] = newAttributeValueMap(v)
564
		}
565
		result.Keys = list
566
	}
567
568
	return result
569
}
570
571
func (r KeysAndAttributes) ToSDK() SDK.KeysAndAttributes {
0 ignored issues
show
introduced by
exported method KeysAndAttributes.ToSDK should have comment or be unexported
Loading history...
572
	o := SDK.KeysAndAttributes{}
573
574
	if len(r.Keys) != 0 {
575
		list := make([]map[string]SDK.AttributeValue, len(r.Keys))
576
		for i, v := range r.Keys {
577
			m := make(map[string]SDK.AttributeValue, len(v))
578
			for key, val := range v {
579
				m[key] = val.ToSDK()
580
			}
581
			list[i] = m
582
		}
583
		o.Keys = list
584
	}
585
586
	if r.ConsistentRead {
587
		o.ConsistentRead = pointers.Bool(r.ConsistentRead)
588
	}
589
	if r.ProjectionExpression != "" {
590
		o.ProjectionExpression = pointers.String(r.ProjectionExpression)
591
	}
592
593
	o.AttributesToGet = r.AttributesToGet
594
	o.ExpressionAttributeNames = r.ExpressionAttributeNames
595
	return o
596
}
597
598
type KeySchemaElement struct {
0 ignored issues
show
introduced by
exported type KeySchemaElement should have comment or be unexported
Loading history...
599
	AttributeName string
600
	KeyType       KeyType
601
}
602
603
func newKeySchemaElements(list []SDK.KeySchemaElement) []KeySchemaElement {
604
	if len(list) == 0 {
605
		return nil
606
	}
607
608
	results := make([]KeySchemaElement, len(list))
609
	for i, v := range list {
610
		results[i] = newKeySchemaElement(v)
611
	}
612
	return results
613
}
614
615
func newKeySchemaElement(o SDK.KeySchemaElement) KeySchemaElement {
616
	result := KeySchemaElement{}
617
618
	if o.AttributeName != nil {
619
		result.AttributeName = *o.AttributeName
620
	}
621
622
	result.KeyType = KeyType(o.KeyType)
623
	return result
624
}
625
626
func (r KeySchemaElement) ToSDK() SDK.KeySchemaElement {
0 ignored issues
show
introduced by
exported method KeySchemaElement.ToSDK should have comment or be unexported
Loading history...
627
	o := SDK.KeySchemaElement{}
628
629
	if r.AttributeName != "" {
630
		o.AttributeName = pointers.String(r.AttributeName)
631
	}
632
	o.KeyType = SDK.KeyType(r.KeyType)
633
	return o
634
}
635
636
type LocalSecondaryIndex struct {
0 ignored issues
show
introduced by
exported type LocalSecondaryIndex should have comment or be unexported
Loading history...
637
	IndexName  string
638
	KeySchema  []KeySchemaElement
639
	Projection Projection
640
}
641
642
func (r LocalSecondaryIndex) ToSDK() SDK.LocalSecondaryIndex {
0 ignored issues
show
introduced by
exported method LocalSecondaryIndex.ToSDK should have comment or be unexported
Loading history...
643
	o := SDK.LocalSecondaryIndex{}
644
645
	if r.IndexName != "" {
646
		o.IndexName = pointers.String(r.IndexName)
647
	}
648
649
	if r.Projection.hasValue() {
650
		v := r.Projection.ToSDK()
651
		o.Projection = &v
652
	}
653
654
	if len(r.KeySchema) != 0 {
655
		list := make([]SDK.KeySchemaElement, len(r.KeySchema))
656
		for i, v := range r.KeySchema {
657
			list[i] = v.ToSDK()
658
		}
659
		o.KeySchema = list
660
	}
661
	return o
662
}
663
664
type LocalSecondaryIndexDescription struct {
0 ignored issues
show
introduced by
exported type LocalSecondaryIndexDescription should have comment or be unexported
Loading history...
665
	IndexARN       string
666
	IndexName      string
667
	IndexSizeBytes int64
668
	ItemCount      int64
669
	KeySchema      []KeySchemaElement
670
	Projection     Projection
671
}
672
673
func newLocalSecondaryIndexDescriptions(list []SDK.LocalSecondaryIndexDescription) []LocalSecondaryIndexDescription {
674
	if len(list) == 0 {
675
		return nil
676
	}
677
678
	result := make([]LocalSecondaryIndexDescription, len(list))
679
	for i, v := range list {
680
		result[i] = newLocalSecondaryIndexDescription(v)
681
	}
682
	return result
683
}
684
685
func newLocalSecondaryIndexDescription(o SDK.LocalSecondaryIndexDescription) LocalSecondaryIndexDescription {
686
	result := LocalSecondaryIndexDescription{}
687
688
	if o.IndexArn != nil {
689
		result.IndexARN = *o.IndexArn
690
	}
691
	if o.IndexName != nil {
692
		result.IndexName = *o.IndexName
693
	}
694
	if o.IndexSizeBytes != nil {
695
		result.IndexSizeBytes = *o.IndexSizeBytes
696
	}
697
	if o.ItemCount != nil {
698
		result.ItemCount = *o.ItemCount
699
	}
700
701
	result.KeySchema = newKeySchemaElements(o.KeySchema)
702
	result.Projection = newProjection(o.Projection)
703
	return result
704
}
705
706
type Projection struct {
0 ignored issues
show
introduced by
exported type Projection should have comment or be unexported
Loading history...
707
	NonKeyAttributes []string
708
	ProjectionType   ProjectionType
709
}
710
711
func newProjection(o *SDK.Projection) Projection {
712
	result := Projection{}
713
	if o == nil {
714
		return result
715
	}
716
717
	result.NonKeyAttributes = o.NonKeyAttributes
718
	result.ProjectionType = ProjectionType(o.ProjectionType)
719
	return result
720
}
721
722
func (r Projection) ToSDK() SDK.Projection {
0 ignored issues
show
introduced by
exported method Projection.ToSDK should have comment or be unexported
Loading history...
723
	o := SDK.Projection{}
724
	o.NonKeyAttributes = r.NonKeyAttributes
725
	o.ProjectionType = SDK.ProjectionType(r.ProjectionType)
726
	return o
727
}
728
729
func (r Projection) hasValue() bool {
730
	switch {
731
	case r.ProjectionType != "",
732
		len(r.NonKeyAttributes) != 0:
733
		return true
734
	}
735
	return false
736
}
737
738
type ProvisionedThroughput struct {
0 ignored issues
show
introduced by
exported type ProvisionedThroughput should have comment or be unexported
Loading history...
739
	ReadCapacityUnits  int64
740
	WriteCapacityUnits int64
741
}
742
743
func (r ProvisionedThroughput) ToSDK() SDK.ProvisionedThroughput {
0 ignored issues
show
introduced by
exported method ProvisionedThroughput.ToSDK should have comment or be unexported
Loading history...
744
	return SDK.ProvisionedThroughput{
745
		ReadCapacityUnits:  pointers.Long64(r.ReadCapacityUnits),
746
		WriteCapacityUnits: pointers.Long64(r.WriteCapacityUnits),
747
	}
748
}
749
750
func (r ProvisionedThroughput) hasValue() bool {
751
	switch {
752
	case r.ReadCapacityUnits != 0,
753
		r.WriteCapacityUnits != 0:
754
		return true
755
	}
756
	return false
757
}
758
759
type ProvisionedThroughputDescription struct {
0 ignored issues
show
introduced by
exported type ProvisionedThroughputDescription should have comment or be unexported
Loading history...
760
	LastDecreaseDateTime   time.Time
761
	LastIncreaseDateTime   time.Time
762
	NumberOfDecreasesToday int64
763
	ReadCapacityUnits      int64
764
	WriteCapacityUnits     int64
765
}
766
767
func newProvisionedThroughputDescription(o *SDK.ProvisionedThroughputDescription) ProvisionedThroughputDescription {
768
	result := ProvisionedThroughputDescription{}
769
	if o == nil {
770
		return result
771
	}
772
773
	if o.LastDecreaseDateTime != nil {
774
		result.LastDecreaseDateTime = *o.LastDecreaseDateTime
775
	}
776
	if o.LastIncreaseDateTime != nil {
777
		result.LastIncreaseDateTime = *o.LastIncreaseDateTime
778
	}
779
	if o.NumberOfDecreasesToday != nil {
780
		result.NumberOfDecreasesToday = *o.NumberOfDecreasesToday
781
	}
782
	if o.ReadCapacityUnits != nil {
783
		result.ReadCapacityUnits = *o.ReadCapacityUnits
784
	}
785
	if o.WriteCapacityUnits != nil {
786
		result.WriteCapacityUnits = *o.WriteCapacityUnits
787
	}
788
	return result
789
}
790
791
type ReplicaDescription struct {
0 ignored issues
show
introduced by
exported type ReplicaDescription should have comment or be unexported
Loading history...
792
	GlobalSecondaryIndexes       []ReplicaGlobalSecondaryIndexDescription
793
	KMSMasterKeyID               string
794
	RegionName                   string
795
	ReplicaStatus                ReplicaStatus
796
	ReplicaStatusDescription     string
797
	ReplicaStatusPercentProgress string
798
799
	ProvisionedThroughputOverrideRCU int64
800
}
801
802
func newReplicaDescriptions(list []SDK.ReplicaDescription) []ReplicaDescription {
803
	if len(list) == 0 {
804
		return nil
805
	}
806
807
	result := make([]ReplicaDescription, len(list))
808
	for i, v := range list {
809
		result[i] = newReplicaDescription(v)
810
	}
811
	return result
812
}
813
814
func newReplicaDescription(o SDK.ReplicaDescription) ReplicaDescription {
815
	result := ReplicaDescription{}
816
817
	if o.KMSMasterKeyId != nil {
818
		result.KMSMasterKeyID = *o.KMSMasterKeyId
819
	}
820
	if o.RegionName != nil {
821
		result.RegionName = *o.RegionName
822
	}
823
	if o.ReplicaStatusDescription != nil {
824
		result.ReplicaStatusDescription = *o.ReplicaStatusDescription
825
	}
826
	if o.ReplicaStatusPercentProgress != nil {
827
		result.ReplicaStatusPercentProgress = *o.ReplicaStatusPercentProgress
828
	}
829
830
	result.ReplicaStatus = ReplicaStatus(o.ReplicaStatus)
831
832
	result.GlobalSecondaryIndexes = newReplicaGlobalSecondaryIndexDescriptions(o.GlobalSecondaryIndexes)
833
	if v := o.ProvisionedThroughputOverride; v != nil {
834
		if v.ReadCapacityUnits != nil {
835
			result.ProvisionedThroughputOverrideRCU = *v.ReadCapacityUnits
836
		}
837
	}
838
	return result
839
}
840
841
type ReplicaGlobalSecondaryIndexDescription struct {
0 ignored issues
show
introduced by
exported type ReplicaGlobalSecondaryIndexDescription should have comment or be unexported
Loading history...
842
	IndexName                        string
843
	ProvisionedThroughputOverrideRCU int64
844
}
845
846
func newReplicaGlobalSecondaryIndexDescriptions(list []SDK.ReplicaGlobalSecondaryIndexDescription) []ReplicaGlobalSecondaryIndexDescription {
847
	if len(list) == 0 {
848
		return nil
849
	}
850
851
	result := make([]ReplicaGlobalSecondaryIndexDescription, len(list))
852
	for i, v := range list {
853
		result[i] = newReplicaGlobalSecondaryIndexDescription(v)
854
	}
855
	return result
856
}
857
858
func newReplicaGlobalSecondaryIndexDescription(o SDK.ReplicaGlobalSecondaryIndexDescription) ReplicaGlobalSecondaryIndexDescription {
859
	result := ReplicaGlobalSecondaryIndexDescription{}
860
861
	if o.IndexName != nil {
862
		result.IndexName = *o.IndexName
863
	}
864
	if v := o.ProvisionedThroughputOverride; v != nil {
865
		if v.ReadCapacityUnits != nil {
866
			result.ProvisionedThroughputOverrideRCU = *v.ReadCapacityUnits
867
		}
868
	}
869
	return result
870
}
871
872
type RestoreSummary struct {
0 ignored issues
show
introduced by
exported type RestoreSummary should have comment or be unexported
Loading history...
873
	RestoreDateTime   time.Time
874
	RestoreInProgress bool
875
876
	// optional
877
	SourceBackupARN string
878
	SourceTableARN  string
879
}
880
881
func newRestoreSummary(o *SDK.RestoreSummary) RestoreSummary {
882
	result := RestoreSummary{}
883
	if o == nil {
884
		return result
885
	}
886
887
	if o.RestoreDateTime != nil {
888
		result.RestoreDateTime = *o.RestoreDateTime
889
	}
890
	if o.RestoreInProgress != nil {
891
		result.RestoreInProgress = *o.RestoreInProgress
892
	}
893
	if o.SourceBackupArn != nil {
894
		result.SourceBackupARN = *o.SourceBackupArn
895
	}
896
	if o.SourceTableArn != nil {
897
		result.SourceTableARN = *o.SourceTableArn
898
	}
899
	return result
900
}
901
902
type SSEDescription struct {
0 ignored issues
show
introduced by
exported type SSEDescription should have comment or be unexported
Loading history...
903
	InaccessibleEncryptionDateTime time.Time
904
	KMSMasterKeyArn                string
905
	SSEType                        SSEType
906
	Status                         SSEStatus
907
}
908
909
func newSSEDescription(o *SDK.SSEDescription) SSEDescription {
910
	result := SSEDescription{}
911
	if o == nil {
912
		return result
913
	}
914
915
	if o.InaccessibleEncryptionDateTime != nil {
916
		result.InaccessibleEncryptionDateTime = *o.InaccessibleEncryptionDateTime
917
	}
918
	if o.KMSMasterKeyArn != nil {
919
		result.KMSMasterKeyArn = *o.KMSMasterKeyArn
920
	}
921
	result.SSEType = SSEType(o.SSEType)
922
	result.Status = SSEStatus(o.Status)
923
	return result
924
}
925
926
type SSESpecification struct {
0 ignored issues
show
introduced by
exported type SSESpecification should have comment or be unexported
Loading history...
927
	Enabled        bool
928
	KMSMasterKeyID string
929
	SSEType        SSEType
930
}
931
932
func (r SSESpecification) ToSDK() SDK.SSESpecification {
0 ignored issues
show
introduced by
exported method SSESpecification.ToSDK should have comment or be unexported
Loading history...
933
	o := SDK.SSESpecification{}
934
935
	if r.Enabled {
936
		o.Enabled = pointers.Bool(r.Enabled)
937
	}
938
	if r.KMSMasterKeyID != "" {
939
		o.KMSMasterKeyId = pointers.String(r.KMSMasterKeyID)
940
	}
941
	o.SSEType = SDK.SSEType(r.SSEType)
942
	return o
943
}
944
945
func (r SSESpecification) hasValue() bool {
946
	switch {
947
	case r.Enabled,
948
		r.KMSMasterKeyID != "",
949
		r.SSEType != "":
950
		return true
951
	}
952
	return false
953
}
954
955
type StreamSpecification struct {
0 ignored issues
show
introduced by
exported type StreamSpecification should have comment or be unexported
Loading history...
956
	StreamEnabled bool
957
958
	// optional
959
	StreamViewType StreamViewType
960
}
961
962
func newStreamSpecification(o *SDK.StreamSpecification) StreamSpecification {
963
	result := StreamSpecification{}
964
	if o == nil {
965
		return result
966
	}
967
968
	if o.StreamEnabled != nil {
969
		result.StreamEnabled = *o.StreamEnabled
970
	}
971
	result.StreamViewType = StreamViewType(o.StreamViewType)
972
	return result
973
}
974
975
func (r StreamSpecification) ToSDK() SDK.StreamSpecification {
0 ignored issues
show
introduced by
exported method StreamSpecification.ToSDK should have comment or be unexported
Loading history...
976
	o := SDK.StreamSpecification{}
977
978
	if r.StreamEnabled {
979
		o.StreamEnabled = pointers.Bool(r.StreamEnabled)
980
	}
981
982
	o.StreamViewType = SDK.StreamViewType(r.StreamViewType)
983
	return o
984
}
985
986
func (r StreamSpecification) hasValue() bool {
987
	switch {
988
	case r.StreamEnabled,
989
		r.StreamViewType != "":
990
		return true
991
	}
992
	return false
993
}
994
995
type TableDescription struct {
0 ignored issues
show
introduced by
exported type TableDescription should have comment or be unexported
Loading history...
996
	ArchivalSummary        ArchivalSummary
997
	AttributeDefinitions   []AttributeDefinition
998
	BillingModeSummary     BillingModeSummary
999
	CreationDateTime       time.Time
1000
	GlobalSecondaryIndexes []GlobalSecondaryIndexDescription
1001
	GlobalTableVersion     string
1002
	ItemCount              int64
1003
	KeySchema              []KeySchemaElement
1004
	LatestStreamARN        string
1005
	LatestStreamLabel      string
1006
	LocalSecondaryIndexes  []LocalSecondaryIndexDescription
1007
	ProvisionedThroughput  ProvisionedThroughputDescription
1008
	Replicas               []ReplicaDescription
1009
	RestoreSummary         RestoreSummary
1010
	SSEDescription         SSEDescription
1011
	StreamSpecification    StreamSpecification
1012
	TableARN               string
1013
	TableID                string
1014
	TableName              string
1015
	TableSizeBytes         int64
1016
	TableStatus            TableStatus
1017
}
1018
1019
func newTableDescription(o SDK.TableDescription) TableDescription {
1020
	result := TableDescription{}
1021
1022
	if o.CreationDateTime != nil {
1023
		result.CreationDateTime = *o.CreationDateTime
1024
	}
1025
	if o.GlobalTableVersion != nil {
1026
		result.GlobalTableVersion = *o.GlobalTableVersion
1027
	}
1028
	if o.ItemCount != nil {
1029
		result.ItemCount = *o.ItemCount
1030
	}
1031
	if o.LatestStreamArn != nil {
1032
		result.LatestStreamARN = *o.LatestStreamArn
1033
	}
1034
	if o.LatestStreamLabel != nil {
1035
		result.LatestStreamLabel = *o.LatestStreamLabel
1036
	}
1037
	if o.TableArn != nil {
1038
		result.TableARN = *o.TableArn
1039
	}
1040
	if o.TableId != nil {
1041
		result.TableID = *o.TableId
1042
	}
1043
	if o.TableName != nil {
1044
		result.TableName = *o.TableName
1045
	}
1046
	if o.TableSizeBytes != nil {
1047
		result.TableSizeBytes = *o.TableSizeBytes
1048
	}
1049
1050
	result.TableStatus = TableStatus(o.TableStatus)
1051
1052
	result.ArchivalSummary = newArchivalSummary(o.ArchivalSummary)
1053
	result.BillingModeSummary = newBillingModeSummary(o.BillingModeSummary)
1054
	result.ProvisionedThroughput = newProvisionedThroughputDescription(o.ProvisionedThroughput)
1055
	result.RestoreSummary = newRestoreSummary(o.RestoreSummary)
1056
	result.SSEDescription = newSSEDescription(o.SSEDescription)
1057
	result.StreamSpecification = newStreamSpecification(o.StreamSpecification)
1058
1059
	result.AttributeDefinitions = newAttributeDefinitions(o.AttributeDefinitions)
1060
	result.GlobalSecondaryIndexes = newGlobalSecondaryIndexDescriptions(o.GlobalSecondaryIndexes)
1061
	result.LocalSecondaryIndexes = newLocalSecondaryIndexDescriptions(o.LocalSecondaryIndexes)
1062
	result.KeySchema = newKeySchemaElements(o.KeySchema)
1063
	result.Replicas = newReplicaDescriptions(o.Replicas)
1064
	return result
1065
}
1066
1067
type Tag struct {
0 ignored issues
show
introduced by
exported type Tag should have comment or be unexported
Loading history...
1068
	Key   string
1069
	Value string
1070
}
1071
1072
func (r Tag) ToSDK() SDK.Tag {
0 ignored issues
show
introduced by
exported method Tag.ToSDK should have comment or be unexported
Loading history...
1073
	o := SDK.Tag{}
1074
1075
	if r.Key != "" {
1076
		o.Key = pointers.String(r.Key)
1077
	}
1078
	if r.Value != "" {
1079
		o.Value = pointers.String(r.Value)
1080
	}
1081
	return o
1082
}
1083
1084
type WriteRequest struct {
0 ignored issues
show
introduced by
exported type WriteRequest should have comment or be unexported
Loading history...
1085
	DeleteKeys map[string]AttributeValue
1086
	PutItems   map[string]AttributeValue
1087
}
1088
1089
func newWriteRequest(o SDK.WriteRequest) WriteRequest {
1090
	result := WriteRequest{
1091
		DeleteKeys: make(map[string]AttributeValue),
1092
		PutItems:   make(map[string]AttributeValue),
1093
	}
1094
1095
	if o.DeleteRequest != nil {
1096
		m := make(map[string]AttributeValue, len(o.DeleteRequest.Key))
1097
		for key, val := range o.DeleteRequest.Key {
1098
			m[key] = newAttributeValue(val)
1099
		}
1100
		result.DeleteKeys = m
1101
	}
1102
1103
	if o.PutRequest != nil {
1104
		m := make(map[string]AttributeValue, len(o.PutRequest.Item))
1105
		for key, val := range o.PutRequest.Item {
1106
			m[key] = newAttributeValue(val)
1107
		}
1108
		result.DeleteKeys = m
1109
	}
1110
1111
	return result
1112
}
1113
1114
func (r WriteRequest) ToSDK() SDK.WriteRequest {
0 ignored issues
show
introduced by
exported method WriteRequest.ToSDK should have comment or be unexported
Loading history...
1115
	o := SDK.WriteRequest{}
1116
1117
	if len(r.DeleteKeys) != 0 {
1118
		m := make(map[string]SDK.AttributeValue, len(r.DeleteKeys))
1119
		for key, val := range r.DeleteKeys {
1120
			m[key] = val.ToSDK()
1121
		}
1122
		o.DeleteRequest = &SDK.DeleteRequest{
1123
			Key: m,
1124
		}
1125
	}
1126
1127
	if len(r.PutItems) != 0 {
1128
		m := make(map[string]SDK.AttributeValue, len(r.PutItems))
1129
		for key, val := range r.PutItems {
1130
			m[key] = val.ToSDK()
1131
		}
1132
		o.PutRequest = &SDK.PutRequest{
1133
			Item: m,
1134
		}
1135
	}
1136
1137
	return o
1138
}
1139