Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package kms |
||
2 | |||
3 | import ( |
||
4 | "context" |
||
5 | "time" |
||
6 | |||
7 | SDK "github.com/aws/aws-sdk-go-v2/service/kms" |
||
8 | |||
9 | "github.com/evalphobia/aws-sdk-go-v2-wrapper/errors" |
||
10 | "github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" |
||
11 | ) |
||
12 | |||
13 | // ScheduleKeyDeletion executes `ScheduleKeyDeletion` operation. |
||
14 | func (svc *KMS) ScheduleKeyDeletion(ctx context.Context, r ScheduleKeyDeletionRequest) (*ScheduleKeyDeletionResult, error) { |
||
15 | out, err := svc.RawScheduleKeyDeletion(ctx, r.ToInput()) |
||
16 | if err != nil { |
||
17 | err = svc.errWrap(errors.ErrorData{ |
||
18 | Err: err, |
||
19 | AWSOperation: "ScheduleKeyDeletion", |
||
20 | }) |
||
21 | svc.Errorf(err.Error()) |
||
|
|||
22 | return nil, err |
||
23 | } |
||
24 | return NewScheduleKeyDeletionResult(out), nil |
||
25 | } |
||
26 | |||
27 | // ScheduleKeyDeletionRequest has parameters for `ScheduleKeyDeletion` operation. |
||
28 | type ScheduleKeyDeletionRequest struct { |
||
29 | KeyID string |
||
30 | |||
31 | // optional |
||
32 | PendingWindowInDays int64 // must be [7 ~ 30] days |
||
33 | } |
||
34 | |||
35 | func (r ScheduleKeyDeletionRequest) ToInput() *SDK.ScheduleKeyDeletionInput { |
||
36 | in := &SDK.ScheduleKeyDeletionInput{} |
||
37 | if r.KeyID != "" { |
||
38 | in.KeyId = pointers.String(r.KeyID) |
||
39 | } |
||
40 | if r.PendingWindowInDays != 0 { |
||
41 | in.PendingWindowInDays = pointers.Long64(r.PendingWindowInDays) |
||
42 | } |
||
43 | return in |
||
44 | } |
||
45 | |||
46 | type ScheduleKeyDeletionResult struct { |
||
47 | DeletionDate time.Time |
||
48 | KeyID string |
||
49 | } |
||
50 | |||
51 | func NewScheduleKeyDeletionResult(output *SDK.ScheduleKeyDeletionResponse) *ScheduleKeyDeletionResult { |
||
52 | r := &ScheduleKeyDeletionResult{} |
||
53 | if output == nil { |
||
54 | return r |
||
55 | } |
||
56 | |||
57 | if output.DeletionDate != nil { |
||
58 | r.DeletionDate = *output.DeletionDate |
||
59 | } |
||
60 | if output.KeyId != nil { |
||
61 | r.KeyID = *output.KeyId |
||
62 | } |
||
63 | return r |
||
64 | } |
||
65 |