Class Method
Inherited Members
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Method : Resource, IResource
Syntax (vb)
Public Class Method
Inherits Resource
Implements IResource
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
Method(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Method(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Method(Construct, String, IMethodProps) |
Properties
Api | The API Gateway RestApi associated with this method. |
HttpMethod | |
MethodArn | Returns an execute-api ARN for this method:. |
MethodId | |
Resource | |
TestMethodArn | Returns an execute-api ARN for this method's "test-invoke-stage" stage. |
Methods
AddMethodResponse(IMethodResponse) | Add a method response to this method. |
GrantExecute(IGrantable) | Grants an IAM principal permission to invoke this method. |
Metric(String, IStage, IMetricOptions) | Returns the given named metric for this API method. |
MetricCacheHitCount(IStage, IMetricOptions) | Metric for the number of requests served from the API cache in a given period. |
MetricCacheMissCount(IStage, IMetricOptions) | Metric for the number of requests served from the backend in a given period, when API caching is enabled. |
MetricClientError(IStage, IMetricOptions) | Metric for the number of client-side errors captured in a given period. |
MetricCount(IStage, IMetricOptions) | Metric for the total number API requests in a given period. |
MetricIntegrationLatency(IStage, IMetricOptions) | Metric for the time between when API Gateway relays a request to the backend and when it receives a response from the backend. |
MetricLatency(IStage, IMetricOptions) | The time between when API Gateway receives a request from a client and when it returns a response to the client. |
MetricServerError(IStage, IMetricOptions) | Metric for the number of server-side errors captured in a given period. |
Constructors
Method(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Method(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Method(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Method(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Method(Construct, String, IMethodProps)
public Method(Construct scope, string id, IMethodProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props 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
System.String
MethodArn
Returns an execute-api ARN for this method:.
public virtual string MethodArn { get; }
Property Value
System.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
System.String
Remarks
Attribute: true
Resource
TestMethodArn
Returns an execute-api ARN for this method's "test-invoke-stage" stage.
public virtual string TestMethodArn { get; }
Property Value
System.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
Remarks
You should only add one method reponse for every status code. The API allows it for historical reasons, but will add a warning if this happens. If you do, your Method will nondeterministically use one of the responses, and ignore the rest.
GrantExecute(IGrantable)
Grants an IAM principal permission to invoke this method.
public virtual Grant GrantExecute(IGrantable grantee)
Parameters
- grantee IGrantable
the principal.
Returns
Metric(String, IStage, IMetricOptions)
Returns the given named metric for this API method.
public virtual Metric Metric(string metricName, IStage stage, IMetricOptions props = null)
Parameters
- metricName System.String
- stage IStage
- props IMetricOptions
Returns
MetricCacheHitCount(IStage, IMetricOptions)
Metric for the number of requests served from the API cache in a given period.
public virtual Metric MetricCacheHitCount(IStage stage, IMetricOptions props = null)
Parameters
- stage IStage
- props IMetricOptions
Returns
Remarks
Default: - sum over 5 minutes
MetricCacheMissCount(IStage, IMetricOptions)
Metric for the number of requests served from the backend in a given period, when API caching is enabled.
public virtual Metric MetricCacheMissCount(IStage stage, IMetricOptions props = null)
Parameters
- stage IStage
- props IMetricOptions
Returns
Remarks
Default: - sum over 5 minutes
MetricClientError(IStage, IMetricOptions)
Metric for the number of client-side errors captured in a given period.
public virtual Metric MetricClientError(IStage stage, IMetricOptions props = null)
Parameters
- stage IStage
- props IMetricOptions
Returns
Remarks
Default: - sum over 5 minutes
MetricCount(IStage, IMetricOptions)
Metric for the total number API requests in a given period.
public virtual Metric MetricCount(IStage stage, IMetricOptions props = null)
Parameters
- stage IStage
- props IMetricOptions
Returns
Remarks
Default: - sample count over 5 minutes
MetricIntegrationLatency(IStage, 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(IStage stage, IMetricOptions props = null)
Parameters
- stage IStage
- props IMetricOptions
Returns
Remarks
Default: - average over 5 minutes.
MetricLatency(IStage, 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(IStage stage, IMetricOptions props = null)
Parameters
- stage IStage
- props IMetricOptions
Returns
Remarks
The latency includes the integration latency and other API Gateway overhead.
Default: - average over 5 minutes.
MetricServerError(IStage, IMetricOptions)
Metric for the number of server-side errors captured in a given period.
public virtual Metric MetricServerError(IStage stage, IMetricOptions props = null)
Parameters
- stage IStage
- props IMetricOptions
Returns
Remarks
Default: - sum over 5 minutes