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

athena.NewGetQueryExecutionResult   B

Complexity

Conditions 7

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 22
nop 1
dl 0
loc 30
rs 7.952
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
// GetQueryExecution executes `GetQueryExecution` operation.
13
func (svc *Athena) GetQueryExecution(ctx context.Context, r GetQueryExecutionRequest) (*GetQueryExecutionResult, error) {
14
	out, err := svc.RawGetQueryExecution(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "GetQueryExecution",
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 NewGetQueryExecutionResult(out), nil
24
}
25
26
// GetQueryExecutionRequest has parameters for `GetQueryExecution` operation.
27
type GetQueryExecutionRequest struct {
28
	QueryExecutionID string
29
}
30
31
func (r GetQueryExecutionRequest) ToInput() *SDK.GetQueryExecutionInput {
0 ignored issues
show
introduced by
exported method GetQueryExecutionRequest.ToInput should have comment or be unexported
Loading history...
32
	in := &SDK.GetQueryExecutionInput{}
33
34
	if r.QueryExecutionID != "" {
35
		in.QueryExecutionId = pointers.String(r.QueryExecutionID)
36
	}
37
	return in
38
}
39
40
type GetQueryExecutionResult struct {
0 ignored issues
show
introduced by
exported type GetQueryExecutionResult should have comment or be unexported
Loading history...
41
	Query                 string
42
	QueryExecutionContext QueryExecutionContext
43
	QueryExecutionID      string
44
	ResultConfiguration   ResultConfiguration
45
	StatementType         StatementType
46
	Statistics            QueryExecutionStatistics
47
	Status                QueryExecutionStatus
48
	WorkGroup             string
49
}
50
51
func NewGetQueryExecutionResult(o *SDK.GetQueryExecutionResponse) *GetQueryExecutionResult {
0 ignored issues
show
introduced by
exported function NewGetQueryExecutionResult should have comment or be unexported
Loading history...
52
	r := &GetQueryExecutionResult{}
53
	if o == nil {
54
		return r
55
	}
56
	oo := o.GetQueryExecutionOutput
57
	if oo == nil {
58
		return r
59
	}
60
	v := oo.QueryExecution
61
	if v == nil {
62
		return r
63
	}
64
65
	if v.Query != nil {
66
		r.Query = *v.Query
67
	}
68
	if v.QueryExecutionId != nil {
69
		r.QueryExecutionID = *v.QueryExecutionId
70
	}
71
	if v.WorkGroup != nil {
72
		r.WorkGroup = *v.WorkGroup
73
	}
74
75
	r.QueryExecutionContext = NewQueryExecutionContext(v.QueryExecutionContext)
76
	r.ResultConfiguration = NewResultConfiguration(v.ResultConfiguration)
77
	r.Statistics = NewQueryExecutionStatistics(v.Statistics)
78
	r.Status = NewQueryExecutionStatus(v.Status)
79
	r.StatementType = StatementType(v.StatementType)
80
	return r
81
}
82