java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.apigatewayv2.HttpApi
All Implemented Interfaces:
IResource, IApi, IHttpApi, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-25T14:21:09.550Z") @Stability(Stable) public class HttpApi extends Resource implements IHttpApi, IApi
Create a new API Gateway HTTP API endpoint.

Example:

 import software.amazon.awscdk.aws_apigatewayv2_integrations.HttpLambdaIntegration;
 Function booksDefaultFn;
 HttpLambdaIntegration booksIntegration = new HttpLambdaIntegration("BooksIntegration", booksDefaultFn);
 HttpApi httpApi = new HttpApi(this, "HttpApi");
 httpApi.addRoutes(AddRoutesOptions.builder()
         .path("/books")
         .methods(List.of(HttpMethod.GET))
         .integration(booksIntegration)
         .build());
 
  • Constructor Details

    • HttpApi

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

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

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

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

    • fromHttpApiAttributes

      @Stability(Stable) @NotNull public static IHttpApi fromHttpApiAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull HttpApiAttributes attrs)
      Import an existing HTTP API into this CDK app.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • addRoutes

      @Stability(Stable) @NotNull public List<HttpRoute> addRoutes(@NotNull AddRoutesOptions options)
      Add multiple routes that uses the same configuration.

      The routes all go to the same path, but for different methods.

      Parameters:
      options - This parameter is required.
    • addStage

      @Stability(Stable) @NotNull public HttpStage addStage(@NotNull String id, @NotNull HttpStageOptions options)
      Add a new stage.

      Parameters:
      id - This parameter is required.
      options - This parameter is required.
    • addVpcLink

      @Stability(Stable) @NotNull public VpcLink addVpcLink(@NotNull VpcLinkProps options)
      Add a new VpcLink.

      Specified by:
      addVpcLink in interface IHttpApi
      Parameters:
      options - This parameter is required.
    • arnForExecuteApi

      @Stability(Stable) @NotNull public String arnForExecuteApi(@Nullable String method, @Nullable String path, @Nullable String stage)
      Get the "execute-api" ARN.

      When 'ANY' is passed to the method, an ARN with the method set to '*' is obtained.

      Specified by:
      arnForExecuteApi in interface IHttpApi
      Parameters:
      method -
      path -
      stage -
    • arnForExecuteApi

      @Stability(Stable) @NotNull public String arnForExecuteApi(@Nullable String method, @Nullable String path)
      Get the "execute-api" ARN.

      When 'ANY' is passed to the method, an ARN with the method set to '*' is obtained.

      Specified by:
      arnForExecuteApi in interface IHttpApi
      Parameters:
      method -
      path -
    • arnForExecuteApi

      @Stability(Stable) @NotNull public String arnForExecuteApi(@Nullable String method)
      Get the "execute-api" ARN.

      When 'ANY' is passed to the method, an ARN with the method set to '*' is obtained.

      Specified by:
      arnForExecuteApi in interface IHttpApi
      Parameters:
      method -
    • arnForExecuteApi

      @Stability(Stable) @NotNull public String arnForExecuteApi()
      Get the "execute-api" ARN.

      When 'ANY' is passed to the method, an ARN with the method set to '*' is obtained.

      Specified by:
      arnForExecuteApi in interface IHttpApi
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
      Return the given named metric for this Api Gateway.

      Specified by:
      metric in interface IApi
      Parameters:
      metricName - This parameter is required.
      props -
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName)
      Return the given named metric for this Api Gateway.

      Specified by:
      metric in interface IApi
      Parameters:
      metricName - This parameter is required.
    • metricClientError

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

      Specified by:
      metricClientError in interface IHttpApi
      Parameters:
      props -
    • metricClientError

      @Stability(Stable) @NotNull public Metric metricClientError()
      Metric for the number of client-side errors captured in a given period.
      Specified by:
      metricClientError in interface IHttpApi
    • metricCount

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

      Specified by:
      metricCount in interface IHttpApi
      Parameters:
      props -
    • metricCount

      @Stability(Stable) @NotNull public Metric metricCount()
      Metric for the total number API requests in a given period.
      Specified by:
      metricCount in interface IHttpApi
    • metricDataProcessed

      @Stability(Stable) @NotNull public Metric metricDataProcessed(@Nullable MetricOptions props)
      Metric for the amount of data processed in bytes.

      Specified by:
      metricDataProcessed in interface IHttpApi
      Parameters:
      props -
    • metricDataProcessed

      @Stability(Stable) @NotNull public Metric metricDataProcessed()
      Metric for the amount of data processed in bytes.
      Specified by:
      metricDataProcessed in interface IHttpApi
    • metricIntegrationLatency

      @Stability(Stable) @NotNull public Metric metricIntegrationLatency(@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.

      Specified by:
      metricIntegrationLatency in interface IHttpApi
      Parameters:
      props -
    • metricIntegrationLatency

      @Stability(Stable) @NotNull public Metric metricIntegrationLatency()
      Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend.
      Specified by:
      metricIntegrationLatency in interface IHttpApi
    • metricLatency

      @Stability(Stable) @NotNull public Metric metricLatency(@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.

      Specified by:
      metricLatency in interface IHttpApi
      Parameters:
      props -
    • metricLatency

      @Stability(Stable) @NotNull public Metric metricLatency()
      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.

      Specified by:
      metricLatency in interface IHttpApi
    • metricServerError

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

      Specified by:
      metricServerError in interface IHttpApi
      Parameters:
      props -
    • metricServerError

      @Stability(Stable) @NotNull public Metric metricServerError()
      Metric for the number of server-side errors captured in a given period.
      Specified by:
      metricServerError in interface IHttpApi
    • getApiEndpoint

      @Stability(Stable) @NotNull public String getApiEndpoint()
      Get the default endpoint for this API.
      Specified by:
      getApiEndpoint in interface IApi
    • getApiId

      @Stability(Stable) @NotNull public String getApiId()
      The identifier of this API Gateway API.
      Specified by:
      getApiId in interface IApi
    • getHttpApiId

      @Stability(Stable) @NotNull public String getHttpApiId()
      The identifier of the HTTP API.

      See Also:
    • getDefaultAuthorizationScopes

      @Stability(Stable) @Nullable public List<String> getDefaultAuthorizationScopes()
      Default OIDC scopes attached to all routes in the gateway, unless explicitly configured on the route.

      The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation.

      Specified by:
      getDefaultAuthorizationScopes in interface IHttpApi
    • getDefaultAuthorizer

      @Stability(Stable) @Nullable public IHttpRouteAuthorizer getDefaultAuthorizer()
      Default Authorizer applied to all routes in the gateway.
      Specified by:
      getDefaultAuthorizer in interface IHttpApi
    • getDefaultStage

      @Stability(Stable) @Nullable public IHttpStage getDefaultStage()
      The default stage of this API.
    • getDisableExecuteApiEndpoint

      @Stability(Stable) @Nullable public Boolean getDisableExecuteApiEndpoint()
      Specifies whether clients can invoke this HTTP API by using the default execute-api endpoint.
    • getHttpApiName

      @Stability(Stable) @Nullable public String getHttpApiName()
      A human friendly name for this HTTP API.

      Note that this is different from httpApiId.

    • getUrl

      @Stability(Stable) @Nullable public String getUrl()
      Get the URL to the default stage of this API.

      Returns undefined if createDefaultStage is unset.