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

athena/client_op_start_query_execution.go   A

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 39
dl 0
loc 64
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A athena.StartQueryExecutionRequest.ToInput 0 12 3
A athena.NewStartQueryExecutionResult 0 10 3
A athena.*Athena.StartQueryExecution 0 11 2
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
// StartQueryExecution executes `StartQueryExecution` operation.
13
func (svc *Athena) StartQueryExecution(ctx context.Context, r StartQueryExecutionRequest) (*StartQueryExecutionResult, error) {
14
	out, err := svc.RawStartQueryExecution(ctx, r.ToInput())
15
	if err != nil {
16
		err = svc.errWrap(errors.ErrorData{
17
			Err:          err,
18
			AWSOperation: "StartQueryExecution",
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 NewStartQueryExecutionResult(out), nil
24
}
25
26
// StartQueryExecutionRequest has parameters for `StartQueryExecution` operation.
27
type StartQueryExecutionRequest struct {
28
	QueryString string
29
30
	// optional
31
	ClientRequestToken    string
32
	QueryExecutionContext QueryExecutionContext
33
	ResultConfiguration   ResultConfiguration
34
	WorkGroup             string
35
}
36
37
func (r StartQueryExecutionRequest) ToInput() *SDK.StartQueryExecutionInput {
0 ignored issues
show
introduced by
exported method StartQueryExecutionRequest.ToInput should have comment or be unexported
Loading history...
38
	in := &SDK.StartQueryExecutionInput{}
39
40
	if r.QueryString != "" {
41
		in.QueryString = pointers.String(r.QueryString)
42
	}
43
	if r.WorkGroup != "" {
44
		in.WorkGroup = pointers.String(r.WorkGroup)
45
	}
46
	in.QueryExecutionContext = r.QueryExecutionContext.ToSDK()
47
	in.ResultConfiguration = r.ResultConfiguration.ToSDK()
48
	return in
49
}
50
51
type StartQueryExecutionResult struct {
0 ignored issues
show
introduced by
exported type StartQueryExecutionResult should have comment or be unexported
Loading history...
52
	QueryExecutionID string
53
}
54
55
func NewStartQueryExecutionResult(o *SDK.StartQueryExecutionResponse) *StartQueryExecutionResult {
0 ignored issues
show
introduced by
exported function NewStartQueryExecutionResult should have comment or be unexported
Loading history...
56
	result := &StartQueryExecutionResult{}
57
	if o == nil {
58
		return result
59
	}
60
61
	if o.QueryExecutionId != nil {
62
		result.QueryExecutionID = *o.QueryExecutionId
63
	}
64
	return result
65
}
66