Table of Contents

Class UsagePlan

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll
public class UsagePlan : Resource, IUsagePlan, IResource, IConstruct, IConstruct, IDependable
Inheritance
UsagePlan
Implements
IResource
IConstruct
IConstruct
IDependable

Examples

LambdaIntegration integration;


            var api = new RestApi(this, "hello-api");

            var v1 = api.Root.AddResource("v1");
            var echo = v1.AddResource("echo");
            var echoMethod = echo.AddMethod("GET", integration, new MethodOptions { ApiKeyRequired = true });

            var plan = api.AddUsagePlan("UsagePlan", new UsagePlanProps {
                Name = "Easy",
                Throttle = new ThrottleSettings {
                    RateLimit = 10,
                    BurstLimit = 2
                }
            });

            var key = api.AddApiKey("ApiKey");
            plan.AddApiKey(key);

Remarks

ExampleMetadata: infused

Constructors

UsagePlan(Construct, string, IUsagePlanProps?)

public UsagePlan(Construct scope, string id, IUsagePlanProps? props = null)

Parameters

scope Construct
id string
props IUsagePlanProps

Properties

UsagePlanId

Id of the usage plan.

public virtual string UsagePlanId { get; }

Property Value

string

Remarks

Attribute: true

Methods

AddApiKey(IApiKey, IAddApiKeyOptions?)

Adds an ApiKey.

public virtual void AddApiKey(IApiKey apiKey, IAddApiKeyOptions? options = null)

Parameters

apiKey IApiKey

the api key to associate with this usage plan.

options IAddApiKeyOptions

options that control the behaviour of this method.

AddApiStage(IUsagePlanPerApiStage)

Adds an apiStage.

public virtual void AddApiStage(IUsagePlanPerApiStage apiStage)

Parameters

apiStage IUsagePlanPerApiStage

FromUsagePlanId(Construct, string, string)

Import an externally defined usage plan using its ARN.

public static IUsagePlan FromUsagePlanId(Construct scope, string id, string usagePlanId)

Parameters

scope Construct

the construct that will "own" the imported usage plan.

id string

the id of the imported usage plan in the construct tree.

usagePlanId string

the id of an existing usage plan.

Returns

IUsagePlan