github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/athena/preparedStatement.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package athena
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Resource for managing an Athena Prepared Statement.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"fmt"
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/athena"
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			test, err := s3.NewBucketV2(ctx, "test", &s3.BucketV2Args{
    36  //				Bucket:       pulumi.String("tf-test"),
    37  //				ForceDestroy: pulumi.Bool(true),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			testWorkgroup, err := athena.NewWorkgroup(ctx, "test", &athena.WorkgroupArgs{
    43  //				Name: pulumi.String("tf-test"),
    44  //			})
    45  //			if err != nil {
    46  //				return err
    47  //			}
    48  //			testDatabase, err := athena.NewDatabase(ctx, "test", &athena.DatabaseArgs{
    49  //				Name:   pulumi.String("example"),
    50  //				Bucket: test.Bucket,
    51  //			})
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			_, err = athena.NewPreparedStatement(ctx, "test", &athena.PreparedStatementArgs{
    56  //				Name: pulumi.String("tf_test"),
    57  //				QueryStatement: testDatabase.Name.ApplyT(func(name string) (string, error) {
    58  //					return fmt.Sprintf("SELECT * FROM %v WHERE x = ?", name), nil
    59  //				}).(pulumi.StringOutput),
    60  //				Workgroup: testWorkgroup.Name,
    61  //			})
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			return nil
    66  //		})
    67  //	}
    68  //
    69  // ```
    70  // <!--End PulumiCodeChooser -->
    71  //
    72  // ## Import
    73  //
    74  // Using `pulumi import`, import Athena Prepared Statement using the `WORKGROUP-NAME/STATEMENT-NAME`. For example:
    75  //
    76  // ```sh
    77  // $ pulumi import aws:athena/preparedStatement:PreparedStatement example 12345abcde/example
    78  // ```
    79  type PreparedStatement struct {
    80  	pulumi.CustomResourceState
    81  
    82  	// Brief explanation of prepared statement. Maximum length of 1024.
    83  	Description pulumi.StringPtrOutput `pulumi:"description"`
    84  	// The name of the prepared statement. Maximum length of 256.
    85  	Name pulumi.StringOutput `pulumi:"name"`
    86  	// The query string for the prepared statement.
    87  	QueryStatement pulumi.StringOutput `pulumi:"queryStatement"`
    88  	// The name of the workgroup to which the prepared statement belongs.
    89  	Workgroup pulumi.StringOutput `pulumi:"workgroup"`
    90  }
    91  
    92  // NewPreparedStatement registers a new resource with the given unique name, arguments, and options.
    93  func NewPreparedStatement(ctx *pulumi.Context,
    94  	name string, args *PreparedStatementArgs, opts ...pulumi.ResourceOption) (*PreparedStatement, error) {
    95  	if args == nil {
    96  		return nil, errors.New("missing one or more required arguments")
    97  	}
    98  
    99  	if args.QueryStatement == nil {
   100  		return nil, errors.New("invalid value for required argument 'QueryStatement'")
   101  	}
   102  	if args.Workgroup == nil {
   103  		return nil, errors.New("invalid value for required argument 'Workgroup'")
   104  	}
   105  	opts = internal.PkgResourceDefaultOpts(opts)
   106  	var resource PreparedStatement
   107  	err := ctx.RegisterResource("aws:athena/preparedStatement:PreparedStatement", name, args, &resource, opts...)
   108  	if err != nil {
   109  		return nil, err
   110  	}
   111  	return &resource, nil
   112  }
   113  
   114  // GetPreparedStatement gets an existing PreparedStatement resource's state with the given name, ID, and optional
   115  // state properties that are used to uniquely qualify the lookup (nil if not required).
   116  func GetPreparedStatement(ctx *pulumi.Context,
   117  	name string, id pulumi.IDInput, state *PreparedStatementState, opts ...pulumi.ResourceOption) (*PreparedStatement, error) {
   118  	var resource PreparedStatement
   119  	err := ctx.ReadResource("aws:athena/preparedStatement:PreparedStatement", name, id, state, &resource, opts...)
   120  	if err != nil {
   121  		return nil, err
   122  	}
   123  	return &resource, nil
   124  }
   125  
   126  // Input properties used for looking up and filtering PreparedStatement resources.
   127  type preparedStatementState struct {
   128  	// Brief explanation of prepared statement. Maximum length of 1024.
   129  	Description *string `pulumi:"description"`
   130  	// The name of the prepared statement. Maximum length of 256.
   131  	Name *string `pulumi:"name"`
   132  	// The query string for the prepared statement.
   133  	QueryStatement *string `pulumi:"queryStatement"`
   134  	// The name of the workgroup to which the prepared statement belongs.
   135  	Workgroup *string `pulumi:"workgroup"`
   136  }
   137  
   138  type PreparedStatementState struct {
   139  	// Brief explanation of prepared statement. Maximum length of 1024.
   140  	Description pulumi.StringPtrInput
   141  	// The name of the prepared statement. Maximum length of 256.
   142  	Name pulumi.StringPtrInput
   143  	// The query string for the prepared statement.
   144  	QueryStatement pulumi.StringPtrInput
   145  	// The name of the workgroup to which the prepared statement belongs.
   146  	Workgroup pulumi.StringPtrInput
   147  }
   148  
   149  func (PreparedStatementState) ElementType() reflect.Type {
   150  	return reflect.TypeOf((*preparedStatementState)(nil)).Elem()
   151  }
   152  
   153  type preparedStatementArgs struct {
   154  	// Brief explanation of prepared statement. Maximum length of 1024.
   155  	Description *string `pulumi:"description"`
   156  	// The name of the prepared statement. Maximum length of 256.
   157  	Name *string `pulumi:"name"`
   158  	// The query string for the prepared statement.
   159  	QueryStatement string `pulumi:"queryStatement"`
   160  	// The name of the workgroup to which the prepared statement belongs.
   161  	Workgroup string `pulumi:"workgroup"`
   162  }
   163  
   164  // The set of arguments for constructing a PreparedStatement resource.
   165  type PreparedStatementArgs struct {
   166  	// Brief explanation of prepared statement. Maximum length of 1024.
   167  	Description pulumi.StringPtrInput
   168  	// The name of the prepared statement. Maximum length of 256.
   169  	Name pulumi.StringPtrInput
   170  	// The query string for the prepared statement.
   171  	QueryStatement pulumi.StringInput
   172  	// The name of the workgroup to which the prepared statement belongs.
   173  	Workgroup pulumi.StringInput
   174  }
   175  
   176  func (PreparedStatementArgs) ElementType() reflect.Type {
   177  	return reflect.TypeOf((*preparedStatementArgs)(nil)).Elem()
   178  }
   179  
   180  type PreparedStatementInput interface {
   181  	pulumi.Input
   182  
   183  	ToPreparedStatementOutput() PreparedStatementOutput
   184  	ToPreparedStatementOutputWithContext(ctx context.Context) PreparedStatementOutput
   185  }
   186  
   187  func (*PreparedStatement) ElementType() reflect.Type {
   188  	return reflect.TypeOf((**PreparedStatement)(nil)).Elem()
   189  }
   190  
   191  func (i *PreparedStatement) ToPreparedStatementOutput() PreparedStatementOutput {
   192  	return i.ToPreparedStatementOutputWithContext(context.Background())
   193  }
   194  
   195  func (i *PreparedStatement) ToPreparedStatementOutputWithContext(ctx context.Context) PreparedStatementOutput {
   196  	return pulumi.ToOutputWithContext(ctx, i).(PreparedStatementOutput)
   197  }
   198  
   199  // PreparedStatementArrayInput is an input type that accepts PreparedStatementArray and PreparedStatementArrayOutput values.
   200  // You can construct a concrete instance of `PreparedStatementArrayInput` via:
   201  //
   202  //	PreparedStatementArray{ PreparedStatementArgs{...} }
   203  type PreparedStatementArrayInput interface {
   204  	pulumi.Input
   205  
   206  	ToPreparedStatementArrayOutput() PreparedStatementArrayOutput
   207  	ToPreparedStatementArrayOutputWithContext(context.Context) PreparedStatementArrayOutput
   208  }
   209  
   210  type PreparedStatementArray []PreparedStatementInput
   211  
   212  func (PreparedStatementArray) ElementType() reflect.Type {
   213  	return reflect.TypeOf((*[]*PreparedStatement)(nil)).Elem()
   214  }
   215  
   216  func (i PreparedStatementArray) ToPreparedStatementArrayOutput() PreparedStatementArrayOutput {
   217  	return i.ToPreparedStatementArrayOutputWithContext(context.Background())
   218  }
   219  
   220  func (i PreparedStatementArray) ToPreparedStatementArrayOutputWithContext(ctx context.Context) PreparedStatementArrayOutput {
   221  	return pulumi.ToOutputWithContext(ctx, i).(PreparedStatementArrayOutput)
   222  }
   223  
   224  // PreparedStatementMapInput is an input type that accepts PreparedStatementMap and PreparedStatementMapOutput values.
   225  // You can construct a concrete instance of `PreparedStatementMapInput` via:
   226  //
   227  //	PreparedStatementMap{ "key": PreparedStatementArgs{...} }
   228  type PreparedStatementMapInput interface {
   229  	pulumi.Input
   230  
   231  	ToPreparedStatementMapOutput() PreparedStatementMapOutput
   232  	ToPreparedStatementMapOutputWithContext(context.Context) PreparedStatementMapOutput
   233  }
   234  
   235  type PreparedStatementMap map[string]PreparedStatementInput
   236  
   237  func (PreparedStatementMap) ElementType() reflect.Type {
   238  	return reflect.TypeOf((*map[string]*PreparedStatement)(nil)).Elem()
   239  }
   240  
   241  func (i PreparedStatementMap) ToPreparedStatementMapOutput() PreparedStatementMapOutput {
   242  	return i.ToPreparedStatementMapOutputWithContext(context.Background())
   243  }
   244  
   245  func (i PreparedStatementMap) ToPreparedStatementMapOutputWithContext(ctx context.Context) PreparedStatementMapOutput {
   246  	return pulumi.ToOutputWithContext(ctx, i).(PreparedStatementMapOutput)
   247  }
   248  
   249  type PreparedStatementOutput struct{ *pulumi.OutputState }
   250  
   251  func (PreparedStatementOutput) ElementType() reflect.Type {
   252  	return reflect.TypeOf((**PreparedStatement)(nil)).Elem()
   253  }
   254  
   255  func (o PreparedStatementOutput) ToPreparedStatementOutput() PreparedStatementOutput {
   256  	return o
   257  }
   258  
   259  func (o PreparedStatementOutput) ToPreparedStatementOutputWithContext(ctx context.Context) PreparedStatementOutput {
   260  	return o
   261  }
   262  
   263  // Brief explanation of prepared statement. Maximum length of 1024.
   264  func (o PreparedStatementOutput) Description() pulumi.StringPtrOutput {
   265  	return o.ApplyT(func(v *PreparedStatement) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   266  }
   267  
   268  // The name of the prepared statement. Maximum length of 256.
   269  func (o PreparedStatementOutput) Name() pulumi.StringOutput {
   270  	return o.ApplyT(func(v *PreparedStatement) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   271  }
   272  
   273  // The query string for the prepared statement.
   274  func (o PreparedStatementOutput) QueryStatement() pulumi.StringOutput {
   275  	return o.ApplyT(func(v *PreparedStatement) pulumi.StringOutput { return v.QueryStatement }).(pulumi.StringOutput)
   276  }
   277  
   278  // The name of the workgroup to which the prepared statement belongs.
   279  func (o PreparedStatementOutput) Workgroup() pulumi.StringOutput {
   280  	return o.ApplyT(func(v *PreparedStatement) pulumi.StringOutput { return v.Workgroup }).(pulumi.StringOutput)
   281  }
   282  
   283  type PreparedStatementArrayOutput struct{ *pulumi.OutputState }
   284  
   285  func (PreparedStatementArrayOutput) ElementType() reflect.Type {
   286  	return reflect.TypeOf((*[]*PreparedStatement)(nil)).Elem()
   287  }
   288  
   289  func (o PreparedStatementArrayOutput) ToPreparedStatementArrayOutput() PreparedStatementArrayOutput {
   290  	return o
   291  }
   292  
   293  func (o PreparedStatementArrayOutput) ToPreparedStatementArrayOutputWithContext(ctx context.Context) PreparedStatementArrayOutput {
   294  	return o
   295  }
   296  
   297  func (o PreparedStatementArrayOutput) Index(i pulumi.IntInput) PreparedStatementOutput {
   298  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PreparedStatement {
   299  		return vs[0].([]*PreparedStatement)[vs[1].(int)]
   300  	}).(PreparedStatementOutput)
   301  }
   302  
   303  type PreparedStatementMapOutput struct{ *pulumi.OutputState }
   304  
   305  func (PreparedStatementMapOutput) ElementType() reflect.Type {
   306  	return reflect.TypeOf((*map[string]*PreparedStatement)(nil)).Elem()
   307  }
   308  
   309  func (o PreparedStatementMapOutput) ToPreparedStatementMapOutput() PreparedStatementMapOutput {
   310  	return o
   311  }
   312  
   313  func (o PreparedStatementMapOutput) ToPreparedStatementMapOutputWithContext(ctx context.Context) PreparedStatementMapOutput {
   314  	return o
   315  }
   316  
   317  func (o PreparedStatementMapOutput) MapIndex(k pulumi.StringInput) PreparedStatementOutput {
   318  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PreparedStatement {
   319  		return vs[0].(map[string]*PreparedStatement)[vs[1].(string)]
   320  	}).(PreparedStatementOutput)
   321  }
   322  
   323  func init() {
   324  	pulumi.RegisterInputType(reflect.TypeOf((*PreparedStatementInput)(nil)).Elem(), &PreparedStatement{})
   325  	pulumi.RegisterInputType(reflect.TypeOf((*PreparedStatementArrayInput)(nil)).Elem(), PreparedStatementArray{})
   326  	pulumi.RegisterInputType(reflect.TypeOf((*PreparedStatementMapInput)(nil)).Elem(), PreparedStatementMap{})
   327  	pulumi.RegisterOutputType(PreparedStatementOutput{})
   328  	pulumi.RegisterOutputType(PreparedStatementArrayOutput{})
   329  	pulumi.RegisterOutputType(PreparedStatementMapOutput{})
   330  }