Show / Hide Table of Contents

Class RestApi

Represents a REST API in Amazon API Gateway.

Inheritance
object
Resource
RestApiBase
RestApi
LambdaRestApi
StepFunctionsRestApi
Implements
IRestApi
IRestApiRef
IResourceWithPolicy
IResource
IConstruct
IDependable
IResourceWithPolicyV2
IEnvironmentAware
Inherited Members
RestApiBase.AddApiKey(string, IApiKeyOptions)
RestApiBase.AddDomainName(string, IDomainNameOptions)
RestApiBase.AddGatewayResponse(string, IGatewayResponseOptions)
RestApiBase.AddUsagePlan(string, IUsagePlanProps)
RestApiBase.ArnForExecuteApi(string, string, string)
RestApiBase.GrantInvokeFromVpcEndpointsOnly(IVpcEndpoint[])
RestApiBase.Metric(string, IMetricOptions)
RestApiBase.MetricCacheHitCount(IMetricOptions)
RestApiBase.MetricCacheMissCount(IMetricOptions)
RestApiBase.MetricClientError(IMetricOptions)
RestApiBase.MetricCount(IMetricOptions)
RestApiBase.MetricIntegrationLatency(IMetricOptions)
RestApiBase.MetricLatency(IMetricOptions)
RestApiBase.MetricServerError(IMetricOptions)
RestApiBase.UrlForPath(string)
RestApiBase.RestApiName
RestApiBase.RestApiRef
RestApiBase.Url
RestApiBase.DomainName
RestApiBase.LatestDeployment
RestApiBase.DeploymentStage
RestApiBase.CloudWatchAccount
RestApiBase.ResourcePolicy
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyCrossStackReferenceStrength(ReferenceStrength)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.With(params IMixin[])
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class RestApi : RestApiBase, IRestApi, IRestApiRef, IResourceWithPolicy, IResource, IConstruct, IDependable, IResourceWithPolicyV2, IEnvironmentAware
Syntax (vb)
Public Class RestApi Inherits RestApiBase Implements IRestApi, IRestApiRef, IResourceWithPolicy, IResource, IConstruct, IDependable, IResourceWithPolicyV2, IEnvironmentAware
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: fixture=default infused

Examples
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
                 GatewayName = "my-gateway"
             });

             var api = new RestApi(this, "MyApi", new RestApiProps {
                 RestApiName = "my-api"
             });

             // Uses IAM authorization for outbound auth by default
             var apiGatewayTarget = gateway.AddApiGatewayTarget("MyApiGatewayTarget", new AddApiGatewayTargetOptions {
                 RestApi = api,
                 ApiGatewayToolConfiguration = new ApiGatewayToolConfiguration {
                     ToolFilters = new [] { new ApiGatewayToolFilter {
                         FilterPath = "/pets/*",
                         Methods = new [] { ApiGatewayHttpMethod.GET }
                     } }
                 }
             });

Synopsis

Constructors

RestApi(Construct, string, IRestApiProps?)

Represents a REST API in Amazon API Gateway.

Properties

Methods

The list of methods bound to this RestApi.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

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.

AddToResourcePolicy(PolicyStatement)

Adds a statement to the resource policy associated with this rest api.

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 RestApi.

Constructors

RestApi(Construct, string, IRestApiProps?)

Represents a REST API in Amazon API Gateway.

public RestApi(Construct scope, string id, IRestApiProps? props = null)
Parameters
scope Construct
id string
props IRestApiProps
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: fixture=default infused

Examples
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
                 GatewayName = "my-gateway"
             });

             var api = new RestApi(this, "MyApi", new RestApiProps {
                 RestApiName = "my-api"
             });

             // Uses IAM authorization for outbound auth by default
             var apiGatewayTarget = gateway.AddApiGatewayTarget("MyApiGatewayTarget", new AddApiGatewayTargetOptions {
                 RestApi = api,
                 ApiGatewayToolConfiguration = new ApiGatewayToolConfiguration {
                     ToolFilters = new [] { new ApiGatewayToolFilter {
                         FilterPath = "/pets/*",
                         Methods = new [] { ApiGatewayHttpMethod.GET }
                     } }
                 }
             });

Properties

Methods

The list of methods bound to this RestApi.

public virtual Method[] Methods { get; }
Property Value

Method[]

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: fixture=default infused

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

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: fixture=default infused

RestApiId

The ID of this API Gateway RestApi.

public override string RestApiId { get; }
Property Value

string

Overrides
RestApiBase.RestApiId
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: fixture=default infused

RestApiRootResourceId

The resource ID of the root resource.

public override string RestApiRootResourceId { get; }
Property Value

string

Overrides
RestApiBase.RestApiRootResourceId
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: fixture=default infused

Root

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

public override IResource Root { get; }
Property Value

IResource

Overrides
RestApiBase.Root
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 string
props IModelOptions
Returns

Model

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: fixture=default infused

AddRequestValidator(string, IRequestValidatorOptions)

Adds a new request validator.

public virtual RequestValidator AddRequestValidator(string id, IRequestValidatorOptions props)
Parameters
id string
props IRequestValidatorOptions
Returns

RequestValidator

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: fixture=default infused

AddToResourcePolicy(PolicyStatement)

Adds a statement to the resource policy associated with this rest api.

public override IAddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)
Parameters
statement PolicyStatement

The policy statement to add.

Returns

IAddToResourcePolicyResult

Overrides
RestApiBase.AddToResourcePolicy(PolicyStatement)
Remarks

A resource policy will be automatically created upon the first call to addToResourcePolicy.

Note that this does not work with imported rest api.

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

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: fixture=default infused

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

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: fixture=default infused

IsRestApi(object)

Return whether the given object is a RestApi.

public static bool IsRestApi(object x)
Parameters
x object
Returns

bool

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: fixture=default infused

Implements

IRestApi
IRestApiRef
IResourceWithPolicy
IResource
Constructs.IConstruct
Constructs.IDependable
IResourceWithPolicyV2
IEnvironmentAware
Back to top Generated by DocFX