Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 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()) |
||
|
|||
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 { |
||
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 { |
||
45 | KeyMetadata KeyMetadata |
||
46 | } |
||
47 | |||
48 | func NewDescribeKeyResult(output *SDK.DescribeKeyResponse) *DescribeKeyResult { |
||
49 | r := &DescribeKeyResult{} |
||
50 | if output == nil { |
||
51 | return r |
||
52 | } |
||
53 | |||
54 | r.KeyMetadata = newKeyMetadata(output.KeyMetadata) |
||
55 | return r |
||
56 | } |
||
57 |