github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/requestValidator.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 apigateway
     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  // Manages an API Gateway Request Validator.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			_, err := apigateway.NewRequestValidator(ctx, "example", &apigateway.RequestValidatorArgs{
    33  //				Name:                      pulumi.String("example"),
    34  //				RestApi:                   pulumi.Any(exampleAwsApiGatewayRestApi.Id),
    35  //				ValidateRequestBody:       pulumi.Bool(true),
    36  //				ValidateRequestParameters: pulumi.Bool(true),
    37  //			})
    38  //			if err != nil {
    39  //				return err
    40  //			}
    41  //			return nil
    42  //		})
    43  //	}
    44  //
    45  // ```
    46  // <!--End PulumiCodeChooser -->
    47  //
    48  // ## Import
    49  //
    50  // Using `pulumi import`, import `aws_api_gateway_request_validator` using `REST-API-ID/REQUEST-VALIDATOR-ID`. For example:
    51  //
    52  // ```sh
    53  // $ pulumi import aws:apigateway/requestValidator:RequestValidator example 12345abcde/67890fghij
    54  // ```
    55  type RequestValidator struct {
    56  	pulumi.CustomResourceState
    57  
    58  	// Name of the request validator
    59  	Name pulumi.StringOutput `pulumi:"name"`
    60  	// ID of the associated Rest API
    61  	RestApi pulumi.StringOutput `pulumi:"restApi"`
    62  	// Boolean whether to validate request body. Defaults to `false`.
    63  	ValidateRequestBody pulumi.BoolPtrOutput `pulumi:"validateRequestBody"`
    64  	// Boolean whether to validate request parameters. Defaults to `false`.
    65  	ValidateRequestParameters pulumi.BoolPtrOutput `pulumi:"validateRequestParameters"`
    66  }
    67  
    68  // NewRequestValidator registers a new resource with the given unique name, arguments, and options.
    69  func NewRequestValidator(ctx *pulumi.Context,
    70  	name string, args *RequestValidatorArgs, opts ...pulumi.ResourceOption) (*RequestValidator, error) {
    71  	if args == nil {
    72  		return nil, errors.New("missing one or more required arguments")
    73  	}
    74  
    75  	if args.RestApi == nil {
    76  		return nil, errors.New("invalid value for required argument 'RestApi'")
    77  	}
    78  	opts = internal.PkgResourceDefaultOpts(opts)
    79  	var resource RequestValidator
    80  	err := ctx.RegisterResource("aws:apigateway/requestValidator:RequestValidator", name, args, &resource, opts...)
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  	return &resource, nil
    85  }
    86  
    87  // GetRequestValidator gets an existing RequestValidator resource's state with the given name, ID, and optional
    88  // state properties that are used to uniquely qualify the lookup (nil if not required).
    89  func GetRequestValidator(ctx *pulumi.Context,
    90  	name string, id pulumi.IDInput, state *RequestValidatorState, opts ...pulumi.ResourceOption) (*RequestValidator, error) {
    91  	var resource RequestValidator
    92  	err := ctx.ReadResource("aws:apigateway/requestValidator:RequestValidator", name, id, state, &resource, opts...)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	return &resource, nil
    97  }
    98  
    99  // Input properties used for looking up and filtering RequestValidator resources.
   100  type requestValidatorState struct {
   101  	// Name of the request validator
   102  	Name *string `pulumi:"name"`
   103  	// ID of the associated Rest API
   104  	RestApi interface{} `pulumi:"restApi"`
   105  	// Boolean whether to validate request body. Defaults to `false`.
   106  	ValidateRequestBody *bool `pulumi:"validateRequestBody"`
   107  	// Boolean whether to validate request parameters. Defaults to `false`.
   108  	ValidateRequestParameters *bool `pulumi:"validateRequestParameters"`
   109  }
   110  
   111  type RequestValidatorState struct {
   112  	// Name of the request validator
   113  	Name pulumi.StringPtrInput
   114  	// ID of the associated Rest API
   115  	RestApi pulumi.Input
   116  	// Boolean whether to validate request body. Defaults to `false`.
   117  	ValidateRequestBody pulumi.BoolPtrInput
   118  	// Boolean whether to validate request parameters. Defaults to `false`.
   119  	ValidateRequestParameters pulumi.BoolPtrInput
   120  }
   121  
   122  func (RequestValidatorState) ElementType() reflect.Type {
   123  	return reflect.TypeOf((*requestValidatorState)(nil)).Elem()
   124  }
   125  
   126  type requestValidatorArgs struct {
   127  	// Name of the request validator
   128  	Name *string `pulumi:"name"`
   129  	// ID of the associated Rest API
   130  	RestApi interface{} `pulumi:"restApi"`
   131  	// Boolean whether to validate request body. Defaults to `false`.
   132  	ValidateRequestBody *bool `pulumi:"validateRequestBody"`
   133  	// Boolean whether to validate request parameters. Defaults to `false`.
   134  	ValidateRequestParameters *bool `pulumi:"validateRequestParameters"`
   135  }
   136  
   137  // The set of arguments for constructing a RequestValidator resource.
   138  type RequestValidatorArgs struct {
   139  	// Name of the request validator
   140  	Name pulumi.StringPtrInput
   141  	// ID of the associated Rest API
   142  	RestApi pulumi.Input
   143  	// Boolean whether to validate request body. Defaults to `false`.
   144  	ValidateRequestBody pulumi.BoolPtrInput
   145  	// Boolean whether to validate request parameters. Defaults to `false`.
   146  	ValidateRequestParameters pulumi.BoolPtrInput
   147  }
   148  
   149  func (RequestValidatorArgs) ElementType() reflect.Type {
   150  	return reflect.TypeOf((*requestValidatorArgs)(nil)).Elem()
   151  }
   152  
   153  type RequestValidatorInput interface {
   154  	pulumi.Input
   155  
   156  	ToRequestValidatorOutput() RequestValidatorOutput
   157  	ToRequestValidatorOutputWithContext(ctx context.Context) RequestValidatorOutput
   158  }
   159  
   160  func (*RequestValidator) ElementType() reflect.Type {
   161  	return reflect.TypeOf((**RequestValidator)(nil)).Elem()
   162  }
   163  
   164  func (i *RequestValidator) ToRequestValidatorOutput() RequestValidatorOutput {
   165  	return i.ToRequestValidatorOutputWithContext(context.Background())
   166  }
   167  
   168  func (i *RequestValidator) ToRequestValidatorOutputWithContext(ctx context.Context) RequestValidatorOutput {
   169  	return pulumi.ToOutputWithContext(ctx, i).(RequestValidatorOutput)
   170  }
   171  
   172  // RequestValidatorArrayInput is an input type that accepts RequestValidatorArray and RequestValidatorArrayOutput values.
   173  // You can construct a concrete instance of `RequestValidatorArrayInput` via:
   174  //
   175  //	RequestValidatorArray{ RequestValidatorArgs{...} }
   176  type RequestValidatorArrayInput interface {
   177  	pulumi.Input
   178  
   179  	ToRequestValidatorArrayOutput() RequestValidatorArrayOutput
   180  	ToRequestValidatorArrayOutputWithContext(context.Context) RequestValidatorArrayOutput
   181  }
   182  
   183  type RequestValidatorArray []RequestValidatorInput
   184  
   185  func (RequestValidatorArray) ElementType() reflect.Type {
   186  	return reflect.TypeOf((*[]*RequestValidator)(nil)).Elem()
   187  }
   188  
   189  func (i RequestValidatorArray) ToRequestValidatorArrayOutput() RequestValidatorArrayOutput {
   190  	return i.ToRequestValidatorArrayOutputWithContext(context.Background())
   191  }
   192  
   193  func (i RequestValidatorArray) ToRequestValidatorArrayOutputWithContext(ctx context.Context) RequestValidatorArrayOutput {
   194  	return pulumi.ToOutputWithContext(ctx, i).(RequestValidatorArrayOutput)
   195  }
   196  
   197  // RequestValidatorMapInput is an input type that accepts RequestValidatorMap and RequestValidatorMapOutput values.
   198  // You can construct a concrete instance of `RequestValidatorMapInput` via:
   199  //
   200  //	RequestValidatorMap{ "key": RequestValidatorArgs{...} }
   201  type RequestValidatorMapInput interface {
   202  	pulumi.Input
   203  
   204  	ToRequestValidatorMapOutput() RequestValidatorMapOutput
   205  	ToRequestValidatorMapOutputWithContext(context.Context) RequestValidatorMapOutput
   206  }
   207  
   208  type RequestValidatorMap map[string]RequestValidatorInput
   209  
   210  func (RequestValidatorMap) ElementType() reflect.Type {
   211  	return reflect.TypeOf((*map[string]*RequestValidator)(nil)).Elem()
   212  }
   213  
   214  func (i RequestValidatorMap) ToRequestValidatorMapOutput() RequestValidatorMapOutput {
   215  	return i.ToRequestValidatorMapOutputWithContext(context.Background())
   216  }
   217  
   218  func (i RequestValidatorMap) ToRequestValidatorMapOutputWithContext(ctx context.Context) RequestValidatorMapOutput {
   219  	return pulumi.ToOutputWithContext(ctx, i).(RequestValidatorMapOutput)
   220  }
   221  
   222  type RequestValidatorOutput struct{ *pulumi.OutputState }
   223  
   224  func (RequestValidatorOutput) ElementType() reflect.Type {
   225  	return reflect.TypeOf((**RequestValidator)(nil)).Elem()
   226  }
   227  
   228  func (o RequestValidatorOutput) ToRequestValidatorOutput() RequestValidatorOutput {
   229  	return o
   230  }
   231  
   232  func (o RequestValidatorOutput) ToRequestValidatorOutputWithContext(ctx context.Context) RequestValidatorOutput {
   233  	return o
   234  }
   235  
   236  // Name of the request validator
   237  func (o RequestValidatorOutput) Name() pulumi.StringOutput {
   238  	return o.ApplyT(func(v *RequestValidator) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   239  }
   240  
   241  // ID of the associated Rest API
   242  func (o RequestValidatorOutput) RestApi() pulumi.StringOutput {
   243  	return o.ApplyT(func(v *RequestValidator) pulumi.StringOutput { return v.RestApi }).(pulumi.StringOutput)
   244  }
   245  
   246  // Boolean whether to validate request body. Defaults to `false`.
   247  func (o RequestValidatorOutput) ValidateRequestBody() pulumi.BoolPtrOutput {
   248  	return o.ApplyT(func(v *RequestValidator) pulumi.BoolPtrOutput { return v.ValidateRequestBody }).(pulumi.BoolPtrOutput)
   249  }
   250  
   251  // Boolean whether to validate request parameters. Defaults to `false`.
   252  func (o RequestValidatorOutput) ValidateRequestParameters() pulumi.BoolPtrOutput {
   253  	return o.ApplyT(func(v *RequestValidator) pulumi.BoolPtrOutput { return v.ValidateRequestParameters }).(pulumi.BoolPtrOutput)
   254  }
   255  
   256  type RequestValidatorArrayOutput struct{ *pulumi.OutputState }
   257  
   258  func (RequestValidatorArrayOutput) ElementType() reflect.Type {
   259  	return reflect.TypeOf((*[]*RequestValidator)(nil)).Elem()
   260  }
   261  
   262  func (o RequestValidatorArrayOutput) ToRequestValidatorArrayOutput() RequestValidatorArrayOutput {
   263  	return o
   264  }
   265  
   266  func (o RequestValidatorArrayOutput) ToRequestValidatorArrayOutputWithContext(ctx context.Context) RequestValidatorArrayOutput {
   267  	return o
   268  }
   269  
   270  func (o RequestValidatorArrayOutput) Index(i pulumi.IntInput) RequestValidatorOutput {
   271  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RequestValidator {
   272  		return vs[0].([]*RequestValidator)[vs[1].(int)]
   273  	}).(RequestValidatorOutput)
   274  }
   275  
   276  type RequestValidatorMapOutput struct{ *pulumi.OutputState }
   277  
   278  func (RequestValidatorMapOutput) ElementType() reflect.Type {
   279  	return reflect.TypeOf((*map[string]*RequestValidator)(nil)).Elem()
   280  }
   281  
   282  func (o RequestValidatorMapOutput) ToRequestValidatorMapOutput() RequestValidatorMapOutput {
   283  	return o
   284  }
   285  
   286  func (o RequestValidatorMapOutput) ToRequestValidatorMapOutputWithContext(ctx context.Context) RequestValidatorMapOutput {
   287  	return o
   288  }
   289  
   290  func (o RequestValidatorMapOutput) MapIndex(k pulumi.StringInput) RequestValidatorOutput {
   291  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RequestValidator {
   292  		return vs[0].(map[string]*RequestValidator)[vs[1].(string)]
   293  	}).(RequestValidatorOutput)
   294  }
   295  
   296  func init() {
   297  	pulumi.RegisterInputType(reflect.TypeOf((*RequestValidatorInput)(nil)).Elem(), &RequestValidator{})
   298  	pulumi.RegisterInputType(reflect.TypeOf((*RequestValidatorArrayInput)(nil)).Elem(), RequestValidatorArray{})
   299  	pulumi.RegisterInputType(reflect.TypeOf((*RequestValidatorMapInput)(nil)).Elem(), RequestValidatorMap{})
   300  	pulumi.RegisterOutputType(RequestValidatorOutput{})
   301  	pulumi.RegisterOutputType(RequestValidatorArrayOutput{})
   302  	pulumi.RegisterOutputType(RequestValidatorMapOutput{})
   303  }