-
Notifications
You must be signed in to change notification settings - Fork 623
/
api_op_ExecuteStatement.go
323 lines (265 loc) · 9.92 KB
/
api_op_ExecuteStatement.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package rdsdata
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
"github.com/aws/aws-sdk-go-v2/private/protocol"
)
// The request parameters represent the input of a request to run a SQL statement
// against a database.
type ExecuteStatementInput struct {
_ struct{} `type:"structure"`
// A value that indicates whether to continue running the statement after the
// call times out. By default, the statement stops running when the call times
// out.
//
// For DDL statements, we recommend continuing to run the statement after the
// call times out. When a DDL statement terminates before it is finished running,
// it can result in errors and possibly corrupted data structures.
ContinueAfterTimeout *bool `locationName:"continueAfterTimeout" type:"boolean"`
// The name of the database.
Database *string `locationName:"database" type:"string"`
// A value that indicates whether to include metadata in the results.
IncludeResultMetadata *bool `locationName:"includeResultMetadata" type:"boolean"`
// The parameters for the SQL statement.
Parameters []SqlParameter `locationName:"parameters" type:"list"`
// The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
//
// ResourceArn is a required field
ResourceArn *string `locationName:"resourceArn" min:"11" type:"string" required:"true"`
// Options that control how the result set is returned.
ResultSetOptions *ResultSetOptions `locationName:"resultSetOptions" type:"structure"`
// The name of the database schema.
Schema *string `locationName:"schema" type:"string"`
// The name or ARN of the secret that enables access to the DB cluster.
//
// SecretArn is a required field
SecretArn *string `locationName:"secretArn" min:"11" type:"string" required:"true"`
// The SQL statement to run.
//
// Sql is a required field
Sql *string `locationName:"sql" type:"string" required:"true"`
// The identifier of a transaction that was started by using the BeginTransaction
// operation. Specify the transaction ID of the transaction that you want to
// include the SQL statement in.
//
// If the SQL statement is not part of a transaction, don't set this parameter.
TransactionId *string `locationName:"transactionId" type:"string"`
}
// String returns the string representation
func (s ExecuteStatementInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *ExecuteStatementInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "ExecuteStatementInput"}
if s.ResourceArn == nil {
invalidParams.Add(aws.NewErrParamRequired("ResourceArn"))
}
if s.ResourceArn != nil && len(*s.ResourceArn) < 11 {
invalidParams.Add(aws.NewErrParamMinLen("ResourceArn", 11))
}
if s.SecretArn == nil {
invalidParams.Add(aws.NewErrParamRequired("SecretArn"))
}
if s.SecretArn != nil && len(*s.SecretArn) < 11 {
invalidParams.Add(aws.NewErrParamMinLen("SecretArn", 11))
}
if s.Sql == nil {
invalidParams.Add(aws.NewErrParamRequired("Sql"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s ExecuteStatementInput) MarshalFields(e protocol.FieldEncoder) error {
e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{})
if s.ContinueAfterTimeout != nil {
v := *s.ContinueAfterTimeout
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "continueAfterTimeout", protocol.BoolValue(v), metadata)
}
if s.Database != nil {
v := *s.Database
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "database", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.IncludeResultMetadata != nil {
v := *s.IncludeResultMetadata
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "includeResultMetadata", protocol.BoolValue(v), metadata)
}
if s.Parameters != nil {
v := s.Parameters
metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "parameters", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddFields(v1)
}
ls0.End()
}
if s.ResourceArn != nil {
v := *s.ResourceArn
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "resourceArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.ResultSetOptions != nil {
v := s.ResultSetOptions
metadata := protocol.Metadata{}
e.SetFields(protocol.BodyTarget, "resultSetOptions", v, metadata)
}
if s.Schema != nil {
v := *s.Schema
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "schema", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.SecretArn != nil {
v := *s.SecretArn
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "secretArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.Sql != nil {
v := *s.Sql
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "sql", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
if s.TransactionId != nil {
v := *s.TransactionId
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "transactionId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)
}
return nil
}
// The response elements represent the output of a request to run a SQL statement
// against a database.
type ExecuteStatementOutput struct {
_ struct{} `type:"structure"`
// Metadata for the columns included in the results.
ColumnMetadata []ColumnMetadata `locationName:"columnMetadata" type:"list"`
// Values for fields generated during the request.
//
// <note> <p>The <code>generatedFields</code> data isn't supported by Aurora
// PostgreSQL. To get the values of generated fields, use the <code>RETURNING</code>
// clause. For more information, see <a href="https://www.postgresql.org/docs/10/dml-returning.html">Returning
// Data From Modified Rows</a> in the PostgreSQL documentation.</p> </note>
GeneratedFields []Field `locationName:"generatedFields" type:"list"`
// The number of records updated by the request.
NumberOfRecordsUpdated *int64 `locationName:"numberOfRecordsUpdated" type:"long"`
// The records returned by the SQL statement.
Records [][]Field `locationName:"records" type:"list"`
}
// String returns the string representation
func (s ExecuteStatementOutput) String() string {
return awsutil.Prettify(s)
}
// MarshalFields encodes the AWS API shape using the passed in protocol encoder.
func (s ExecuteStatementOutput) MarshalFields(e protocol.FieldEncoder) error {
if s.ColumnMetadata != nil {
v := s.ColumnMetadata
metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "columnMetadata", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddFields(v1)
}
ls0.End()
}
if s.GeneratedFields != nil {
v := s.GeneratedFields
metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "generatedFields", metadata)
ls0.Start()
for _, v1 := range v {
ls0.ListAddFields(v1)
}
ls0.End()
}
if s.NumberOfRecordsUpdated != nil {
v := *s.NumberOfRecordsUpdated
metadata := protocol.Metadata{}
e.SetValue(protocol.BodyTarget, "numberOfRecordsUpdated", protocol.Int64Value(v), metadata)
}
if s.Records != nil {
v := s.Records
metadata := protocol.Metadata{}
ls0 := e.List(protocol.BodyTarget, "records", metadata)
ls0.Start()
for _, v1 := range v {
ls1 := ls0.List()
ls1.Start()
for _, v2 := range v1 {
ls1.ListAddFields(v2)
}
ls1.End()
}
ls0.End()
}
return nil
}
const opExecuteStatement = "ExecuteStatement"
// ExecuteStatementRequest returns a request value for making API operation for
// AWS RDS DataService.
//
// Runs a SQL statement against a database.
//
// If a call isn't part of a transaction because it doesn't include the transactionID
// parameter, changes that result from the call are committed automatically.
//
// The response size limit is 1 MB or 1,000 records. If the call returns more
// than 1 MB of response data or over 1,000 records, the call is terminated.
//
// // Example sending a request using ExecuteStatementRequest.
// req := client.ExecuteStatementRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-data-2018-08-01/ExecuteStatement
func (c *Client) ExecuteStatementRequest(input *ExecuteStatementInput) ExecuteStatementRequest {
op := &aws.Operation{
Name: opExecuteStatement,
HTTPMethod: "POST",
HTTPPath: "/Execute",
}
if input == nil {
input = &ExecuteStatementInput{}
}
req := c.newRequest(op, input, &ExecuteStatementOutput{})
return ExecuteStatementRequest{Request: req, Input: input, Copy: c.ExecuteStatementRequest}
}
// ExecuteStatementRequest is the request type for the
// ExecuteStatement API operation.
type ExecuteStatementRequest struct {
*aws.Request
Input *ExecuteStatementInput
Copy func(*ExecuteStatementInput) ExecuteStatementRequest
}
// Send marshals and sends the ExecuteStatement API request.
func (r ExecuteStatementRequest) Send(ctx context.Context) (*ExecuteStatementResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &ExecuteStatementResponse{
ExecuteStatementOutput: r.Request.Data.(*ExecuteStatementOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// ExecuteStatementResponse is the response type for the
// ExecuteStatement API operation.
type ExecuteStatementResponse struct {
*ExecuteStatementOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// ExecuteStatement request.
func (r *ExecuteStatementResponse) SDKResponseMetdata() *aws.Response {
return r.response
}