Class Method
- Namespace
- Amazon.CDK.AWS.APIGateway
- Assembly
- Amazon.CDK.AWS.APIGateway.dll
public class Method : Resource
- Inheritance
-
Method
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
Method(Construct, string, IMethodProps)
public Method(Construct scope, string id, IMethodProps props)
Parameters
scope
Constructid
stringprops
IMethodProps
Properties
Api
The API Gateway RestApi associated with this method.
public virtual IRestApi Api { get; }
Property Value
HttpMethod
public virtual string HttpMethod { get; }
Property Value
MethodArn
Returns an execute-api ARN for this method:.
public virtual string MethodArn { get; }
Property Value
Remarks
arn:aws:execute-api:{region}:{account}:{restApiId}/{stage}/{method}/{path}
NOTE: {stage} will refer to the restApi.deploymentStage
, which will
automatically set if auto-deploy is enabled, or can be explicitly assigned.
When not configured, {stage} will be set to '*', as a shorthand for 'all stages'.
Attribute: true
MethodId
public virtual string MethodId { get; }
Property Value
Remarks
Attribute: true
Resource
public virtual IResource Resource { get; }
Property Value
RestApi
(deprecated) The RestApi associated with this Method.
[Obsolete("- Throws an error if this Resource is not associated with an instance of `RestApi`. Use `api` instead.")]
public virtual RestApi RestApi { get; }
Property Value
Remarks
Stability: Deprecated
TestMethodArn
Returns an execute-api ARN for this method's "test-invoke-stage" stage.
public virtual string TestMethodArn { get; }
Property Value
Remarks
This stage is used by the AWS Console UI when testing the method.
Methods
AddMethodResponse(IMethodResponse)
Add a method response to this method.
public virtual void AddMethodResponse(IMethodResponse methodResponse)
Parameters
methodResponse
IMethodResponse