kms/type.go   A
last analyzed

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 17
eloc 72
dl 0
loc 108
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
F kms.newKeyMetadata 0 64 16
A kms.Tag.ToSDK 0 4 1
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 {
0 ignored issues
show
introduced by
exported type KeyMetadata should have comment or be unexported
Loading history...
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 {
0 ignored issues
show
introduced by
exported type Tag should have comment or be unexported
Loading history...
101
	Key   string
102
	Value string
103
}
104
105
func (r Tag) ToSDK() SDK.Tag {
0 ignored issues
show
introduced by
exported method Tag.ToSDK should have comment or be unexported
Loading history...
106
	return SDK.Tag{
107
		TagKey:   pointers.String(r.Key),
108
		TagValue: pointers.String(r.Value),
109
	}
110
}
111