Table of Contents

Class RestApiBase

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

Base implementation that are common to various implementations of IRestApi.

public abstract class RestApiBase : Resource, IRestApi, IResource, IConstruct, IConstruct, IDependable
Inheritance
RestApiBase
Implements
IResource
IConstruct
IConstruct
IDependable
Derived

Examples

using Amazon.CDK.AWS.Route53;
            using Amazon.CDK.AWS.Route53.Targets;

            RestApi api;
            var hostedZoneForExampleCom;


            new ARecord(this, "CustomDomainAliasRecord", new ARecordProps {
                Zone = hostedZoneForExampleCom,
                Target = RecordTarget.FromAlias(new ApiGateway(api))
            });

Remarks

ExampleMetadata: infused

Constructors

RestApiBase(Construct, string, IRestApiBaseProps?)

protected RestApiBase(Construct scope, string id, IRestApiBaseProps? props = null)

Parameters

scope Construct
id string
props IRestApiBaseProps

Properties

CloudWatchAccount

protected virtual CfnAccount? CloudWatchAccount { get; set; }

Property Value

CfnAccount

DeploymentStage

API Gateway stage that points to the latest deployment (if defined).

public virtual Stage DeploymentStage { get; set; }

Property Value

Stage

Remarks

If deploy is disabled, you will need to explicitly assign this value in order to set up integrations.

DomainName

The first domain name mapped to this API, if defined through the domainName configuration prop, or added via addDomainName.

public virtual DomainName_? DomainName { get; }

Property Value

DomainName_

LatestDeployment

API Gateway deployment that represents the latest changes of the API.

public virtual Deployment? LatestDeployment { get; }

Property Value

Deployment

Remarks

This resource will be automatically updated every time the REST API model changes. This will be undefined if deploy is false.

RestApiId

The ID of this API Gateway RestApi.

public abstract string RestApiId { get; }

Property Value

string

RestApiName

A human friendly name for this Rest API.

public virtual string RestApiName { get; }

Property Value

string

Remarks

Note that this is different from restApiId.

Attribute: true

RestApiRootResourceId

The resource ID of the root resource.

public abstract string RestApiRootResourceId { get; }

Property Value

string

Remarks

Attribute: true

Root

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

public abstract IResource Root { get; }

Property Value

IResource

Remarks

Resources and Methods are added to this resource.

Methods

AddApiKey(string, IApiKeyOptions?)

Add an ApiKey.

public virtual IApiKey AddApiKey(string id, IApiKeyOptions? options = null)

Parameters

id string
options IApiKeyOptions

Returns

IApiKey

AddDomainName(string, IDomainNameOptions)

Defines an API Gateway domain name and maps it to this API.

public virtual DomainName_ AddDomainName(string id, IDomainNameOptions options)

Parameters

id string

The construct id.

options IDomainNameOptions

custom domain options.

Returns

DomainName_

AddGatewayResponse(string, IGatewayResponseOptions)

Adds a new gateway response.

public virtual GatewayResponse AddGatewayResponse(string id, IGatewayResponseOptions options)

Parameters

id string
options IGatewayResponseOptions

Returns

GatewayResponse

AddUsagePlan(string, IUsagePlanProps?)

Adds a usage plan.

public virtual UsagePlan AddUsagePlan(string id, IUsagePlanProps? props = null)

Parameters

id string
props IUsagePlanProps

Returns

UsagePlan

ArnForExecuteApi(string?, string?, string?)

Gets the "execute-api" ARN.

public virtual string ArnForExecuteApi(string? method = null, string? path = null, string? stage = null)

Parameters

method string
path string
stage string

Returns

string

ConfigureCloudWatchRole(CfnRestApi)

[Obsolete("This method will be made internal. No replacement")]
protected virtual void ConfigureCloudWatchRole(CfnRestApi apiResource)

Parameters

apiResource CfnRestApi

Remarks

Stability: Deprecated

ConfigureDeployment(IRestApiBaseProps)

[Obsolete("This method will be made internal. No replacement")]
protected virtual void ConfigureDeployment(IRestApiBaseProps props)

Parameters

props IRestApiBaseProps

Remarks

Stability: Deprecated

Metric(string, IMetricOptions?)

Returns the given named metric for this API.

public virtual Metric Metric(string metricName, IMetricOptions? props = null)

Parameters

metricName string
props IMetricOptions

Returns

Metric

MetricCacheHitCount(IMetricOptions?)

Metric for the number of requests served from the API cache in a given period.

public virtual Metric MetricCacheHitCount(IMetricOptions? props = null)

Parameters

props IMetricOptions

Returns

Metric

Remarks

Default: sum over 5 minutes

MetricCacheMissCount(IMetricOptions?)

Metric for the number of requests served from the backend in a given period, when API caching is enabled.

public virtual Metric MetricCacheMissCount(IMetricOptions? props = null)

Parameters

props IMetricOptions

Returns

Metric

Remarks

Default: sum over 5 minutes

MetricClientError(IMetricOptions?)

Metric for the number of client-side errors captured in a given period.

public virtual Metric MetricClientError(IMetricOptions? props = null)

Parameters

props IMetricOptions

Returns

Metric

Remarks

Default: sum over 5 minutes

MetricCount(IMetricOptions?)

Metric for the total number API requests in a given period.

public virtual Metric MetricCount(IMetricOptions? props = null)

Parameters

props IMetricOptions

Returns

Metric

Remarks

Default: sample count over 5 minutes

MetricIntegrationLatency(IMetricOptions?)

Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend.

public virtual Metric MetricIntegrationLatency(IMetricOptions? props = null)

Parameters

props IMetricOptions

Returns

Metric

Remarks

Default: average over 5 minutes.

MetricLatency(IMetricOptions?)

The time between when API Gateway receives a request from a client and when it returns a response to the client.

public virtual Metric MetricLatency(IMetricOptions? props = null)

Parameters

props IMetricOptions

Returns

Metric

Remarks

The latency includes the integration latency and other API Gateway overhead.

Default: average over 5 minutes.

MetricServerError(IMetricOptions?)

Metric for the number of server-side errors captured in a given period.

public virtual Metric MetricServerError(IMetricOptions? props = null)

Parameters

props IMetricOptions

Returns

Metric

Remarks

Default: sum over 5 minutes

UrlForPath(string?)

Returns the URL for an HTTP path.

public virtual string UrlForPath(string? path = null)

Parameters

path string

Returns

string

Remarks

Fails if deploymentStage is not set either by deploy or explicitly.