/
preparedStatement.go
330 lines (280 loc) · 11.8 KB
/
preparedStatement.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
324
325
326
327
328
329
330
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package athena
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Resource for managing an Athena Prepared Statement.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/athena"
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// test, err := s3.NewBucketV2(ctx, "test", &s3.BucketV2Args{
// Bucket: pulumi.String("tf-test"),
// ForceDestroy: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// testWorkgroup, err := athena.NewWorkgroup(ctx, "test", &athena.WorkgroupArgs{
// Name: pulumi.String("tf-test"),
// })
// if err != nil {
// return err
// }
// testDatabase, err := athena.NewDatabase(ctx, "test", &athena.DatabaseArgs{
// Name: pulumi.String("example"),
// Bucket: test.Bucket,
// })
// if err != nil {
// return err
// }
// _, err = athena.NewPreparedStatement(ctx, "test", &athena.PreparedStatementArgs{
// Name: pulumi.String("tf_test"),
// QueryStatement: testDatabase.Name.ApplyT(func(name string) (string, error) {
// return fmt.Sprintf("SELECT * FROM %v WHERE x = ?", name), nil
// }).(pulumi.StringOutput),
// Workgroup: testWorkgroup.Name,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import Athena Prepared Statement using the `WORKGROUP-NAME/STATEMENT-NAME`. For example:
//
// ```sh
// $ pulumi import aws:athena/preparedStatement:PreparedStatement example 12345abcde/example
// ```
type PreparedStatement struct {
pulumi.CustomResourceState
// Brief explanation of prepared statement. Maximum length of 1024.
Description pulumi.StringPtrOutput `pulumi:"description"`
// The name of the prepared statement. Maximum length of 256.
Name pulumi.StringOutput `pulumi:"name"`
// The query string for the prepared statement.
QueryStatement pulumi.StringOutput `pulumi:"queryStatement"`
// The name of the workgroup to which the prepared statement belongs.
Workgroup pulumi.StringOutput `pulumi:"workgroup"`
}
// NewPreparedStatement registers a new resource with the given unique name, arguments, and options.
func NewPreparedStatement(ctx *pulumi.Context,
name string, args *PreparedStatementArgs, opts ...pulumi.ResourceOption) (*PreparedStatement, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.QueryStatement == nil {
return nil, errors.New("invalid value for required argument 'QueryStatement'")
}
if args.Workgroup == nil {
return nil, errors.New("invalid value for required argument 'Workgroup'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource PreparedStatement
err := ctx.RegisterResource("aws:athena/preparedStatement:PreparedStatement", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetPreparedStatement gets an existing PreparedStatement resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetPreparedStatement(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *PreparedStatementState, opts ...pulumi.ResourceOption) (*PreparedStatement, error) {
var resource PreparedStatement
err := ctx.ReadResource("aws:athena/preparedStatement:PreparedStatement", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering PreparedStatement resources.
type preparedStatementState struct {
// Brief explanation of prepared statement. Maximum length of 1024.
Description *string `pulumi:"description"`
// The name of the prepared statement. Maximum length of 256.
Name *string `pulumi:"name"`
// The query string for the prepared statement.
QueryStatement *string `pulumi:"queryStatement"`
// The name of the workgroup to which the prepared statement belongs.
Workgroup *string `pulumi:"workgroup"`
}
type PreparedStatementState struct {
// Brief explanation of prepared statement. Maximum length of 1024.
Description pulumi.StringPtrInput
// The name of the prepared statement. Maximum length of 256.
Name pulumi.StringPtrInput
// The query string for the prepared statement.
QueryStatement pulumi.StringPtrInput
// The name of the workgroup to which the prepared statement belongs.
Workgroup pulumi.StringPtrInput
}
func (PreparedStatementState) ElementType() reflect.Type {
return reflect.TypeOf((*preparedStatementState)(nil)).Elem()
}
type preparedStatementArgs struct {
// Brief explanation of prepared statement. Maximum length of 1024.
Description *string `pulumi:"description"`
// The name of the prepared statement. Maximum length of 256.
Name *string `pulumi:"name"`
// The query string for the prepared statement.
QueryStatement string `pulumi:"queryStatement"`
// The name of the workgroup to which the prepared statement belongs.
Workgroup string `pulumi:"workgroup"`
}
// The set of arguments for constructing a PreparedStatement resource.
type PreparedStatementArgs struct {
// Brief explanation of prepared statement. Maximum length of 1024.
Description pulumi.StringPtrInput
// The name of the prepared statement. Maximum length of 256.
Name pulumi.StringPtrInput
// The query string for the prepared statement.
QueryStatement pulumi.StringInput
// The name of the workgroup to which the prepared statement belongs.
Workgroup pulumi.StringInput
}
func (PreparedStatementArgs) ElementType() reflect.Type {
return reflect.TypeOf((*preparedStatementArgs)(nil)).Elem()
}
type PreparedStatementInput interface {
pulumi.Input
ToPreparedStatementOutput() PreparedStatementOutput
ToPreparedStatementOutputWithContext(ctx context.Context) PreparedStatementOutput
}
func (*PreparedStatement) ElementType() reflect.Type {
return reflect.TypeOf((**PreparedStatement)(nil)).Elem()
}
func (i *PreparedStatement) ToPreparedStatementOutput() PreparedStatementOutput {
return i.ToPreparedStatementOutputWithContext(context.Background())
}
func (i *PreparedStatement) ToPreparedStatementOutputWithContext(ctx context.Context) PreparedStatementOutput {
return pulumi.ToOutputWithContext(ctx, i).(PreparedStatementOutput)
}
// PreparedStatementArrayInput is an input type that accepts PreparedStatementArray and PreparedStatementArrayOutput values.
// You can construct a concrete instance of `PreparedStatementArrayInput` via:
//
// PreparedStatementArray{ PreparedStatementArgs{...} }
type PreparedStatementArrayInput interface {
pulumi.Input
ToPreparedStatementArrayOutput() PreparedStatementArrayOutput
ToPreparedStatementArrayOutputWithContext(context.Context) PreparedStatementArrayOutput
}
type PreparedStatementArray []PreparedStatementInput
func (PreparedStatementArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*PreparedStatement)(nil)).Elem()
}
func (i PreparedStatementArray) ToPreparedStatementArrayOutput() PreparedStatementArrayOutput {
return i.ToPreparedStatementArrayOutputWithContext(context.Background())
}
func (i PreparedStatementArray) ToPreparedStatementArrayOutputWithContext(ctx context.Context) PreparedStatementArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(PreparedStatementArrayOutput)
}
// PreparedStatementMapInput is an input type that accepts PreparedStatementMap and PreparedStatementMapOutput values.
// You can construct a concrete instance of `PreparedStatementMapInput` via:
//
// PreparedStatementMap{ "key": PreparedStatementArgs{...} }
type PreparedStatementMapInput interface {
pulumi.Input
ToPreparedStatementMapOutput() PreparedStatementMapOutput
ToPreparedStatementMapOutputWithContext(context.Context) PreparedStatementMapOutput
}
type PreparedStatementMap map[string]PreparedStatementInput
func (PreparedStatementMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*PreparedStatement)(nil)).Elem()
}
func (i PreparedStatementMap) ToPreparedStatementMapOutput() PreparedStatementMapOutput {
return i.ToPreparedStatementMapOutputWithContext(context.Background())
}
func (i PreparedStatementMap) ToPreparedStatementMapOutputWithContext(ctx context.Context) PreparedStatementMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(PreparedStatementMapOutput)
}
type PreparedStatementOutput struct{ *pulumi.OutputState }
func (PreparedStatementOutput) ElementType() reflect.Type {
return reflect.TypeOf((**PreparedStatement)(nil)).Elem()
}
func (o PreparedStatementOutput) ToPreparedStatementOutput() PreparedStatementOutput {
return o
}
func (o PreparedStatementOutput) ToPreparedStatementOutputWithContext(ctx context.Context) PreparedStatementOutput {
return o
}
// Brief explanation of prepared statement. Maximum length of 1024.
func (o PreparedStatementOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *PreparedStatement) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// The name of the prepared statement. Maximum length of 256.
func (o PreparedStatementOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *PreparedStatement) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The query string for the prepared statement.
func (o PreparedStatementOutput) QueryStatement() pulumi.StringOutput {
return o.ApplyT(func(v *PreparedStatement) pulumi.StringOutput { return v.QueryStatement }).(pulumi.StringOutput)
}
// The name of the workgroup to which the prepared statement belongs.
func (o PreparedStatementOutput) Workgroup() pulumi.StringOutput {
return o.ApplyT(func(v *PreparedStatement) pulumi.StringOutput { return v.Workgroup }).(pulumi.StringOutput)
}
type PreparedStatementArrayOutput struct{ *pulumi.OutputState }
func (PreparedStatementArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*PreparedStatement)(nil)).Elem()
}
func (o PreparedStatementArrayOutput) ToPreparedStatementArrayOutput() PreparedStatementArrayOutput {
return o
}
func (o PreparedStatementArrayOutput) ToPreparedStatementArrayOutputWithContext(ctx context.Context) PreparedStatementArrayOutput {
return o
}
func (o PreparedStatementArrayOutput) Index(i pulumi.IntInput) PreparedStatementOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PreparedStatement {
return vs[0].([]*PreparedStatement)[vs[1].(int)]
}).(PreparedStatementOutput)
}
type PreparedStatementMapOutput struct{ *pulumi.OutputState }
func (PreparedStatementMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*PreparedStatement)(nil)).Elem()
}
func (o PreparedStatementMapOutput) ToPreparedStatementMapOutput() PreparedStatementMapOutput {
return o
}
func (o PreparedStatementMapOutput) ToPreparedStatementMapOutputWithContext(ctx context.Context) PreparedStatementMapOutput {
return o
}
func (o PreparedStatementMapOutput) MapIndex(k pulumi.StringInput) PreparedStatementOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PreparedStatement {
return vs[0].(map[string]*PreparedStatement)[vs[1].(string)]
}).(PreparedStatementOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*PreparedStatementInput)(nil)).Elem(), &PreparedStatement{})
pulumi.RegisterInputType(reflect.TypeOf((*PreparedStatementArrayInput)(nil)).Elem(), PreparedStatementArray{})
pulumi.RegisterInputType(reflect.TypeOf((*PreparedStatementMapInput)(nil)).Elem(), PreparedStatementMap{})
pulumi.RegisterOutputType(PreparedStatementOutput{})
pulumi.RegisterOutputType(PreparedStatementArrayOutput{})
pulumi.RegisterOutputType(PreparedStatementMapOutput{})
}