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

ssm.NewGetParameterHistoryResult   A

Complexity

Conditions 5

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

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