github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/response.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 API Gateway Gateway Response for a REST API Gateway. 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 // main, err := apigateway.NewRestApi(ctx, "main", &apigateway.RestApiArgs{ 33 // Name: pulumi.String("MyDemoAPI"), 34 // }) 35 // if err != nil { 36 // return err 37 // } 38 // _, err = apigateway.NewResponse(ctx, "test", &apigateway.ResponseArgs{ 39 // RestApiId: main.ID(), 40 // StatusCode: pulumi.String("401"), 41 // ResponseType: pulumi.String("UNAUTHORIZED"), 42 // ResponseTemplates: pulumi.StringMap{ 43 // "application/json": pulumi.String("{\"message\":$context.error.messageString}"), 44 // }, 45 // ResponseParameters: pulumi.StringMap{ 46 // "gatewayresponse.header.Authorization": pulumi.String("'Basic'"), 47 // }, 48 // }) 49 // if err != nil { 50 // return err 51 // } 52 // return nil 53 // }) 54 // } 55 // 56 // ``` 57 // <!--End PulumiCodeChooser --> 58 // 59 // ## Import 60 // 61 // Using `pulumi import`, import `aws_api_gateway_gateway_response` using `REST-API-ID/RESPONSE-TYPE`. For example: 62 // 63 // ```sh 64 // $ pulumi import aws:apigateway/response:Response example 12345abcde/UNAUTHORIZED 65 // ``` 66 type Response struct { 67 pulumi.CustomResourceState 68 69 // Map of parameters (paths, query strings and headers) of the Gateway Response. 70 ResponseParameters pulumi.StringMapOutput `pulumi:"responseParameters"` 71 // Map of templates used to transform the response body. 72 ResponseTemplates pulumi.StringMapOutput `pulumi:"responseTemplates"` 73 // Response type of the associated GatewayResponse. 74 ResponseType pulumi.StringOutput `pulumi:"responseType"` 75 // String identifier of the associated REST API. 76 RestApiId pulumi.StringOutput `pulumi:"restApiId"` 77 // HTTP status code of the Gateway Response. 78 StatusCode pulumi.StringPtrOutput `pulumi:"statusCode"` 79 } 80 81 // NewResponse registers a new resource with the given unique name, arguments, and options. 82 func NewResponse(ctx *pulumi.Context, 83 name string, args *ResponseArgs, opts ...pulumi.ResourceOption) (*Response, error) { 84 if args == nil { 85 return nil, errors.New("missing one or more required arguments") 86 } 87 88 if args.ResponseType == nil { 89 return nil, errors.New("invalid value for required argument 'ResponseType'") 90 } 91 if args.RestApiId == nil { 92 return nil, errors.New("invalid value for required argument 'RestApiId'") 93 } 94 opts = internal.PkgResourceDefaultOpts(opts) 95 var resource Response 96 err := ctx.RegisterResource("aws:apigateway/response:Response", name, args, &resource, opts...) 97 if err != nil { 98 return nil, err 99 } 100 return &resource, nil 101 } 102 103 // GetResponse gets an existing Response resource's state with the given name, ID, and optional 104 // state properties that are used to uniquely qualify the lookup (nil if not required). 105 func GetResponse(ctx *pulumi.Context, 106 name string, id pulumi.IDInput, state *ResponseState, opts ...pulumi.ResourceOption) (*Response, error) { 107 var resource Response 108 err := ctx.ReadResource("aws:apigateway/response:Response", name, id, state, &resource, opts...) 109 if err != nil { 110 return nil, err 111 } 112 return &resource, nil 113 } 114 115 // Input properties used for looking up and filtering Response resources. 116 type responseState struct { 117 // Map of parameters (paths, query strings and headers) of the Gateway Response. 118 ResponseParameters map[string]string `pulumi:"responseParameters"` 119 // Map of templates used to transform the response body. 120 ResponseTemplates map[string]string `pulumi:"responseTemplates"` 121 // Response type of the associated GatewayResponse. 122 ResponseType *string `pulumi:"responseType"` 123 // String identifier of the associated REST API. 124 RestApiId *string `pulumi:"restApiId"` 125 // HTTP status code of the Gateway Response. 126 StatusCode *string `pulumi:"statusCode"` 127 } 128 129 type ResponseState struct { 130 // Map of parameters (paths, query strings and headers) of the Gateway Response. 131 ResponseParameters pulumi.StringMapInput 132 // Map of templates used to transform the response body. 133 ResponseTemplates pulumi.StringMapInput 134 // Response type of the associated GatewayResponse. 135 ResponseType pulumi.StringPtrInput 136 // String identifier of the associated REST API. 137 RestApiId pulumi.StringPtrInput 138 // HTTP status code of the Gateway Response. 139 StatusCode pulumi.StringPtrInput 140 } 141 142 func (ResponseState) ElementType() reflect.Type { 143 return reflect.TypeOf((*responseState)(nil)).Elem() 144 } 145 146 type responseArgs struct { 147 // Map of parameters (paths, query strings and headers) of the Gateway Response. 148 ResponseParameters map[string]string `pulumi:"responseParameters"` 149 // Map of templates used to transform the response body. 150 ResponseTemplates map[string]string `pulumi:"responseTemplates"` 151 // Response type of the associated GatewayResponse. 152 ResponseType string `pulumi:"responseType"` 153 // String identifier of the associated REST API. 154 RestApiId string `pulumi:"restApiId"` 155 // HTTP status code of the Gateway Response. 156 StatusCode *string `pulumi:"statusCode"` 157 } 158 159 // The set of arguments for constructing a Response resource. 160 type ResponseArgs struct { 161 // Map of parameters (paths, query strings and headers) of the Gateway Response. 162 ResponseParameters pulumi.StringMapInput 163 // Map of templates used to transform the response body. 164 ResponseTemplates pulumi.StringMapInput 165 // Response type of the associated GatewayResponse. 166 ResponseType pulumi.StringInput 167 // String identifier of the associated REST API. 168 RestApiId pulumi.StringInput 169 // HTTP status code of the Gateway Response. 170 StatusCode pulumi.StringPtrInput 171 } 172 173 func (ResponseArgs) ElementType() reflect.Type { 174 return reflect.TypeOf((*responseArgs)(nil)).Elem() 175 } 176 177 type ResponseInput interface { 178 pulumi.Input 179 180 ToResponseOutput() ResponseOutput 181 ToResponseOutputWithContext(ctx context.Context) ResponseOutput 182 } 183 184 func (*Response) ElementType() reflect.Type { 185 return reflect.TypeOf((**Response)(nil)).Elem() 186 } 187 188 func (i *Response) ToResponseOutput() ResponseOutput { 189 return i.ToResponseOutputWithContext(context.Background()) 190 } 191 192 func (i *Response) ToResponseOutputWithContext(ctx context.Context) ResponseOutput { 193 return pulumi.ToOutputWithContext(ctx, i).(ResponseOutput) 194 } 195 196 // ResponseArrayInput is an input type that accepts ResponseArray and ResponseArrayOutput values. 197 // You can construct a concrete instance of `ResponseArrayInput` via: 198 // 199 // ResponseArray{ ResponseArgs{...} } 200 type ResponseArrayInput interface { 201 pulumi.Input 202 203 ToResponseArrayOutput() ResponseArrayOutput 204 ToResponseArrayOutputWithContext(context.Context) ResponseArrayOutput 205 } 206 207 type ResponseArray []ResponseInput 208 209 func (ResponseArray) ElementType() reflect.Type { 210 return reflect.TypeOf((*[]*Response)(nil)).Elem() 211 } 212 213 func (i ResponseArray) ToResponseArrayOutput() ResponseArrayOutput { 214 return i.ToResponseArrayOutputWithContext(context.Background()) 215 } 216 217 func (i ResponseArray) ToResponseArrayOutputWithContext(ctx context.Context) ResponseArrayOutput { 218 return pulumi.ToOutputWithContext(ctx, i).(ResponseArrayOutput) 219 } 220 221 // ResponseMapInput is an input type that accepts ResponseMap and ResponseMapOutput values. 222 // You can construct a concrete instance of `ResponseMapInput` via: 223 // 224 // ResponseMap{ "key": ResponseArgs{...} } 225 type ResponseMapInput interface { 226 pulumi.Input 227 228 ToResponseMapOutput() ResponseMapOutput 229 ToResponseMapOutputWithContext(context.Context) ResponseMapOutput 230 } 231 232 type ResponseMap map[string]ResponseInput 233 234 func (ResponseMap) ElementType() reflect.Type { 235 return reflect.TypeOf((*map[string]*Response)(nil)).Elem() 236 } 237 238 func (i ResponseMap) ToResponseMapOutput() ResponseMapOutput { 239 return i.ToResponseMapOutputWithContext(context.Background()) 240 } 241 242 func (i ResponseMap) ToResponseMapOutputWithContext(ctx context.Context) ResponseMapOutput { 243 return pulumi.ToOutputWithContext(ctx, i).(ResponseMapOutput) 244 } 245 246 type ResponseOutput struct{ *pulumi.OutputState } 247 248 func (ResponseOutput) ElementType() reflect.Type { 249 return reflect.TypeOf((**Response)(nil)).Elem() 250 } 251 252 func (o ResponseOutput) ToResponseOutput() ResponseOutput { 253 return o 254 } 255 256 func (o ResponseOutput) ToResponseOutputWithContext(ctx context.Context) ResponseOutput { 257 return o 258 } 259 260 // Map of parameters (paths, query strings and headers) of the Gateway Response. 261 func (o ResponseOutput) ResponseParameters() pulumi.StringMapOutput { 262 return o.ApplyT(func(v *Response) pulumi.StringMapOutput { return v.ResponseParameters }).(pulumi.StringMapOutput) 263 } 264 265 // Map of templates used to transform the response body. 266 func (o ResponseOutput) ResponseTemplates() pulumi.StringMapOutput { 267 return o.ApplyT(func(v *Response) pulumi.StringMapOutput { return v.ResponseTemplates }).(pulumi.StringMapOutput) 268 } 269 270 // Response type of the associated GatewayResponse. 271 func (o ResponseOutput) ResponseType() pulumi.StringOutput { 272 return o.ApplyT(func(v *Response) pulumi.StringOutput { return v.ResponseType }).(pulumi.StringOutput) 273 } 274 275 // String identifier of the associated REST API. 276 func (o ResponseOutput) RestApiId() pulumi.StringOutput { 277 return o.ApplyT(func(v *Response) pulumi.StringOutput { return v.RestApiId }).(pulumi.StringOutput) 278 } 279 280 // HTTP status code of the Gateway Response. 281 func (o ResponseOutput) StatusCode() pulumi.StringPtrOutput { 282 return o.ApplyT(func(v *Response) pulumi.StringPtrOutput { return v.StatusCode }).(pulumi.StringPtrOutput) 283 } 284 285 type ResponseArrayOutput struct{ *pulumi.OutputState } 286 287 func (ResponseArrayOutput) ElementType() reflect.Type { 288 return reflect.TypeOf((*[]*Response)(nil)).Elem() 289 } 290 291 func (o ResponseArrayOutput) ToResponseArrayOutput() ResponseArrayOutput { 292 return o 293 } 294 295 func (o ResponseArrayOutput) ToResponseArrayOutputWithContext(ctx context.Context) ResponseArrayOutput { 296 return o 297 } 298 299 func (o ResponseArrayOutput) Index(i pulumi.IntInput) ResponseOutput { 300 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Response { 301 return vs[0].([]*Response)[vs[1].(int)] 302 }).(ResponseOutput) 303 } 304 305 type ResponseMapOutput struct{ *pulumi.OutputState } 306 307 func (ResponseMapOutput) ElementType() reflect.Type { 308 return reflect.TypeOf((*map[string]*Response)(nil)).Elem() 309 } 310 311 func (o ResponseMapOutput) ToResponseMapOutput() ResponseMapOutput { 312 return o 313 } 314 315 func (o ResponseMapOutput) ToResponseMapOutputWithContext(ctx context.Context) ResponseMapOutput { 316 return o 317 } 318 319 func (o ResponseMapOutput) MapIndex(k pulumi.StringInput) ResponseOutput { 320 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Response { 321 return vs[0].(map[string]*Response)[vs[1].(string)] 322 }).(ResponseOutput) 323 } 324 325 func init() { 326 pulumi.RegisterInputType(reflect.TypeOf((*ResponseInput)(nil)).Elem(), &Response{}) 327 pulumi.RegisterInputType(reflect.TypeOf((*ResponseArrayInput)(nil)).Elem(), ResponseArray{}) 328 pulumi.RegisterInputType(reflect.TypeOf((*ResponseMapInput)(nil)).Elem(), ResponseMap{}) 329 pulumi.RegisterOutputType(ResponseOutput{}) 330 pulumi.RegisterOutputType(ResponseArrayOutput{}) 331 pulumi.RegisterOutputType(ResponseMapOutput{}) 332 }