|
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()) |
|
|
|
|
|
|
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 { |
|
|
|
|
|
|
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 { |
|
|
|
|
|
|
41
|
|
|
Results QueryResults |
|
42
|
|
|
StatisticsBytesScanned float64 |
|
43
|
|
|
StatisticsRecordsMatched float64 |
|
44
|
|
|
StatisticsRecordsScanned float64 |
|
45
|
|
|
Status QueryStatus |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
func NewGetQueryResultsResult(o *SDK.GetQueryResultsResponse) *GetQueryResultsResult { |
|
|
|
|
|
|
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
|
|
|
|