java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IResource, IRestApi, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable
Direct Known Subclasses:
LambdaRestApi, StepFunctionsRestApi

@Generated(value="jsii-pacmak/1.94.0 (build b380f01)", date="2024-03-14T22:21:49.568Z") @Stability(Stable) public class RestApi extends RestApiBase
Represents a REST API in Amazon API Gateway.

Use addResource and addMethod to configure the API model.

By default, the API will automatically be deployed and accessible from a public endpoint.

Example:

 Bucket destinationBucket = new Bucket(this, "Bucket");
 Role deliveryStreamRole = Role.Builder.create(this, "Role")
         .assumedBy(new ServicePrincipal("firehose.amazonaws.com"))
         .build();
 CfnDeliveryStream stream = CfnDeliveryStream.Builder.create(this, "MyStream")
         .deliveryStreamName("amazon-apigateway-delivery-stream")
         .s3DestinationConfiguration(S3DestinationConfigurationProperty.builder()
                 .bucketArn(destinationBucket.getBucketArn())
                 .roleArn(deliveryStreamRole.getRoleArn())
                 .build())
         .build();
 RestApi api = RestApi.Builder.create(this, "books")
         .deployOptions(StageOptions.builder()
                 .accessLogDestination(new FirehoseLogDestination(stream))
                 .accessLogFormat(AccessLogFormat.jsonWithStandardFields())
                 .build())
         .build();
 
  • Constructor Details

    • RestApi

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

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

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

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

    • fromRestApiAttributes

      @Stability(Stable) @NotNull public static IRestApi fromRestApiAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull RestApiAttributes attrs)
      Import an existing RestApi that can be configured with additional Methods and Resources.

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

      @Stability(Stable) @NotNull public static IRestApi fromRestApiId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String restApiId)
      Import an existing RestApi.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      restApiId - This parameter is required.
    • addModel

      @Stability(Stable) @NotNull public Model addModel(@NotNull String id, @NotNull ModelOptions props)
      Adds a new model.

      Parameters:
      id - This parameter is required.
      props - This parameter is required.
    • addRequestValidator

      @Stability(Stable) @NotNull public RequestValidator addRequestValidator(@NotNull String id, @NotNull RequestValidatorOptions props)
      Adds a new request validator.

      Parameters:
      id - This parameter is required.
      props - This parameter is required.
    • getMethods

      @Stability(Stable) @NotNull public List<Method> getMethods()
      The list of methods bound to this RestApi.
    • getRestApiId

      @Stability(Stable) @NotNull public String getRestApiId()
      The ID of this API Gateway RestApi.
      Specified by:
      getRestApiId in interface IRestApi
      Specified by:
      getRestApiId in class RestApiBase
    • getRestApiRootResourceId

      @Stability(Stable) @NotNull public String getRestApiRootResourceId()
      The resource ID of the root resource.
      Specified by:
      getRestApiRootResourceId in interface IRestApi
      Specified by:
      getRestApiRootResourceId in class RestApiBase
    • getRoot

      @Stability(Stable) @NotNull public IResource getRoot()
      Represents the root resource of this API endpoint ('/').

      Resources and Methods are added to this resource.

      Specified by:
      getRoot in interface IRestApi
      Specified by:
      getRoot in class RestApiBase