Class ApiEventSource.Builder

java.lang.Object
software.amazon.awscdk.services.lambda.eventsources.ApiEventSource.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<ApiEventSource>
Enclosing class:
ApiEventSource

@Stability(Stable) public static final class ApiEventSource.Builder extends Object implements software.amazon.jsii.Builder<ApiEventSource>
A fluent builder for ApiEventSource.
  • Method Details

    • create

      @Stability(Stable) public static ApiEventSource.Builder create(String method, String path)
      Parameters:
      method - This parameter is required.
      path - This parameter is required.
      Returns:
      a new instance of ApiEventSource.Builder.
    • apiKeyRequired

      @Stability(Stable) public ApiEventSource.Builder apiKeyRequired(Boolean apiKeyRequired)
      Indicates whether the method requires clients to submit a valid API key.

      Default: false

      Parameters:
      apiKeyRequired - Indicates whether the method requires clients to submit a valid API key. This parameter is required.
      Returns:
      this
    • authorizationScopes

      @Stability(Stable) public ApiEventSource.Builder authorizationScopes(List<String> authorizationScopes)
      A list of authorization scopes configured on the method.

      The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation.

      Default: - no authorization scopes

      Parameters:
      authorizationScopes - A list of authorization scopes configured on the method. This parameter is required.
      Returns:
      this
      See Also:
    • authorizationType

      @Stability(Stable) public ApiEventSource.Builder authorizationType(AuthorizationType authorizationType)
      Method authorization. If the value is set of Custom, an authorizer must also be specified.

      If you're using one of the authorizers that are available via the Authorizer class, such as Authorizer#token(), it is recommended that this option not be specified. The authorizer will take care of setting the correct authorization type. However, specifying an authorization type using this property that conflicts with what is expected by the Authorizer will result in an error.

      Default: - open access unless `authorizer` is specified

      Parameters:
      authorizationType - Method authorization. If the value is set of Custom, an authorizer must also be specified. This parameter is required.
      Returns:
      this
    • authorizer

      @Stability(Stable) public ApiEventSource.Builder authorizer(IAuthorizer authorizer)
      If authorizationType is Custom, this specifies the ID of the method authorizer resource.

      If specified, the value of authorizationType must be set to Custom

      Parameters:
      authorizer - If authorizationType is Custom, this specifies the ID of the method authorizer resource. This parameter is required.
      Returns:
      this
    • methodResponses

      @Stability(Stable) public ApiEventSource.Builder methodResponses(List<? extends MethodResponse> methodResponses)
      The responses that can be sent to the client who calls the method.

      Default: None This property is not required, but if these are not supplied for a Lambda proxy integration, the Lambda function must return a value of the correct format, for the integration response to be correctly mapped to a response to the client.

      Parameters:
      methodResponses - The responses that can be sent to the client who calls the method. This parameter is required.
      Returns:
      this
      See Also:
    • operationName

      @Stability(Stable) public ApiEventSource.Builder operationName(String operationName)
      A friendly operation name for the method.

      For example, you can assign the OperationName of ListPets for the GET /pets method.

      Parameters:
      operationName - A friendly operation name for the method. This parameter is required.
      Returns:
      this
    • requestModels

      @Stability(Stable) public ApiEventSource.Builder requestModels(Map<String,? extends IModel> requestModels)
      The models which describe data structure of request payload.

      When combined with requestValidator or requestValidatorOptions, the service will validate the API request payload before it reaches the API's Integration (including proxies). Specify requestModels as key-value pairs, with a content type (e.g. 'application/json') as the key and an API Gateway Model as the value.

      Example:

       RestApi api;
       Function userLambda;
       Model userModel = api.addModel("UserModel", ModelOptions.builder()
               .schema(JsonSchema.builder()
                       .type(JsonSchemaType.OBJECT)
                       .properties(Map.of(
                               "userId", JsonSchema.builder()
                                       .type(JsonSchemaType.STRING)
                                       .build(),
                               "name", JsonSchema.builder()
                                       .type(JsonSchemaType.STRING)
                                       .build()))
                       .required(List.of("userId"))
                       .build())
               .build());
       api.root.addResource("user").addMethod("POST",
       new LambdaIntegration(userLambda), MethodOptions.builder()
               .requestModels(Map.of(
                       "application/json", userModel))
               .build());
       

      Parameters:
      requestModels - The models which describe data structure of request payload. This parameter is required.
      Returns:
      this
      See Also:
    • requestParameters

      @Stability(Stable) public ApiEventSource.Builder requestParameters(Map<String,? extends Boolean> requestParameters)
      The request parameters that API Gateway accepts.

      Specify request parameters as key-value pairs (string-to-Boolean mapping), with a source as the key and a Boolean as the value. The Boolean specifies whether a parameter is required. A source must match the format method.request.location.name, where the location is querystring, path, or header, and name is a valid, unique parameter name.

      Default: None

      Parameters:
      requestParameters - The request parameters that API Gateway accepts. This parameter is required.
      Returns:
      this
    • requestValidator

      @Stability(Stable) public ApiEventSource.Builder requestValidator(IRequestValidator requestValidator)
      The ID of the associated request validator.

      Only one of requestValidator or requestValidatorOptions must be specified. Works together with requestModels or requestParameters to validate the request before it reaches integration like Lambda Proxy Integration.

      Default: - No default validator

      Parameters:
      requestValidator - The ID of the associated request validator. This parameter is required.
      Returns:
      this
    • requestValidatorOptions

      @Stability(Stable) public ApiEventSource.Builder requestValidatorOptions(RequestValidatorOptions requestValidatorOptions)
      Request validator options to create new validator Only one of requestValidator or requestValidatorOptions must be specified.

      Works together with requestModels or requestParameters to validate the request before it reaches integration like Lambda Proxy Integration.

      Default: - No default validator

      Parameters:
      requestValidatorOptions - Request validator options to create new validator Only one of requestValidator or requestValidatorOptions must be specified. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public ApiEventSource build()
      Specified by:
      build in interface software.amazon.jsii.Builder<ApiEventSource>
      Returns:
      a newly built instance of ApiEventSource.