Table of Contents

Class RestApi

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll

Represents a REST API in Amazon API Gateway.

public class RestApi : RestApiBase, IRestApi, IResource, IConstruct, IConstruct, IDependable
Inheritance
RestApi
Implements
IResource
IConstruct
IConstruct
IDependable
Derived
Inherited Members

Examples

var stateMachine = new StateMachine(this, "MyStateMachine", new StateMachineProps {
                 StateMachineType = StateMachineType.EXPRESS,
                 Definition = Chain.Start(new Pass(this, "Pass"))
             });

             var api = new RestApi(this, "Api", new RestApiProps {
                 RestApiName = "MyApi"
             });
             api.Root.AddMethod("GET", StepFunctionsIntegration.StartExecution(stateMachine));

Remarks

Use addResource and addMethod to configure the API model.

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

ExampleMetadata: infused

Constructors

RestApi(Construct, string, IRestApiProps?)

public RestApi(Construct scope, string id, IRestApiProps? props = null)

Parameters

scope Construct
id string
props IRestApiProps

Properties

Methods

The list of methods bound to this RestApi.

public virtual Method[] Methods { get; }

Property Value

Method[]

RestApiId

The ID of this API Gateway RestApi.

public override string RestApiId { get; }

Property Value

string

RestApiRootResourceId

The resource ID of the root resource.

public override string RestApiRootResourceId { get; }

Property Value

string

Root

Represents the root resource of this API endpoint ('/').

public override IResource Root { get; }

Property Value

IResource

Remarks

Resources and Methods are added to this resource.

Url

The deployed root URL of this REST API.

public virtual string Url { get; }

Property Value

string

Methods

AddModel(string, IModelOptions)

Adds a new model.

public virtual Model AddModel(string id, IModelOptions props)

Parameters

id string
props IModelOptions

Returns

Model

AddRequestValidator(string, IRequestValidatorOptions)

Adds a new request validator.

public virtual RequestValidator AddRequestValidator(string id, IRequestValidatorOptions props)

Parameters

id string
props IRequestValidatorOptions

Returns

RequestValidator

FromRestApiAttributes(Construct, string, IRestApiAttributes)

Import an existing RestApi that can be configured with additional Methods and Resources.

public static IRestApi FromRestApiAttributes(Construct scope, string id, IRestApiAttributes attrs)

Parameters

scope Construct
id string
attrs IRestApiAttributes

Returns

IRestApi

FromRestApiId(Construct, string, string)

Import an existing RestApi.

public static IRestApi FromRestApiId(Construct scope, string id, string restApiId)

Parameters

scope Construct
id string
restApiId string

Returns

IRestApi

Validate()

Performs validation of the REST API.

protected override string[] Validate()

Returns

string[]