Class RestApi
Represents a REST API in Amazon API Gateway.
Inherited Members
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class RestApi : RestApiBase, IRestApi, IResource
Syntax (vb)
Public Class RestApi
Inherits RestApiBase
Implements IRestApi, IResource
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
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));
Synopsis
Constructors
RestApi(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
RestApi(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
RestApi(Construct, String, IRestApiProps) |
Properties
Methods | The list of methods bound to this RestApi. |
RestApiId | The ID of this API Gateway RestApi. |
RestApiRootResourceId | The resource ID of the root resource. |
Root | Represents the root resource of this API endpoint ('/'). |
Methods
AddModel(String, IModelOptions) | Adds a new model. |
AddRequestValidator(String, IRequestValidatorOptions) | Adds a new request validator. |
FromRestApiAttributes(Construct, String, IRestApiAttributes) | Import an existing RestApi that can be configured with additional Methods and Resources. |
FromRestApiId(Construct, String, String) | Import an existing RestApi. |
IsRestApi(Object) | Return whether the given object is a |
Constructors
RestApi(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected RestApi(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
RestApi(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected RestApi(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
RestApi(Construct, String, IRestApiProps)
public RestApi(Construct scope, string id, IRestApiProps props = null)
Parameters
- scope Constructs.Construct
- id System.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
System.String
Overrides
RestApiRootResourceId
The resource ID of the root resource.
public override string RestApiRootResourceId { get; }
Property Value
System.String
Overrides
Root
Represents the root resource of this API endpoint ('/').
public override IResource Root { get; }
Property Value
Overrides
Remarks
Resources and Methods are added to this resource.
Methods
AddModel(String, IModelOptions)
Adds a new model.
public virtual Model AddModel(string id, IModelOptions props)
Parameters
- id System.String
- props IModelOptions
Returns
AddRequestValidator(String, IRequestValidatorOptions)
Adds a new request validator.
public virtual RequestValidator AddRequestValidator(string id, IRequestValidatorOptions props)
Parameters
- id System.String
- props 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 Constructs.Construct
- id System.String
- attrs IRestApiAttributes
Returns
FromRestApiId(Construct, String, String)
Import an existing RestApi.
public static IRestApi FromRestApiId(Construct scope, string id, string restApiId)
Parameters
- scope Constructs.Construct
- id System.String
- restApiId System.String
Returns
IsRestApi(Object)
Return whether the given object is a RestApi
.
public static bool IsRestApi(object x)
Parameters
- x System.Object
Returns
System.Boolean