1
|
|
|
package kms |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"time" |
5
|
|
|
|
6
|
|
|
SDK "github.com/aws/aws-sdk-go-v2/service/kms" |
7
|
|
|
|
8
|
|
|
"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
9
|
|
|
) |
10
|
|
|
|
11
|
|
|
type KeyMetadata struct { |
|
|
|
|
12
|
|
|
KeyID string |
13
|
|
|
|
14
|
|
|
// optional |
15
|
|
|
AWSAccountID string |
16
|
|
|
ARN string |
17
|
|
|
CloudHsmClusterID string |
18
|
|
|
CreationDate time.Time |
19
|
|
|
CustomKeyStoreID string |
20
|
|
|
CustomerMasterKeySpec CustomerMasterKeySpec |
21
|
|
|
DeletionDate time.Time |
22
|
|
|
Description string |
23
|
|
|
Enabled bool |
24
|
|
|
EncryptionAlgorithms []EncryptionAlgorithmSpec |
25
|
|
|
ExpirationModel ExpirationModelType |
26
|
|
|
KeyManager KeyManagerType |
27
|
|
|
KeyState KeyState |
28
|
|
|
KeyUsage KeyUsageType |
29
|
|
|
Origin OriginType |
30
|
|
|
SigningAlgorithms []SigningAlgorithmSpec |
31
|
|
|
ValidTo time.Time |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
func newKeyMetadata(o *SDK.KeyMetadata) KeyMetadata { |
35
|
|
|
result := KeyMetadata{} |
36
|
|
|
if o == nil { |
37
|
|
|
return result |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if o.KeyId != nil { |
41
|
|
|
result.KeyID = *o.KeyId |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if o.AWSAccountId != nil { |
45
|
|
|
result.AWSAccountID = *o.AWSAccountId |
46
|
|
|
} |
47
|
|
|
if o.Arn != nil { |
48
|
|
|
result.ARN = *o.Arn |
49
|
|
|
} |
50
|
|
|
if o.CloudHsmClusterId != nil { |
51
|
|
|
result.CloudHsmClusterID = *o.CloudHsmClusterId |
52
|
|
|
} |
53
|
|
|
if o.CreationDate != nil { |
54
|
|
|
result.CreationDate = *o.CreationDate |
55
|
|
|
} |
56
|
|
|
if o.CustomKeyStoreId != nil { |
57
|
|
|
result.CustomKeyStoreID = *o.CustomKeyStoreId |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
o.CustomerMasterKeySpec = SDK.CustomerMasterKeySpec(result.CustomerMasterKeySpec) |
61
|
|
|
|
62
|
|
|
if o.DeletionDate != nil { |
63
|
|
|
result.DeletionDate = *o.DeletionDate |
64
|
|
|
} |
65
|
|
|
if o.Description != nil { |
66
|
|
|
result.Description = *o.Description |
67
|
|
|
} |
68
|
|
|
if o.Enabled != nil { |
69
|
|
|
result.Enabled = *o.Enabled |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if len(o.EncryptionAlgorithms) != 0 { |
73
|
|
|
list := make([]EncryptionAlgorithmSpec, len(o.EncryptionAlgorithms)) |
74
|
|
|
for i, v := range o.EncryptionAlgorithms { |
75
|
|
|
list[i] = EncryptionAlgorithmSpec(v) |
76
|
|
|
} |
77
|
|
|
result.EncryptionAlgorithms = list |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
o.ExpirationModel = SDK.ExpirationModelType(result.ExpirationModel) |
81
|
|
|
o.KeyManager = SDK.KeyManagerType(result.KeyManager) |
82
|
|
|
o.KeyState = SDK.KeyState(result.KeyState) |
83
|
|
|
o.KeyUsage = SDK.KeyUsageType(result.KeyUsage) |
84
|
|
|
o.Origin = SDK.OriginType(result.Origin) |
85
|
|
|
|
86
|
|
|
if len(o.SigningAlgorithms) != 0 { |
87
|
|
|
list := make([]SigningAlgorithmSpec, len(o.SigningAlgorithms)) |
88
|
|
|
for i, v := range o.SigningAlgorithms { |
89
|
|
|
list[i] = SigningAlgorithmSpec(v) |
90
|
|
|
} |
91
|
|
|
result.SigningAlgorithms = list |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
if o.ValidTo != nil { |
95
|
|
|
result.ValidTo = *o.ValidTo |
96
|
|
|
} |
97
|
|
|
return result |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
type Tag struct { |
|
|
|
|
101
|
|
|
Key string |
102
|
|
|
Value string |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
func (r Tag) ToSDK() SDK.Tag { |
|
|
|
|
106
|
|
|
return SDK.Tag{ |
107
|
|
|
TagKey: pointers.String(r.Key), |
108
|
|
|
TagValue: pointers.String(r.Value), |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|