Passed
Pull Request — master (#11)
by eval
01:29
created

kms.*KMS.DescribeKey   A

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 2
dl 0
loc 11
rs 9.95
c 0
b 0
f 0
1
package kms
2
3
import (
4
	"context"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/kms"
7
8
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/errors"
9
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers"
10
)
11
12
// DescribeKey executes `DescribeKey` operation.
13
func (svc *KMS) DescribeKey(ctx context.Context, r DescribeKeyRequest) (*DescribeKeyResult, error) {
14
	out, err := svc.RawDescribeKey(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "DescribeKey",
19
		})
20
		svc.Errorf(err.Error())
0 ignored issues
show
introduced by
can't check non-constant format in call to Errorf
Loading history...
21
		return nil, err
22
	}
23
	return NewDescribeKeyResult(out), nil
24
}
25
26
// DescribeKeyRequest has parameters for `DescribeKey` operation.
27
type DescribeKeyRequest struct {
28
	KeyID string
29
30
	// optional
31
	GrantTokens []string
32
}
33
34
func (r DescribeKeyRequest) ToInput() *SDK.DescribeKeyInput {
0 ignored issues
show
introduced by
exported method DescribeKeyRequest.ToInput should have comment or be unexported
Loading history...
35
	in := &SDK.DescribeKeyInput{}
36
37
	if r.KeyID != "" {
38
		in.KeyId = pointers.String(r.KeyID)
39
	}
40
	in.GrantTokens = r.GrantTokens
41
	return in
42
}
43
44
type DescribeKeyResult struct {
0 ignored issues
show
introduced by
exported type DescribeKeyResult should have comment or be unexported
Loading history...
45
	KeyMetadata KeyMetadata
46
}
47
48
func NewDescribeKeyResult(output *SDK.DescribeKeyResponse) *DescribeKeyResult {
0 ignored issues
show
introduced by
exported function NewDescribeKeyResult should have comment or be unexported
Loading history...
49
	r := &DescribeKeyResult{}
50
	if output == nil {
51
		return r
52
	}
53
54
	r.KeyMetadata = newKeyMetadata(output.KeyMetadata)
55
	return r
56
}
57