-
Notifications
You must be signed in to change notification settings - Fork 23
/
type_table_description.go
101 lines (91 loc) · 2.69 KB
/
type_table_description.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package dynamodb
import (
"time"
SDK "github.com/aws/aws-sdk-go/service/dynamodb"
)
// TableDescription represents the properties of a table.
type TableDescription struct {
// IsExist will be true only when the api response contains table data
IsExist bool
ItemCount int64
LatestStreamARN string
LatestStreamLabel string
TableARN string
TableID string
TableName string
TableSizeBytes int64
TableStatus string
CreationDateTime time.Time
AttributeDefinitions []AttributeDefinition
KeySchema []KeySchemaElement
GlobalSecondaryIndexes []GSIDescription
LocalSecondaryIndexes []LSIDescription
ProvisionedThroughput ProvisionedThroughputDescription
BillingModeSummary BillingModeSummary
RestoreSummary RestoreSummary
SSEDescription SSEDescription
StreamSpecification StreamSpecification
}
// NewTableDescription creates TableDescription from SDK's output.
func NewTableDescription(out *SDK.TableDescription) TableDescription {
v := TableDescription{}
if out == nil {
return v
}
v.IsExist = true
if out.ItemCount != nil {
v.ItemCount = *out.ItemCount
}
if out.LatestStreamArn != nil {
v.LatestStreamARN = *out.LatestStreamArn
}
if out.LatestStreamLabel != nil {
v.LatestStreamLabel = *out.LatestStreamLabel
}
if out.TableArn != nil {
v.TableARN = *out.TableArn
}
if out.TableId != nil {
v.TableID = *out.TableId
}
if out.TableName != nil {
v.TableName = *out.TableName
}
if out.TableSizeBytes != nil {
v.TableSizeBytes = *out.TableSizeBytes
}
if out.TableStatus != nil {
v.TableStatus = *out.TableStatus
}
if out.CreationDateTime != nil {
v.CreationDateTime = *out.CreationDateTime
}
v.AttributeDefinitions = NewAttributeDefinitionList(out.AttributeDefinitions)
v.BillingModeSummary = NewBillingModeSummary(out.BillingModeSummary)
v.GlobalSecondaryIndexes = NewGSIDescriptionList(out.GlobalSecondaryIndexes)
v.KeySchema = NewKeySchemaElementList(out.KeySchema)
v.LocalSecondaryIndexes = NewLSIDescriptionList(out.LocalSecondaryIndexes)
v.ProvisionedThroughput = NewProvisionedThroughputDescription(out.ProvisionedThroughput)
v.RestoreSummary = NewRestoreSummary(out.RestoreSummary)
v.StreamSpecification = NewStreamSpecification(out.StreamSpecification)
return v
}
// IsEmpty checks if the data is empty or not.
func (d TableDescription) IsEmpty() bool {
switch {
case d.IsExist,
d.ItemCount != 0,
d.TableSizeBytes != 0,
d.LatestStreamARN != "",
d.LatestStreamLabel != "",
d.TableARN != "",
d.TableID != "",
d.TableName != "",
d.TableStatus != "",
!d.CreationDateTime.IsZero(),
len(d.AttributeDefinitions) != 0,
len(d.KeySchema) != 0:
return false
}
return true
}