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

sqs.GetQueueAttributesRequest.ToInput   A

Complexity

Conditions 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nop 0
dl 0
loc 15
rs 9.9
c 0
b 0
f 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
// GetQueueAttributes executes `GetQueueAttributes` operation.
13
func (svc *SQS) GetQueueAttributes(ctx context.Context, r GetQueueAttributesRequest) (*GetQueueAttributesResult, error) {
14
	out, err := svc.RawGetQueueAttributes(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "GetQueueAttributes",
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 NewGetQueueAttributesResult(out), nil
24
}
25
26
// GetQueueAttributesRequest has parameters for `GetQueueAttributes` operation.
27
type GetQueueAttributesRequest struct {
28
	QueueURL string
29
30
	// optional
31
	AttributeNames []QueueAttributeName
32
}
33
34
func (r GetQueueAttributesRequest) ToInput() *SDK.GetQueueAttributesInput {
0 ignored issues
show
introduced by
exported method GetQueueAttributesRequest.ToInput should have comment or be unexported
Loading history...
35
	in := &SDK.GetQueueAttributesInput{}
36
37
	if r.QueueURL != "" {
38
		in.QueueUrl = pointers.String(r.QueueURL)
39
	}
40
41
	if len(r.AttributeNames) != 0 {
42
		list := make([]SDK.QueueAttributeName, len(r.AttributeNames))
43
		for i, v := range r.AttributeNames {
44
			list[i] = SDK.QueueAttributeName(v)
45
		}
46
		in.AttributeNames = list
47
	}
48
	return in
49
}
50
51
type GetQueueAttributesResult struct {
0 ignored issues
show
introduced by
exported type GetQueueAttributesResult should have comment or be unexported
Loading history...
52
	Attributes map[string]string
53
}
54
55
func NewGetQueueAttributesResult(o *SDK.GetQueueAttributesResponse) *GetQueueAttributesResult {
0 ignored issues
show
introduced by
exported function NewGetQueueAttributesResult should have comment or be unexported
Loading history...
56
	result := &GetQueueAttributesResult{}
57
	if o == nil {
58
		return result
59
	}
60
61
	result.Attributes = o.Attributes
62
	return result
63
}
64