github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/integrationResponse.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 // Provides an HTTP Method Integration Response for an API Gateway Resource. 16 // 17 // > **Note:** Depends on having `apigateway.Integration` inside your rest api. To ensure this 18 // you might need to add an explicit `dependsOn` for clean runs. 19 // 20 // ## Example Usage 21 // 22 // <!--Start PulumiCodeChooser --> 23 // ```go 24 // package main 25 // 26 // import ( 27 // 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway" 29 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 30 // 31 // ) 32 // 33 // func main() { 34 // pulumi.Run(func(ctx *pulumi.Context) error { 35 // myDemoAPI, err := apigateway.NewRestApi(ctx, "MyDemoAPI", &apigateway.RestApiArgs{ 36 // Name: pulumi.String("MyDemoAPI"), 37 // Description: pulumi.String("This is my API for demonstration purposes"), 38 // }) 39 // if err != nil { 40 // return err 41 // } 42 // myDemoResource, err := apigateway.NewResource(ctx, "MyDemoResource", &apigateway.ResourceArgs{ 43 // RestApi: myDemoAPI.ID(), 44 // ParentId: myDemoAPI.RootResourceId, 45 // PathPart: pulumi.String("mydemoresource"), 46 // }) 47 // if err != nil { 48 // return err 49 // } 50 // myDemoMethod, err := apigateway.NewMethod(ctx, "MyDemoMethod", &apigateway.MethodArgs{ 51 // RestApi: myDemoAPI.ID(), 52 // ResourceId: myDemoResource.ID(), 53 // HttpMethod: pulumi.String("GET"), 54 // Authorization: pulumi.String("NONE"), 55 // }) 56 // if err != nil { 57 // return err 58 // } 59 // _, err = apigateway.NewIntegration(ctx, "MyDemoIntegration", &apigateway.IntegrationArgs{ 60 // RestApi: myDemoAPI.ID(), 61 // ResourceId: myDemoResource.ID(), 62 // HttpMethod: myDemoMethod.HttpMethod, 63 // Type: pulumi.String("MOCK"), 64 // }) 65 // if err != nil { 66 // return err 67 // } 68 // response200, err := apigateway.NewMethodResponse(ctx, "response_200", &apigateway.MethodResponseArgs{ 69 // RestApi: myDemoAPI.ID(), 70 // ResourceId: myDemoResource.ID(), 71 // HttpMethod: myDemoMethod.HttpMethod, 72 // StatusCode: pulumi.String("200"), 73 // }) 74 // if err != nil { 75 // return err 76 // } 77 // _, err = apigateway.NewIntegrationResponse(ctx, "MyDemoIntegrationResponse", &apigateway.IntegrationResponseArgs{ 78 // RestApi: myDemoAPI.ID(), 79 // ResourceId: myDemoResource.ID(), 80 // HttpMethod: myDemoMethod.HttpMethod, 81 // StatusCode: response200.StatusCode, 82 // ResponseTemplates: pulumi.StringMap{ 83 // "application/xml": pulumi.String(`#set($inputRoot = $input.path('$')) 84 // 85 // <?xml version="1.0" encoding="UTF-8"?> 86 // <message> 87 // 88 // $inputRoot.body 89 // 90 // </message> 91 // `), 92 // 93 // }, 94 // }) 95 // if err != nil { 96 // return err 97 // } 98 // return nil 99 // }) 100 // } 101 // 102 // ``` 103 // <!--End PulumiCodeChooser --> 104 // 105 // ## Import 106 // 107 // Using `pulumi import`, import `aws_api_gateway_integration_response` using `REST-API-ID/RESOURCE-ID/HTTP-METHOD/STATUS-CODE`. For example: 108 // 109 // ```sh 110 // $ pulumi import aws:apigateway/integrationResponse:IntegrationResponse example 12345abcde/67890fghij/GET/200 111 // ``` 112 type IntegrationResponse struct { 113 pulumi.CustomResourceState 114 115 // How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the response payload will be passed through from the integration response to the method response without modification. 116 ContentHandling pulumi.StringPtrOutput `pulumi:"contentHandling"` 117 // HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`). 118 HttpMethod pulumi.StringOutput `pulumi:"httpMethod"` 119 // API resource ID. 120 ResourceId pulumi.StringOutput `pulumi:"resourceId"` 121 // Map of response parameters that can be read from the backend response. For example: `responseParameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }`. 122 ResponseParameters pulumi.StringMapOutput `pulumi:"responseParameters"` 123 // Map of templates used to transform the integration response body. 124 ResponseTemplates pulumi.StringMapOutput `pulumi:"responseTemplates"` 125 // ID of the associated REST API. 126 RestApi pulumi.StringOutput `pulumi:"restApi"` 127 // Regular expression pattern used to choose an integration response based on the response from the backend. Omit configuring this to make the integration the default one. If the backend is an `AWS` Lambda function, the AWS Lambda function error header is matched. For all other `HTTP` and `AWS` backends, the HTTP status code is matched. 128 SelectionPattern pulumi.StringPtrOutput `pulumi:"selectionPattern"` 129 // HTTP status code. 130 // 131 // The following arguments are optional: 132 StatusCode pulumi.StringOutput `pulumi:"statusCode"` 133 } 134 135 // NewIntegrationResponse registers a new resource with the given unique name, arguments, and options. 136 func NewIntegrationResponse(ctx *pulumi.Context, 137 name string, args *IntegrationResponseArgs, opts ...pulumi.ResourceOption) (*IntegrationResponse, error) { 138 if args == nil { 139 return nil, errors.New("missing one or more required arguments") 140 } 141 142 if args.HttpMethod == nil { 143 return nil, errors.New("invalid value for required argument 'HttpMethod'") 144 } 145 if args.ResourceId == nil { 146 return nil, errors.New("invalid value for required argument 'ResourceId'") 147 } 148 if args.RestApi == nil { 149 return nil, errors.New("invalid value for required argument 'RestApi'") 150 } 151 if args.StatusCode == nil { 152 return nil, errors.New("invalid value for required argument 'StatusCode'") 153 } 154 opts = internal.PkgResourceDefaultOpts(opts) 155 var resource IntegrationResponse 156 err := ctx.RegisterResource("aws:apigateway/integrationResponse:IntegrationResponse", name, args, &resource, opts...) 157 if err != nil { 158 return nil, err 159 } 160 return &resource, nil 161 } 162 163 // GetIntegrationResponse gets an existing IntegrationResponse resource's state with the given name, ID, and optional 164 // state properties that are used to uniquely qualify the lookup (nil if not required). 165 func GetIntegrationResponse(ctx *pulumi.Context, 166 name string, id pulumi.IDInput, state *IntegrationResponseState, opts ...pulumi.ResourceOption) (*IntegrationResponse, error) { 167 var resource IntegrationResponse 168 err := ctx.ReadResource("aws:apigateway/integrationResponse:IntegrationResponse", name, id, state, &resource, opts...) 169 if err != nil { 170 return nil, err 171 } 172 return &resource, nil 173 } 174 175 // Input properties used for looking up and filtering IntegrationResponse resources. 176 type integrationResponseState struct { 177 // How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the response payload will be passed through from the integration response to the method response without modification. 178 ContentHandling *string `pulumi:"contentHandling"` 179 // HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`). 180 HttpMethod *string `pulumi:"httpMethod"` 181 // API resource ID. 182 ResourceId *string `pulumi:"resourceId"` 183 // Map of response parameters that can be read from the backend response. For example: `responseParameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }`. 184 ResponseParameters map[string]string `pulumi:"responseParameters"` 185 // Map of templates used to transform the integration response body. 186 ResponseTemplates map[string]string `pulumi:"responseTemplates"` 187 // ID of the associated REST API. 188 RestApi interface{} `pulumi:"restApi"` 189 // Regular expression pattern used to choose an integration response based on the response from the backend. Omit configuring this to make the integration the default one. If the backend is an `AWS` Lambda function, the AWS Lambda function error header is matched. For all other `HTTP` and `AWS` backends, the HTTP status code is matched. 190 SelectionPattern *string `pulumi:"selectionPattern"` 191 // HTTP status code. 192 // 193 // The following arguments are optional: 194 StatusCode *string `pulumi:"statusCode"` 195 } 196 197 type IntegrationResponseState struct { 198 // How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the response payload will be passed through from the integration response to the method response without modification. 199 ContentHandling pulumi.StringPtrInput 200 // HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`). 201 HttpMethod pulumi.StringPtrInput 202 // API resource ID. 203 ResourceId pulumi.StringPtrInput 204 // Map of response parameters that can be read from the backend response. For example: `responseParameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }`. 205 ResponseParameters pulumi.StringMapInput 206 // Map of templates used to transform the integration response body. 207 ResponseTemplates pulumi.StringMapInput 208 // ID of the associated REST API. 209 RestApi pulumi.Input 210 // Regular expression pattern used to choose an integration response based on the response from the backend. Omit configuring this to make the integration the default one. If the backend is an `AWS` Lambda function, the AWS Lambda function error header is matched. For all other `HTTP` and `AWS` backends, the HTTP status code is matched. 211 SelectionPattern pulumi.StringPtrInput 212 // HTTP status code. 213 // 214 // The following arguments are optional: 215 StatusCode pulumi.StringPtrInput 216 } 217 218 func (IntegrationResponseState) ElementType() reflect.Type { 219 return reflect.TypeOf((*integrationResponseState)(nil)).Elem() 220 } 221 222 type integrationResponseArgs struct { 223 // How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the response payload will be passed through from the integration response to the method response without modification. 224 ContentHandling *string `pulumi:"contentHandling"` 225 // HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`). 226 HttpMethod string `pulumi:"httpMethod"` 227 // API resource ID. 228 ResourceId string `pulumi:"resourceId"` 229 // Map of response parameters that can be read from the backend response. For example: `responseParameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }`. 230 ResponseParameters map[string]string `pulumi:"responseParameters"` 231 // Map of templates used to transform the integration response body. 232 ResponseTemplates map[string]string `pulumi:"responseTemplates"` 233 // ID of the associated REST API. 234 RestApi interface{} `pulumi:"restApi"` 235 // Regular expression pattern used to choose an integration response based on the response from the backend. Omit configuring this to make the integration the default one. If the backend is an `AWS` Lambda function, the AWS Lambda function error header is matched. For all other `HTTP` and `AWS` backends, the HTTP status code is matched. 236 SelectionPattern *string `pulumi:"selectionPattern"` 237 // HTTP status code. 238 // 239 // The following arguments are optional: 240 StatusCode string `pulumi:"statusCode"` 241 } 242 243 // The set of arguments for constructing a IntegrationResponse resource. 244 type IntegrationResponseArgs struct { 245 // How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the response payload will be passed through from the integration response to the method response without modification. 246 ContentHandling pulumi.StringPtrInput 247 // HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`). 248 HttpMethod pulumi.StringInput 249 // API resource ID. 250 ResourceId pulumi.StringInput 251 // Map of response parameters that can be read from the backend response. For example: `responseParameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }`. 252 ResponseParameters pulumi.StringMapInput 253 // Map of templates used to transform the integration response body. 254 ResponseTemplates pulumi.StringMapInput 255 // ID of the associated REST API. 256 RestApi pulumi.Input 257 // Regular expression pattern used to choose an integration response based on the response from the backend. Omit configuring this to make the integration the default one. If the backend is an `AWS` Lambda function, the AWS Lambda function error header is matched. For all other `HTTP` and `AWS` backends, the HTTP status code is matched. 258 SelectionPattern pulumi.StringPtrInput 259 // HTTP status code. 260 // 261 // The following arguments are optional: 262 StatusCode pulumi.StringInput 263 } 264 265 func (IntegrationResponseArgs) ElementType() reflect.Type { 266 return reflect.TypeOf((*integrationResponseArgs)(nil)).Elem() 267 } 268 269 type IntegrationResponseInput interface { 270 pulumi.Input 271 272 ToIntegrationResponseOutput() IntegrationResponseOutput 273 ToIntegrationResponseOutputWithContext(ctx context.Context) IntegrationResponseOutput 274 } 275 276 func (*IntegrationResponse) ElementType() reflect.Type { 277 return reflect.TypeOf((**IntegrationResponse)(nil)).Elem() 278 } 279 280 func (i *IntegrationResponse) ToIntegrationResponseOutput() IntegrationResponseOutput { 281 return i.ToIntegrationResponseOutputWithContext(context.Background()) 282 } 283 284 func (i *IntegrationResponse) ToIntegrationResponseOutputWithContext(ctx context.Context) IntegrationResponseOutput { 285 return pulumi.ToOutputWithContext(ctx, i).(IntegrationResponseOutput) 286 } 287 288 // IntegrationResponseArrayInput is an input type that accepts IntegrationResponseArray and IntegrationResponseArrayOutput values. 289 // You can construct a concrete instance of `IntegrationResponseArrayInput` via: 290 // 291 // IntegrationResponseArray{ IntegrationResponseArgs{...} } 292 type IntegrationResponseArrayInput interface { 293 pulumi.Input 294 295 ToIntegrationResponseArrayOutput() IntegrationResponseArrayOutput 296 ToIntegrationResponseArrayOutputWithContext(context.Context) IntegrationResponseArrayOutput 297 } 298 299 type IntegrationResponseArray []IntegrationResponseInput 300 301 func (IntegrationResponseArray) ElementType() reflect.Type { 302 return reflect.TypeOf((*[]*IntegrationResponse)(nil)).Elem() 303 } 304 305 func (i IntegrationResponseArray) ToIntegrationResponseArrayOutput() IntegrationResponseArrayOutput { 306 return i.ToIntegrationResponseArrayOutputWithContext(context.Background()) 307 } 308 309 func (i IntegrationResponseArray) ToIntegrationResponseArrayOutputWithContext(ctx context.Context) IntegrationResponseArrayOutput { 310 return pulumi.ToOutputWithContext(ctx, i).(IntegrationResponseArrayOutput) 311 } 312 313 // IntegrationResponseMapInput is an input type that accepts IntegrationResponseMap and IntegrationResponseMapOutput values. 314 // You can construct a concrete instance of `IntegrationResponseMapInput` via: 315 // 316 // IntegrationResponseMap{ "key": IntegrationResponseArgs{...} } 317 type IntegrationResponseMapInput interface { 318 pulumi.Input 319 320 ToIntegrationResponseMapOutput() IntegrationResponseMapOutput 321 ToIntegrationResponseMapOutputWithContext(context.Context) IntegrationResponseMapOutput 322 } 323 324 type IntegrationResponseMap map[string]IntegrationResponseInput 325 326 func (IntegrationResponseMap) ElementType() reflect.Type { 327 return reflect.TypeOf((*map[string]*IntegrationResponse)(nil)).Elem() 328 } 329 330 func (i IntegrationResponseMap) ToIntegrationResponseMapOutput() IntegrationResponseMapOutput { 331 return i.ToIntegrationResponseMapOutputWithContext(context.Background()) 332 } 333 334 func (i IntegrationResponseMap) ToIntegrationResponseMapOutputWithContext(ctx context.Context) IntegrationResponseMapOutput { 335 return pulumi.ToOutputWithContext(ctx, i).(IntegrationResponseMapOutput) 336 } 337 338 type IntegrationResponseOutput struct{ *pulumi.OutputState } 339 340 func (IntegrationResponseOutput) ElementType() reflect.Type { 341 return reflect.TypeOf((**IntegrationResponse)(nil)).Elem() 342 } 343 344 func (o IntegrationResponseOutput) ToIntegrationResponseOutput() IntegrationResponseOutput { 345 return o 346 } 347 348 func (o IntegrationResponseOutput) ToIntegrationResponseOutputWithContext(ctx context.Context) IntegrationResponseOutput { 349 return o 350 } 351 352 // How to handle request payload content type conversions. Supported values are `CONVERT_TO_BINARY` and `CONVERT_TO_TEXT`. If this property is not defined, the response payload will be passed through from the integration response to the method response without modification. 353 func (o IntegrationResponseOutput) ContentHandling() pulumi.StringPtrOutput { 354 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringPtrOutput { return v.ContentHandling }).(pulumi.StringPtrOutput) 355 } 356 357 // HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`). 358 func (o IntegrationResponseOutput) HttpMethod() pulumi.StringOutput { 359 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringOutput { return v.HttpMethod }).(pulumi.StringOutput) 360 } 361 362 // API resource ID. 363 func (o IntegrationResponseOutput) ResourceId() pulumi.StringOutput { 364 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringOutput { return v.ResourceId }).(pulumi.StringOutput) 365 } 366 367 // Map of response parameters that can be read from the backend response. For example: `responseParameters = { "method.response.header.X-Some-Header" = "integration.response.header.X-Some-Other-Header" }`. 368 func (o IntegrationResponseOutput) ResponseParameters() pulumi.StringMapOutput { 369 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringMapOutput { return v.ResponseParameters }).(pulumi.StringMapOutput) 370 } 371 372 // Map of templates used to transform the integration response body. 373 func (o IntegrationResponseOutput) ResponseTemplates() pulumi.StringMapOutput { 374 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringMapOutput { return v.ResponseTemplates }).(pulumi.StringMapOutput) 375 } 376 377 // ID of the associated REST API. 378 func (o IntegrationResponseOutput) RestApi() pulumi.StringOutput { 379 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringOutput { return v.RestApi }).(pulumi.StringOutput) 380 } 381 382 // Regular expression pattern used to choose an integration response based on the response from the backend. Omit configuring this to make the integration the default one. If the backend is an `AWS` Lambda function, the AWS Lambda function error header is matched. For all other `HTTP` and `AWS` backends, the HTTP status code is matched. 383 func (o IntegrationResponseOutput) SelectionPattern() pulumi.StringPtrOutput { 384 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringPtrOutput { return v.SelectionPattern }).(pulumi.StringPtrOutput) 385 } 386 387 // HTTP status code. 388 // 389 // The following arguments are optional: 390 func (o IntegrationResponseOutput) StatusCode() pulumi.StringOutput { 391 return o.ApplyT(func(v *IntegrationResponse) pulumi.StringOutput { return v.StatusCode }).(pulumi.StringOutput) 392 } 393 394 type IntegrationResponseArrayOutput struct{ *pulumi.OutputState } 395 396 func (IntegrationResponseArrayOutput) ElementType() reflect.Type { 397 return reflect.TypeOf((*[]*IntegrationResponse)(nil)).Elem() 398 } 399 400 func (o IntegrationResponseArrayOutput) ToIntegrationResponseArrayOutput() IntegrationResponseArrayOutput { 401 return o 402 } 403 404 func (o IntegrationResponseArrayOutput) ToIntegrationResponseArrayOutputWithContext(ctx context.Context) IntegrationResponseArrayOutput { 405 return o 406 } 407 408 func (o IntegrationResponseArrayOutput) Index(i pulumi.IntInput) IntegrationResponseOutput { 409 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *IntegrationResponse { 410 return vs[0].([]*IntegrationResponse)[vs[1].(int)] 411 }).(IntegrationResponseOutput) 412 } 413 414 type IntegrationResponseMapOutput struct{ *pulumi.OutputState } 415 416 func (IntegrationResponseMapOutput) ElementType() reflect.Type { 417 return reflect.TypeOf((*map[string]*IntegrationResponse)(nil)).Elem() 418 } 419 420 func (o IntegrationResponseMapOutput) ToIntegrationResponseMapOutput() IntegrationResponseMapOutput { 421 return o 422 } 423 424 func (o IntegrationResponseMapOutput) ToIntegrationResponseMapOutputWithContext(ctx context.Context) IntegrationResponseMapOutput { 425 return o 426 } 427 428 func (o IntegrationResponseMapOutput) MapIndex(k pulumi.StringInput) IntegrationResponseOutput { 429 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *IntegrationResponse { 430 return vs[0].(map[string]*IntegrationResponse)[vs[1].(string)] 431 }).(IntegrationResponseOutput) 432 } 433 434 func init() { 435 pulumi.RegisterInputType(reflect.TypeOf((*IntegrationResponseInput)(nil)).Elem(), &IntegrationResponse{}) 436 pulumi.RegisterInputType(reflect.TypeOf((*IntegrationResponseArrayInput)(nil)).Elem(), IntegrationResponseArray{}) 437 pulumi.RegisterInputType(reflect.TypeOf((*IntegrationResponseMapInput)(nil)).Elem(), IntegrationResponseMap{}) 438 pulumi.RegisterOutputType(IntegrationResponseOutput{}) 439 pulumi.RegisterOutputType(IntegrationResponseArrayOutput{}) 440 pulumi.RegisterOutputType(IntegrationResponseMapOutput{}) 441 }