ApiEventSource Class
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_apigateway as apigateway } from 'aws-cdk-lib';
import { aws_lambda_event_sources as lambda_event_sources } from 'aws-cdk-lib';
declare const authorizer: apigateway.Authorizer;
declare const model: apigateway.Model;
declare const requestValidator: apigateway.RequestValidator;
const apiEventSource = new lambda_event_sources.ApiEventSource('method', 'path', /* all optional props */ {
apiKeyRequired: false,
authorizationScopes: ['authorizationScopes'],
authorizationType: apigateway.AuthorizationType.NONE,
authorizer: authorizer,
methodResponses: [{
statusCode: 'statusCode',
// the properties below are optional
responseModels: {
responseModelsKey: model,
},
responseParameters: {
responseParametersKey: false,
},
}],
operationName: 'operationName',
requestModels: {
requestModelsKey: model,
},
requestParameters: {
requestParametersKey: false,
},
requestValidator: requestValidator,
requestValidatorOptions: {
requestValidatorName: 'requestValidatorName',
validateRequestBody: false,
validateRequestParameters: false,
},
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_apigateway as apigateway
from aws_cdk import aws_lambda_event_sources as lambda_event_sources
# authorizer: apigateway.Authorizer
# model: apigateway.Model
# request_validator: apigateway.RequestValidator
api_event_source = lambda_event_sources.ApiEventSource("method", "path",
api_key_required=False,
authorization_scopes=["authorizationScopes"],
authorization_type=apigateway.AuthorizationType.NONE,
authorizer=authorizer,
method_responses=[apigateway.MethodResponse(
status_code="statusCode",
# the properties below are optional
response_models={
"response_models_key": model
},
response_parameters={
"response_parameters_key": False
}
)],
operation_name="operationName",
request_models={
"request_models_key": model
},
request_parameters={
"request_parameters_key": False
},
request_validator=request_validator,
request_validator_options=apigateway.RequestValidatorOptions(
request_validator_name="requestValidatorName",
validate_request_body=False,
validate_request_parameters=False
)
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.apigateway.*;
import software.amazon.awscdk.services.lambda.eventsources.*;
Authorizer authorizer;
Model model;
RequestValidator requestValidator;
ApiEventSource apiEventSource = ApiEventSource.Builder.create("method", "path")
.apiKeyRequired(false)
.authorizationScopes(List.of("authorizationScopes"))
.authorizationType(AuthorizationType.NONE)
.authorizer(authorizer)
.methodResponses(List.of(MethodResponse.builder()
.statusCode("statusCode")
// the properties below are optional
.responseModels(Map.of(
"responseModelsKey", model))
.responseParameters(Map.of(
"responseParametersKey", false))
.build()))
.operationName("operationName")
.requestModels(Map.of(
"requestModelsKey", model))
.requestParameters(Map.of(
"requestParametersKey", false))
.requestValidator(requestValidator)
.requestValidatorOptions(RequestValidatorOptions.builder()
.requestValidatorName("requestValidatorName")
.validateRequestBody(false)
.validateRequestParameters(false)
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.APIGateway;
using Amazon.CDK.AWS.Lambda.EventSources;
Authorizer authorizer;
Model model;
RequestValidator requestValidator;
var apiEventSource = new ApiEventSource("method", "path", new MethodOptions {
ApiKeyRequired = false,
AuthorizationScopes = new [] { "authorizationScopes" },
AuthorizationType = AuthorizationType.NONE,
Authorizer = authorizer,
MethodResponses = new [] { new MethodResponse {
StatusCode = "statusCode",
// the properties below are optional
ResponseModels = new Dictionary<string, IModel> {
{ "responseModelsKey", model }
},
ResponseParameters = new Dictionary<string, boolean> {
{ "responseParametersKey", false }
}
} },
OperationName = "operationName",
RequestModels = new Dictionary<string, IModel> {
{ "requestModelsKey", model }
},
RequestParameters = new Dictionary<string, boolean> {
{ "requestParametersKey", false }
},
RequestValidator = requestValidator,
RequestValidatorOptions = new RequestValidatorOptions {
RequestValidatorName = "requestValidatorName",
ValidateRequestBody = false,
ValidateRequestParameters = false
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var authorizer Authorizer
var model Model
var requestValidator RequestValidator
apiEventSource := awscdk.Aws_lambda_event_sources.NewApiEventSource(jsii.String("method"), jsii.String("path"), &MethodOptions{
ApiKeyRequired: jsii.Boolean(false),
AuthorizationScopes: []*string{
jsii.String("authorizationScopes"),
},
AuthorizationType: awscdk.Aws_apigateway.AuthorizationType_NONE,
Authorizer: authorizer,
MethodResponses: []MethodResponse{
&MethodResponse{
StatusCode: jsii.String("statusCode"),
// the properties below are optional
ResponseModels: map[string]IModel{
"responseModelsKey": model,
},
ResponseParameters: map[string]*bool{
"responseParametersKey": jsii.Boolean(false),
},
},
},
OperationName: jsii.String("operationName"),
RequestModels: map[string]IModel{
"requestModelsKey": model,
},
RequestParameters: map[string]*bool{
"requestParametersKey": jsii.Boolean(false),
},
RequestValidator: requestValidator,
RequestValidatorOptions: &RequestValidatorOptions{
RequestValidatorName: jsii.String("requestValidatorName"),
ValidateRequestBody: jsii.Boolean(false),
ValidateRequestParameters: jsii.Boolean(false),
},
})
Initializer
ts
new ApiEventSource(method: string, path: string, options?: MethodOptions)
python
ApiEventSource(method: str, path: str, options: typing.Optional[MethodOptions] = None)
java
new ApiEventSource(String method, String path, MethodOptions options)
csharp
new ApiEventSource(string method, string path, MethodOptions? options = null)
go
NewApiEventSource(Method *string, Path *string, Options MethodOptions)