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

kms.*KMS.CreateAlias   A

Complexity

Conditions 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nop 2
dl 0
loc 10
rs 10
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
// 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())
0 ignored issues
show
introduced by
can't check non-constant format in call to Errorf
Loading history...
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 {
0 ignored issues
show
introduced by
exported method CreateAliasRequest.ToInput should have comment or be unexported
Loading history...
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