Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package sqs |
||
2 | |||
3 | import ( |
||
4 | "context" |
||
5 | |||
6 | SDK "github.com/aws/aws-sdk-go-v2/service/sqs" |
||
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 | // CreateQueue executes `CreateQueue` operation. |
||
13 | func (svc *SQS) CreateQueue(ctx context.Context, r CreateQueueRequest) (*CreateQueueResult, error) { |
||
14 | out, err := svc.RawCreateQueue(ctx, r.ToInput()) |
||
15 | if err != nil { |
||
16 | err = svc.errWrap(errors.ErrorData{ |
||
17 | Err: err, |
||
18 | AWSOperation: "CreateQueue", |
||
19 | }) |
||
20 | svc.Errorf(err.Error()) |
||
|
|||
21 | return nil, err |
||
22 | } |
||
23 | return NewCreateQueueResult(out), nil |
||
24 | } |
||
25 | |||
26 | // CreateQueueRequest has parameters for `CreateQueue` operation. |
||
27 | type CreateQueueRequest struct { |
||
28 | QueueName string |
||
29 | |||
30 | // optional |
||
31 | Attributes map[string]string |
||
32 | Tags map[string]string |
||
33 | } |
||
34 | |||
35 | func (r CreateQueueRequest) ToInput() *SDK.CreateQueueInput { |
||
36 | in := &SDK.CreateQueueInput{} |
||
37 | |||
38 | if r.QueueName != "" { |
||
39 | in.QueueName = pointers.String(r.QueueName) |
||
40 | } |
||
41 | |||
42 | in.Attributes = r.Attributes |
||
43 | in.Tags = r.Tags |
||
44 | return in |
||
45 | } |
||
46 | |||
47 | type CreateQueueResult struct { |
||
48 | QueueURL string |
||
49 | } |
||
50 | |||
51 | func NewCreateQueueResult(o *SDK.CreateQueueResponse) *CreateQueueResult { |
||
52 | result := &CreateQueueResult{} |
||
53 | if o == nil { |
||
54 | return result |
||
55 | } |
||
56 | |||
57 | if o.QueueUrl != nil { |
||
58 | result.QueueURL = *o.QueueUrl |
||
59 | } |
||
60 | return result |
||
61 | } |
||
62 |