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

ssm.GetParametersByPathRequest.ToInput   B

Complexity

Conditions 8

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 18
nop 0
dl 0
loc 25
rs 7.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
// GetParametersByPath executes `GetParametersByPath` operation.
13
func (svc *SSM) GetParametersByPath(ctx context.Context, r GetParametersByPathRequest) (*GetParametersByPathResult, error) {
14
	out, err := svc.RawGetParametersByPath(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "GetParametersByPath",
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 NewGetParametersByPathResult(out), err
24
}
25
26
// GetParametersByPathRequest has parameters for `GetParametersByPath` operation.
27
type GetParametersByPathRequest struct {
28
	Path string
29
30
	// optional
31
	MaxResults       int64
32
	NextToken        string
33
	ParameterFilters []ParameterStringFilter
34
	Recursive        bool
35
	WithDecryption   bool
36
}
37
38
func (r GetParametersByPathRequest) ToInput() *SDK.GetParametersByPathInput {
0 ignored issues
show
introduced by
exported method GetParametersByPathRequest.ToInput should have comment or be unexported
Loading history...
39
	in := &SDK.GetParametersByPathInput{}
40
	if r.Path != "" {
41
		in.Path = pointers.String(r.Path)
42
	}
43
	if r.MaxResults != 0 {
44
		in.MaxResults = pointers.Long64(r.MaxResults)
45
	}
46
	if r.NextToken != "" {
47
		in.NextToken = pointers.String(r.NextToken)
48
	}
49
	if len(r.ParameterFilters) != 0 {
50
		list := make([]SDK.ParameterStringFilter, len(r.ParameterFilters))
51
		for i, v := range r.ParameterFilters {
52
			list[i] = v.ToSDK()
53
		}
54
		in.ParameterFilters = list
55
	}
56
	if r.Recursive {
57
		in.Recursive = pointers.Bool(r.Recursive)
58
	}
59
	if r.WithDecryption {
60
		in.WithDecryption = pointers.Bool(r.WithDecryption)
61
	}
62
	return in
63
}
64
65
type GetParametersByPathResult struct {
0 ignored issues
show
introduced by
exported type GetParametersByPathResult should have comment or be unexported
Loading history...
66
	NextToken  string
67
	Parameters []Parameter
68
}
69
70
func NewGetParametersByPathResult(o *SDK.GetParametersByPathResponse) *GetParametersByPathResult {
0 ignored issues
show
introduced by
exported function NewGetParametersByPathResult should have comment or be unexported
Loading history...
71
	result := &GetParametersByPathResult{}
72
	if o == nil {
73
		return result
74
	}
75
76
	if o.NextToken != nil {
77
		result.NextToken = *o.NextToken
78
	}
79
80
	if len(o.Parameters) != 0 {
81
		list := make([]Parameter, len(o.Parameters))
82
		for i := range o.Parameters {
83
			list[i] = newParameter(&o.Parameters[i])
84
		}
85
		result.Parameters = list
86
	}
87
	return result
88
}
89