Passed
Push — master ( 0cc65a...2c9229 )
by eval
02:27 queued 43s
created

athena.NewGetQueryResultsResult   A

Complexity

Conditions 5

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 13
nop 1
dl 0
loc 18
rs 9.2833
c 0
b 0
f 0
1
package athena
2
3
import (
4
	"context"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/athena"
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 *Athena) 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
	QueryExecutionID string
29
30
	// optional
31
	MaxResults int64
32
	NextToken  string
33
}
34
35
func (r GetQueryResultsRequest) ToInput() *SDK.GetQueryResultsInput {
0 ignored issues
show
introduced by
exported method GetQueryResultsRequest.ToInput should have comment or be unexported
Loading history...
36
	in := &SDK.GetQueryResultsInput{}
37
38
	if r.QueryExecutionID != "" {
39
		in.QueryExecutionId = pointers.String(r.QueryExecutionID)
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
	return in
48
}
49
50
type GetQueryResultsResult struct {
0 ignored issues
show
introduced by
exported type GetQueryResultsResult should have comment or be unexported
Loading history...
51
	NextToken   string
52
	ResultSet   ResultSet
53
	UpdateCount int64
54
}
55
56
func NewGetQueryResultsResult(o *SDK.GetQueryResultsResponse) *GetQueryResultsResult {
0 ignored issues
show
introduced by
exported function NewGetQueryResultsResult should have comment or be unexported
Loading history...
57
	r := &GetQueryResultsResult{}
58
	if o == nil {
59
		return r
60
	}
61
	if o.GetQueryResultsOutput == nil {
62
		return r
63
	}
64
	oo := o.GetQueryResultsOutput
65
66
	if oo.NextToken != nil {
67
		r.NextToken = *oo.NextToken
68
	}
69
	if oo.UpdateCount != nil {
70
		r.UpdateCount = *oo.UpdateCount
71
	}
72
	r.ResultSet = NewResultSet(oo.ResultSet)
73
	return r
74
}
75