Table of Contents

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 Construct
id string
props IMethodProps

Properties

Api

The API Gateway RestApi associated with this method.

public virtual IRestApi Api { get; }

Property Value

IRestApi

HttpMethod

public virtual string HttpMethod { get; }

Property Value

string

MethodArn

Returns an execute-api ARN for this method:.

public virtual string MethodArn { get; }

Property Value

string

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

string

Remarks

Attribute: true

Resource

public virtual IResource Resource { get; }

Property Value

IResource

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

RestApi

Remarks

Stability: Deprecated

TestMethodArn

Returns an execute-api ARN for this method's "test-invoke-stage" stage.

public virtual string TestMethodArn { get; }

Property Value

string

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