Total Lines | 39 |
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 | // CreateAlias executes `CreateAlias` operation. |
||
13 | func (svc *KMS) CreateAlias(ctx context.Context, r CreateAliasRequest) error { |
||
14 | _, err := svc.RawCreateAlias(ctx, r.ToInput()) |
||
15 | if err != nil { |
||
16 | err = svc.errWrap(errors.ErrorData{ |
||
17 | Err: err, |
||
18 | AWSOperation: "CreateAlias", |
||
19 | }) |
||
20 | svc.Errorf(err.Error()) |
||
|
|||
21 | } |
||
22 | return err |
||
23 | } |
||
24 | |||
25 | // CreateAliasRequest has parameters for `CreateAlias` operation. |
||
26 | type CreateAliasRequest struct { |
||
27 | AliasName string |
||
28 | TargetKeyID string |
||
29 | } |
||
30 | |||
31 | func (r CreateAliasRequest) ToInput() *SDK.CreateAliasInput { |
||
32 | in := &SDK.CreateAliasInput{} |
||
33 | if r.AliasName != "" { |
||
34 | in.AliasName = pointers.String(r.AliasName) |
||
35 | } |
||
36 | if r.TargetKeyID != "" { |
||
37 | in.TargetKeyId = pointers.String(r.TargetKeyID) |
||
38 | } |
||
39 | return in |
||
40 | } |
||
41 |