Passed
Push — master ( ad04e3...c5b8de )
by eval
01:47
created

cloudwatchlogs.NewGetQueryResultsResult   B

Complexity

Conditions 6

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
nop 1
dl 0
loc 20
rs 8.6666
c 0
b 0
f 0
1
package cloudwatchlogs
2
3
import (
4
	"context"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
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
// GetQueryResults executes `GetQueryResults` operation.
13
func (svc *CloudwatchLogs) GetQueryResults(ctx context.Context, r GetQueryResultsRequest) (*GetQueryResultsResult, error) {
14
	out, err := svc.RawGetQueryResults(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "GetQueryResults",
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 NewGetQueryResultsResult(out), nil
24
}
25
26
// GetQueryResultsRequest has parameters for `GetQueryResults` operation.
27
type GetQueryResultsRequest struct {
28
	QueryID string
29
}
30
31
func (r GetQueryResultsRequest) ToInput() *SDK.GetQueryResultsInput {
0 ignored issues
show
introduced by
exported method GetQueryResultsRequest.ToInput should have comment or be unexported
Loading history...
32
	in := &SDK.GetQueryResultsInput{}
33
34
	if r.QueryID != "" {
35
		in.QueryId = pointers.String(r.QueryID)
36
	}
37
	return in
38
}
39
40
type GetQueryResultsResult struct {
0 ignored issues
show
introduced by
exported type GetQueryResultsResult should have comment or be unexported
Loading history...
41
	Results                  QueryResults
42
	StatisticsBytesScanned   float64
43
	StatisticsRecordsMatched float64
44
	StatisticsRecordsScanned float64
45
	Status                   QueryStatus
46
}
47
48
func NewGetQueryResultsResult(o *SDK.GetQueryResultsResponse) *GetQueryResultsResult {
0 ignored issues
show
introduced by
exported function NewGetQueryResultsResult should have comment or be unexported
Loading history...
49
	r := &GetQueryResultsResult{}
50
	if o == nil {
51
		return r
52
	}
53
	r.Results = NewQueryResults(o.Results)
54
	r.Status = QueryStatus(o.Status)
55
	if o.Statistics != nil {
56
		v := o.Statistics
57
		if v.BytesScanned != nil {
58
			r.StatisticsBytesScanned = *v.BytesScanned
59
		}
60
		if v.RecordsMatched != nil {
61
			r.StatisticsRecordsMatched = *v.RecordsMatched
62
		}
63
		if v.RecordsScanned != nil {
64
			r.StatisticsRecordsScanned = *v.RecordsScanned
65
		}
66
	}
67
	return r
68
}
69