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
-
IResourceIConstructIConstructIDependable
- 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
Constructid
stringprops
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
RestApiRootResourceId
The resource ID of the root resource.
public override string RestApiRootResourceId { get; }
Property Value
Root
Represents the root resource of this API endpoint ('/').
public override IResource Root { get; }
Property Value
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
Methods
AddModel(string, IModelOptions)
Adds a new model.
public virtual Model AddModel(string id, IModelOptions props)
Parameters
id
stringprops
IModelOptions
Returns
AddRequestValidator(string, IRequestValidatorOptions)
Adds a new request validator.
public virtual RequestValidator AddRequestValidator(string id, IRequestValidatorOptions props)
Parameters
id
stringprops
IRequestValidatorOptions
Returns
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
Constructid
stringattrs
IRestApiAttributes
Returns
FromRestApiId(Construct, string, string)
Import an existing RestApi.
public static IRestApi FromRestApiId(Construct scope, string id, string restApiId)
Parameters
Returns
Validate()
Performs validation of the REST API.
protected override string[] Validate()
Returns
- string[]