Class MethodResponse


  • public class MethodResponse
    extends com.pulumi.resources.CustomResource
    Provides an HTTP Method Response for an API Gateway Resource. More information about API Gateway method responses can be found in the [Amazon API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-response.html). ## Example Usage ### Basic Response
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.apigateway.RestApi;
     import com.pulumi.aws.apigateway.RestApiArgs;
     import com.pulumi.aws.apigateway.Resource;
     import com.pulumi.aws.apigateway.ResourceArgs;
     import com.pulumi.aws.apigateway.Method;
     import com.pulumi.aws.apigateway.MethodArgs;
     import com.pulumi.aws.apigateway.Integration;
     import com.pulumi.aws.apigateway.IntegrationArgs;
     import com.pulumi.aws.apigateway.MethodResponse;
     import com.pulumi.aws.apigateway.MethodResponseArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var myDemoAPI = new RestApi("myDemoAPI", RestApiArgs.builder()
                 .name("MyDemoAPI")
                 .description("This is my API for demonstration purposes")
                 .build());
     
             var myDemoResource = new Resource("myDemoResource", ResourceArgs.builder()
                 .restApi(myDemoAPI.id())
                 .parentId(myDemoAPI.rootResourceId())
                 .pathPart("mydemoresource")
                 .build());
     
             var myDemoMethod = new Method("myDemoMethod", MethodArgs.builder()
                 .restApi(myDemoAPI.id())
                 .resourceId(myDemoResource.id())
                 .httpMethod("GET")
                 .authorization("NONE")
                 .build());
     
             var myDemoIntegration = new Integration("myDemoIntegration", IntegrationArgs.builder()
                 .restApi(myDemoAPI.id())
                 .resourceId(myDemoResource.id())
                 .httpMethod(myDemoMethod.httpMethod())
                 .type("MOCK")
                 .build());
     
             var response200 = new MethodResponse("response200", MethodResponseArgs.builder()
                 .restApi(myDemoAPI.id())
                 .resourceId(myDemoResource.id())
                 .httpMethod(myDemoMethod.httpMethod())
                 .statusCode("200")
                 .build());
     
         }
     }
     
     
    ### Response with Custom Header and Model
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.apigateway.RestApi;
     import com.pulumi.aws.apigateway.RestApiArgs;
     import com.pulumi.aws.apigateway.Resource;
     import com.pulumi.aws.apigateway.ResourceArgs;
     import com.pulumi.aws.apigateway.Method;
     import com.pulumi.aws.apigateway.MethodArgs;
     import com.pulumi.aws.apigateway.Integration;
     import com.pulumi.aws.apigateway.IntegrationArgs;
     import com.pulumi.aws.apigateway.Model;
     import com.pulumi.aws.apigateway.ModelArgs;
     import com.pulumi.aws.apigateway.MethodResponse;
     import com.pulumi.aws.apigateway.MethodResponseArgs;
     import static com.pulumi.codegen.internal.Serialization.*;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var myDemoAPI = new RestApi("myDemoAPI", RestApiArgs.builder()
                 .name("MyDemoAPI")
                 .description("This is my API for demonstration purposes")
                 .build());
     
             var myDemoResource = new Resource("myDemoResource", ResourceArgs.builder()
                 .restApi(myDemoAPI.id())
                 .parentId(myDemoAPI.rootResourceId())
                 .pathPart("mydemoresource")
                 .build());
     
             var myDemoMethod = new Method("myDemoMethod", MethodArgs.builder()
                 .restApi(myDemoAPI.id())
                 .resourceId(myDemoResource.id())
                 .httpMethod("GET")
                 .authorization("NONE")
                 .build());
     
             var myDemoIntegration = new Integration("myDemoIntegration", IntegrationArgs.builder()
                 .restApi(myDemoAPI.id())
                 .resourceId(myDemoResource.id())
                 .httpMethod(myDemoMethod.httpMethod())
                 .type("MOCK")
                 .build());
     
             var myDemoResponseModel = new Model("myDemoResponseModel", ModelArgs.builder()
                 .restApi(myDemoAPI.id())
                 .name("MyDemoResponseModel")
                 .description("API response for MyDemoMethod")
                 .contentType("application/json")
                 .schema(serializeJson(
                     jsonObject(
                         jsonProperty("$schema", "http://json-schema.org/draft-04/schema#"),
                         jsonProperty("title", "MyDemoResponse"),
                         jsonProperty("type", "object"),
                         jsonProperty("properties", jsonObject(
                             jsonProperty("Message", jsonObject(
                                 jsonProperty("type", "string")
                             ))
                         ))
                     )))
                 .build());
     
             var response200 = new MethodResponse("response200", MethodResponseArgs.builder()
                 .restApi(myDemoAPI.id())
                 .resourceId(myDemoResource.id())
                 .httpMethod(myDemoMethod.httpMethod())
                 .statusCode("200")
                 .responseModels(Map.of("application/json", "MyDemoResponseModel"))
                 .responseParameters(Map.ofEntries(
                     Map.entry("method.response.header.Content-Type", false),
                     Map.entry("method-response-header.X-My-Demo-Header", false)
                 ))
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `restApiId` (String) The string identifier of the associated REST API. * `resourceId` (String) The Resource identifier for the method resource. * `httpMethod` (String) The HTTP verb of the method resource. * `statusCode` (String) The method response's status code. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import `aws.apigateway.MethodResponse` using `REST-API-ID/RESOURCE-ID/HTTP-METHOD/STATUS-CODE`. For example: ```sh $ pulumi import aws:apigateway/methodResponse:MethodResponse example 12345abcde/67890fghij/GET/200 ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static MethodResponse get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, MethodResponseState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> httpMethod()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.lang.String> resourceId()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> responseModels()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.Boolean>>> responseParameters()  
      com.pulumi.core.Output<java.lang.String> restApi()  
      com.pulumi.core.Output<java.lang.String> statusCode()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MethodResponse

        public MethodResponse​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • MethodResponse

        public MethodResponse​(java.lang.String name,
                              MethodResponseArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • MethodResponse

        public MethodResponse​(java.lang.String name,
                              MethodResponseArgs args,
                              @Nullable
                              com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • httpMethod

        public com.pulumi.core.Output<java.lang.String> httpMethod()
        Returns:
        HTTP verb of the method resource (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`).
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • resourceId

        public com.pulumi.core.Output<java.lang.String> resourceId()
        Returns:
        Resource identifier for the method resource.
      • responseModels

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> responseModels()
        Returns:
        Map specifying the model resources used for the response's content type. Response models are represented as a key/value map, with a content type as the key and a Model name as the value.
      • responseParameters

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.Boolean>>> responseParameters()
        Returns:
        Map specifying required or optional response parameters that API Gateway can send back to the caller. A key defines a method response header name and the associated value is a boolean flag indicating whether the method response parameter is required. The method response header names must match the pattern of `method.response.header.{name}`, where `name` is a valid and unique header name. The response parameter names defined here are available in the integration response to be mapped from an integration response header expressed in `integration.response.header.{name}`, a static value enclosed within a pair of single quotes (e.g., '`application/json'`), or a JSON expression from the back-end response payload in the form of `integration.response.body.{JSON-expression}`, where `JSON-expression` is a valid JSON expression without the `$` prefix.)
      • restApi

        public com.pulumi.core.Output<java.lang.String> restApi()
        Returns:
        String identifier of the associated REST API.
      • statusCode

        public com.pulumi.core.Output<java.lang.String> statusCode()
        Returns:
        Method response's status code.
      • get

        public static MethodResponse get​(java.lang.String name,
                                         com.pulumi.core.Output<java.lang.String> id,
                                         @Nullable
                                         MethodResponseState state,
                                         @Nullable
                                         com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.