Passed
Push — master ( dd6fe7...ccccae )
by eval
02:05
created

sqs/client_op_create_queue.go   A

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 35
dl 0
loc 60
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sqs.CreateQueueRequest.ToInput 0 10 2
A sqs.*SQS.CreateQueue 0 11 2
A sqs.NewCreateQueueResult 0 10 3
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())
0 ignored issues
show
introduced by
can't check non-constant format in call to Errorf
Loading history...
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 {
0 ignored issues
show
introduced by
exported method CreateQueueRequest.ToInput should have comment or be unexported
Loading history...
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 {
0 ignored issues
show
introduced by
exported type CreateQueueResult should have comment or be unexported
Loading history...
48
	QueueURL string
49
}
50
51
func NewCreateQueueResult(o *SDK.CreateQueueResponse) *CreateQueueResult {
0 ignored issues
show
introduced by
exported function NewCreateQueueResult should have comment or be unexported
Loading history...
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