Class Method


  • public class Method
    extends com.pulumi.resources.CustomResource
    Provides a HTTP Method for an API Gateway Resource. ## Example Usage <!--Start PulumiCodeChooser -->
     
     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 java.util.List;
     import java.util.ArrayList;
     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());
     
         }
     }
     
     
    <!--End PulumiCodeChooser --> ## Usage with Cognito User Pool Authorizer <!--Start PulumiCodeChooser -->
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.cognito.CognitoFunctions;
     import com.pulumi.aws.cognito.inputs.GetUserPoolsArgs;
     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.Authorizer;
     import com.pulumi.aws.apigateway.AuthorizerArgs;
     import com.pulumi.aws.apigateway.Method;
     import com.pulumi.aws.apigateway.MethodArgs;
     import java.util.List;
     import java.util.ArrayList;
     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) {
             final var config = ctx.config();
             final var cognitoUserPoolName = config.get("cognitoUserPoolName");
             final var this = CognitoFunctions.getUserPools(GetUserPoolsArgs.builder()
                 .name(cognitoUserPoolName)
                 .build());
     
             var thisRestApi = new RestApi("thisRestApi", RestApiArgs.builder()
                 .name("with-authorizer")
                 .build());
     
             var thisResource = new Resource("thisResource", ResourceArgs.builder()
                 .restApi(thisRestApi.id())
                 .parentId(thisRestApi.rootResourceId())
                 .pathPart("{proxy+}")
                 .build());
     
             var thisAuthorizer = new Authorizer("thisAuthorizer", AuthorizerArgs.builder()
                 .name("CognitoUserPoolAuthorizer")
                 .type("COGNITO_USER_POOLS")
                 .restApi(thisRestApi.id())
                 .providerArns(this_.arns())
                 .build());
     
             var any = new Method("any", MethodArgs.builder()
                 .restApi(thisRestApi.id())
                 .resourceId(thisResource.id())
                 .httpMethod("ANY")
                 .authorization("COGNITO_USER_POOLS")
                 .authorizerId(thisAuthorizer.id())
                 .requestParameters(Map.of("method.request.path.proxy", true))
                 .build());
     
         }
     }
     
     
    <!--End PulumiCodeChooser --> ## Import Using `pulumi import`, import `aws_api_gateway_method` using `REST-API-ID/RESOURCE-ID/HTTP-METHOD`. For example: ```sh $ pulumi import aws:apigateway/method:Method example 12345abcde/67890fghij/GET ```
    • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      Method​(java.lang.String name)  
      Method​(java.lang.String name, MethodArgs args)  
      Method​(java.lang.String name, MethodArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> apiKeyRequired()  
      com.pulumi.core.Output<java.lang.String> authorization()  
      com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> authorizationScopes()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> authorizerId()  
      static Method get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, MethodState 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.util.Optional<java.lang.String>> operationName()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> requestModels()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.Boolean>>> requestParameters()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> requestValidatorId()  
      com.pulumi.core.Output<java.lang.String> resourceId()  
      com.pulumi.core.Output<java.lang.String> restApi()  
      • 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

      • Method

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

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

        public Method​(java.lang.String name,
                      MethodArgs 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

      • apiKeyRequired

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> apiKeyRequired()
        Returns:
        Specify if the method requires an API key
      • authorization

        public com.pulumi.core.Output<java.lang.String> authorization()
        Returns:
        Type of authorization used for the method (`NONE`, `CUSTOM`, `AWS_IAM`, `COGNITO_USER_POOLS`)
      • authorizationScopes

        public com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> authorizationScopes()
        Returns:
        Authorization scopes used when the authorization is `COGNITO_USER_POOLS`
      • authorizerId

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> authorizerId()
        Returns:
        Authorizer id to be used when the authorization is `CUSTOM` or `COGNITO_USER_POOLS`
      • httpMethod

        public com.pulumi.core.Output<java.lang.String> httpMethod()
        Returns:
        HTTP Method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTIONS`, `ANY`)
      • operationName

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> operationName()
        Returns:
        Function name that will be given to the method when generating an SDK through API Gateway. If omitted, API Gateway will generate a function name based on the resource path and HTTP verb.
      • requestModels

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> requestModels()
        Returns:
        Map of the API models used for the request's content type where key is the content type (e.g., `application/json`) and value is either `Error`, `Empty` (built-in models) or `aws.apigateway.Model`'s `name`.
      • requestParameters

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.Boolean>>> requestParameters()
        Returns:
        Map of request parameters (from the path, query string and headers) that should be passed to the integration. The boolean value indicates whether the parameter is required (`true`) or optional (`false`). For example: `request_parameters = {"method.request.header.X-Some-Header" = true "method.request.querystring.some-query-param" = true}` would define that the header `X-Some-Header` and the query string `some-query-param` must be provided in the request.
      • requestValidatorId

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> requestValidatorId()
        Returns:
        ID of a `aws.apigateway.RequestValidator`
      • resourceId

        public com.pulumi.core.Output<java.lang.String> resourceId()
        Returns:
        API resource ID
      • restApi

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

        public static Method get​(java.lang.String name,
                                 com.pulumi.core.Output<java.lang.String> id,
                                 @Nullable
                                 MethodState 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.