java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.apigateway.Method
All Implemented Interfaces:
IResource, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-24T21:00:24.888Z") @Stability(Stable) public class Method extends Resource
Example:

 LambdaIntegration integration;
 RestApi api = new RestApi(this, "hello-api");
 Resource v1 = api.root.addResource("v1");
 Resource echo = v1.addResource("echo");
 Method echoMethod = echo.addMethod("GET", integration, MethodOptions.builder().apiKeyRequired(true).build());
 UsagePlan plan = api.addUsagePlan("UsagePlan", UsagePlanProps.builder()
         .name("Easy")
         .throttle(ThrottleSettings.builder()
                 .rateLimit(10)
                 .burstLimit(2)
                 .build())
         .build());
 IApiKey key = api.addApiKey("ApiKey");
 plan.addApiKey(key);
 
  • Constructor Details

    • Method

      protected Method(software.amazon.jsii.JsiiObjectRef objRef)
    • Method

      protected Method(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Method

      @Stability(Stable) public Method(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull MethodProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • addMethodResponse

      @Stability(Stable) public void addMethodResponse(@NotNull MethodResponse methodResponse)
      Add a method response to this method.

      You should only add one method reponse for every status code. The API allows it for historical reasons, but will add a warning if this happens. If you do, your Method will nondeterministically use one of the responses, and ignore the rest.

      Parameters:
      methodResponse - This parameter is required.
    • grantExecute

      @Stability(Stable) @NotNull public Grant grantExecute(@NotNull IGrantable grantee)
      Grants an IAM principal permission to invoke this method.

      Parameters:
      grantee - the principal. This parameter is required.
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @NotNull IStage stage, @Nullable MetricOptions props)
      Returns the given named metric for this API method.

      Parameters:
      metricName - This parameter is required.
      stage - This parameter is required.
      props -
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @NotNull IStage stage)
      Returns the given named metric for this API method.

      Parameters:
      metricName - This parameter is required.
      stage - This parameter is required.
    • metricCacheHitCount

      @Stability(Stable) @NotNull public Metric metricCacheHitCount(@NotNull IStage stage, @Nullable MetricOptions props)
      Metric for the number of requests served from the API cache in a given period.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
      props -
    • metricCacheHitCount

      @Stability(Stable) @NotNull public Metric metricCacheHitCount(@NotNull IStage stage)
      Metric for the number of requests served from the API cache in a given period.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
    • metricCacheMissCount

      @Stability(Stable) @NotNull public Metric metricCacheMissCount(@NotNull IStage stage, @Nullable MetricOptions props)
      Metric for the number of requests served from the backend in a given period, when API caching is enabled.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
      props -
    • metricCacheMissCount

      @Stability(Stable) @NotNull public Metric metricCacheMissCount(@NotNull IStage stage)
      Metric for the number of requests served from the backend in a given period, when API caching is enabled.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
    • metricClientError

      @Stability(Stable) @NotNull public Metric metricClientError(@NotNull IStage stage, @Nullable MetricOptions props)
      Metric for the number of client-side errors captured in a given period.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
      props -
    • metricClientError

      @Stability(Stable) @NotNull public Metric metricClientError(@NotNull IStage stage)
      Metric for the number of client-side errors captured in a given period.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
    • metricCount

      @Stability(Stable) @NotNull public Metric metricCount(@NotNull IStage stage, @Nullable MetricOptions props)
      Metric for the total number API requests in a given period.

      Default: - sample count over 5 minutes

      Parameters:
      stage - This parameter is required.
      props -
    • metricCount

      @Stability(Stable) @NotNull public Metric metricCount(@NotNull IStage stage)
      Metric for the total number API requests in a given period.

      Default: - sample count over 5 minutes

      Parameters:
      stage - This parameter is required.
    • metricIntegrationLatency

      @Stability(Stable) @NotNull public Metric metricIntegrationLatency(@NotNull IStage stage, @Nullable MetricOptions props)
      Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend.

      Default: - average over 5 minutes.

      Parameters:
      stage - This parameter is required.
      props -
    • metricIntegrationLatency

      @Stability(Stable) @NotNull public Metric metricIntegrationLatency(@NotNull IStage stage)
      Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend.

      Default: - average over 5 minutes.

      Parameters:
      stage - This parameter is required.
    • metricLatency

      @Stability(Stable) @NotNull public Metric metricLatency(@NotNull IStage stage, @Nullable MetricOptions props)
      The time between when API Gateway receives a request from a client and when it returns a response to the client.

      The latency includes the integration latency and other API Gateway overhead.

      Default: - average over 5 minutes.

      Parameters:
      stage - This parameter is required.
      props -
    • metricLatency

      @Stability(Stable) @NotNull public Metric metricLatency(@NotNull IStage stage)
      The time between when API Gateway receives a request from a client and when it returns a response to the client.

      The latency includes the integration latency and other API Gateway overhead.

      Default: - average over 5 minutes.

      Parameters:
      stage - This parameter is required.
    • metricServerError

      @Stability(Stable) @NotNull public Metric metricServerError(@NotNull IStage stage, @Nullable MetricOptions props)
      Metric for the number of server-side errors captured in a given period.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
      props -
    • metricServerError

      @Stability(Stable) @NotNull public Metric metricServerError(@NotNull IStage stage)
      Metric for the number of server-side errors captured in a given period.

      Default: - sum over 5 minutes

      Parameters:
      stage - This parameter is required.
    • getApi

      @Stability(Stable) @NotNull public IRestApi getApi()
      The API Gateway RestApi associated with this method.
    • getHttpMethod

      @Stability(Stable) @NotNull public String getHttpMethod()
    • getMethodArn

      @Stability(Stable) @NotNull public String getMethodArn()
      Returns an execute-api ARN for this method:.

      arn:aws:execute-api:{region}:{account}:{restApiId}/{stage}/{method}/{path}

      NOTE: {stage} will refer to the restApi.deploymentStage, which will automatically set if auto-deploy is enabled, or can be explicitly assigned. When not configured, {stage} will be set to '*', as a shorthand for 'all stages'.

    • getMethodId

      @Stability(Stable) @NotNull public String getMethodId()
    • getResource

      @Stability(Stable) @NotNull public IResource getResource()
    • getTestMethodArn

      @Stability(Stable) @NotNull public String getTestMethodArn()
      Returns an execute-api ARN for this method's "test-invoke-stage" stage.

      This stage is used by the AWS Console UI when testing the method.