Passed
Push — master ( 44e67e...3437b8 )
by eval
01:37
created

ssm.*SSM.GetParameters   A

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 2
dl 0
loc 11
rs 9.95
c 0
b 0
f 0
1
package ssm
2
3
import (
4
	"context"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/ssm"
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
// GetParameters executes `GetParameters` operation.
13
func (svc *SSM) GetParameters(ctx context.Context, r GetParametersRequest) (*GetParametersResult, error) {
14
	out, err := svc.RawGetParameters(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "GetParameters",
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 NewGetParametersResult(out), err
24
}
25
26
// GetParametersRequest has parameters for `GetParameters` operation.
27
type GetParametersRequest struct {
28
	Names []string
29
30
	// optional
31
	WithDecryption bool
32
}
33
34
func (r GetParametersRequest) ToInput() *SDK.GetParametersInput {
0 ignored issues
show
introduced by
exported method GetParametersRequest.ToInput should have comment or be unexported
Loading history...
35
	in := &SDK.GetParametersInput{}
36
	in.Names = r.Names
37
	if r.WithDecryption {
38
		in.WithDecryption = pointers.Bool(r.WithDecryption)
39
	}
40
	return in
41
}
42
43
type GetParametersResult struct {
0 ignored issues
show
introduced by
exported type GetParametersResult should have comment or be unexported
Loading history...
44
	InvalidParameters []string
45
	Parameters        []Parameter
46
}
47
48
func NewGetParametersResult(o *SDK.GetParametersResponse) *GetParametersResult {
0 ignored issues
show
introduced by
exported function NewGetParametersResult should have comment or be unexported
Loading history...
49
	result := &GetParametersResult{}
50
	if o == nil {
51
		return result
52
	}
53
54
	result.InvalidParameters = o.InvalidParameters
55
	if len(o.Parameters) != 0 {
56
		list := make([]Parameter, len(o.Parameters))
57
		for i := range o.Parameters {
58
			list[i] = newParameter(&o.Parameters[i])
59
		}
60
		result.Parameters = list
61
	}
62
	return result
63
}
64