Class UsagePlan
Inherited Members
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class UsagePlan : Resource, IUsagePlan, IResource, IUsagePlanRef, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class UsagePlan Inherits Resource Implements IUsagePlan, IResource, IUsagePlanRef, IConstruct, IDependable, IEnvironmentAware
Remarks
ExampleMetadata: infused
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);
Synopsis
Constructors
| UsagePlan(Construct, string, IUsagePlanProps?) |
Properties
| PROPERTY_INJECTION_ID | Uniquely identifies this class. |
| UsagePlanId | Id of the usage plan. |
| UsagePlanRef | A reference to a UsagePlan resource. |
Methods
| AddApiKey(IApiKeyRef, IAddApiKeyOptions?) | Adds an ApiKey. |
| AddApiStage(IUsagePlanPerApiStage) | Adds an apiStage. |
| FromUsagePlanId(Construct, string, string) | Import an externally defined usage plan using its ARN. |
Constructors
UsagePlan(Construct, string, IUsagePlanProps?)
public UsagePlan(Construct scope, string id, IUsagePlanProps? props = null)
Parameters
- scope Construct
- id string
- props IUsagePlanProps
Remarks
ExampleMetadata: infused
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);
Properties
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
ExampleMetadata: infused
UsagePlanId
Id of the usage plan.
public virtual string UsagePlanId { get; }
Property Value
Remarks
Attribute: true
UsagePlanRef
A reference to a UsagePlan resource.
public virtual IUsagePlanReference UsagePlanRef { get; }
Property Value
Remarks
ExampleMetadata: infused
Methods
AddApiKey(IApiKeyRef, IAddApiKeyOptions?)
Adds an ApiKey.
public virtual void AddApiKey(IApiKeyRef apiKey, IAddApiKeyOptions? options = null)
Parameters
- apiKey IApiKeyRef
the api key to associate with this usage plan.
- options IAddApiKeyOptions
options that control the behaviour of this method.
Remarks
ExampleMetadata: infused
AddApiStage(IUsagePlanPerApiStage)
Adds an apiStage.
public virtual void AddApiStage(IUsagePlanPerApiStage apiStage)
Parameters
- apiStage IUsagePlanPerApiStage
Remarks
ExampleMetadata: infused
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
Remarks
ExampleMetadata: infused