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

ssm.DescribeParametersRequest.ToInput   A

Complexity

Conditions 5

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 12
nop 0
dl 0
loc 16
rs 9.3333
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
// DescribeParameters executes `DescribeParameters` operation.
13
func (svc *SSM) DescribeParameters(ctx context.Context, r DescribeParametersRequest) (*DescribeParametersResult, error) {
14
	out, err := svc.RawDescribeParameters(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "DescribeParameters",
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 NewDescribeParametersResult(out), err
24
}
25
26
// DescribeParametersRequest has parameters for `DescribeParameters` operation.
27
type DescribeParametersRequest struct {
28
	MaxResults       int64
29
	NextToken        string
30
	ParameterFilters []ParameterStringFilter
31
}
32
33
func (r DescribeParametersRequest) ToInput() *SDK.DescribeParametersInput {
0 ignored issues
show
introduced by
exported method DescribeParametersRequest.ToInput should have comment or be unexported
Loading history...
34
	in := &SDK.DescribeParametersInput{}
35
	if r.MaxResults != 0 {
36
		in.MaxResults = pointers.Long64(r.MaxResults)
37
	}
38
	if r.NextToken != "" {
39
		in.NextToken = pointers.String(r.NextToken)
40
	}
41
	if len(r.ParameterFilters) != 0 {
42
		list := make([]SDK.ParameterStringFilter, len(r.ParameterFilters))
43
		for i, v := range r.ParameterFilters {
44
			list[i] = v.ToSDK()
45
		}
46
		in.ParameterFilters = list
47
	}
48
	return in
49
}
50
51
type DescribeParametersResult struct {
0 ignored issues
show
introduced by
exported type DescribeParametersResult should have comment or be unexported
Loading history...
52
	NextToken  string
53
	Parameters []ParameterMetadata
54
}
55
56
func NewDescribeParametersResult(o *SDK.DescribeParametersResponse) *DescribeParametersResult {
0 ignored issues
show
introduced by
exported function NewDescribeParametersResult should have comment or be unexported
Loading history...
57
	result := &DescribeParametersResult{}
58
	if o == nil {
59
		return result
60
	}
61
62
	if o.NextToken != nil {
63
		result.NextToken = *o.NextToken
64
	}
65
	if len(o.Parameters) != 0 {
66
		list := make([]ParameterMetadata, len(o.Parameters))
67
		for i := range o.Parameters {
68
			list[i] = newParameterMetadata(o.Parameters[i])
69
		}
70
		result.Parameters = list
71
	}
72
	return result
73
}
74