IntegrationResponse

class aws_cdk.aws_apigateway.IntegrationResponse(*, status_code, content_handling=None, response_parameters=None, response_templates=None, selection_pattern=None)

Bases: object

Parameters:
  • status_code (str) – The status code that API Gateway uses to map the integration response to a MethodResponse status code.

  • content_handling (Optional[ContentHandling]) – Specifies how to handle request payload content type conversions. Default: none the request payload is passed through from the method request to the integration request without modification.

  • response_parameters (Optional[Mapping[str, str]]) – The response parameters from the backend response that API Gateway sends to the method response. Use the destination as the key and the source as the value: - The destination must be an existing response parameter in the MethodResponse property. - The source must be an existing method request parameter or a static value. You must enclose static values in single quotation marks and pre-encode these values based on the destination specified in the request.

  • response_templates (Optional[Mapping[str, str]]) – The templates that are used to transform the integration response body. Specify templates as key-value pairs, with a content type as the key and a template as the value.

  • selection_pattern (Optional[str]) – Specifies the regular expression (regex) pattern used to choose an integration response based on the response from the back end. For example, if the success response returns nothing and the error response returns some string, you could use the .+ regex to match error response. However, make sure that the error response does not contain any newline (\n) character in such cases. If the back end is an AWS Lambda function, the AWS Lambda function error header is matched. For all other HTTP and AWS back ends, the HTTP status code is matched.

ExampleMetadata:

fixture=_generated

Example:

# 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

integration_response = apigateway.IntegrationResponse(
    status_code="statusCode",

    # the properties below are optional
    content_handling=apigateway.ContentHandling.CONVERT_TO_BINARY,
    response_parameters={
        "response_parameters_key": "responseParameters"
    },
    response_templates={
        "response_templates_key": "responseTemplates"
    },
    selection_pattern="selectionPattern"
)

Attributes

content_handling

Specifies how to handle request payload content type conversions.

Default:

none the request payload is passed through from the method request to the integration request without modification.

response_parameters

The response parameters from the backend response that API Gateway sends to the method response.

Use the destination as the key and the source as the value:

  • The destination must be an existing response parameter in the MethodResponse property.

  • The source must be an existing method request parameter or a static value. You must enclose static values in single quotation marks and pre-encode these values based on the destination specified in the request.

See:

http://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html

response_templates

The templates that are used to transform the integration response body.

Specify templates as key-value pairs, with a content type as the key and a template as the value.

See:

http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

selection_pattern

Specifies the regular expression (regex) pattern used to choose an integration response based on the response from the back end.

For example, if the success response returns nothing and the error response returns some string, you could use the .+ regex to match error response. However, make sure that the error response does not contain any newline (\n) character in such cases. If the back end is an AWS Lambda function, the AWS Lambda function error header is matched. For all other HTTP and AWS back ends, the HTTP status code is matched.

See:

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-integration-settings-integration-response.html

status_code

The status code that API Gateway uses to map the integration response to a MethodResponse status code.