Class: AWSCDK::APIGateway::CfnMethod::IntegrationResponseProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
api_gateway/cfn_method.rb

Overview

IntegrationResponse is a property of the Amazon API Gateway Method Integration property type that specifies the response that API Gateway sends after a method's backend finishes processing a request.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code:, content_handling: nil, response_parameters: nil, response_templates: nil, selection_pattern: nil) ⇒ IntegrationResponseProperty

Returns a new instance of IntegrationResponseProperty.

Parameters:

  • status_code (String)

    Specifies the status code that is used to map the integration response to an existing MethodResponse.

  • content_handling (String, nil) (defaults to: nil)

    Specifies how to handle response payload content type conversions.

  • response_parameters (AWSCDK::IResolvable, Hash{String => String}, nil) (defaults to: nil)

    A key-value map specifying response parameters that are passed to the method response from the back end.

  • response_templates (AWSCDK::IResolvable, Hash{String => String}, nil) (defaults to: nil)

    Specifies the templates used to transform the integration response body.

  • selection_pattern (String, nil) (defaults to: nil)

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



867
868
869
870
871
872
873
874
875
876
877
878
# File 'api_gateway/cfn_method.rb', line 867

def initialize(status_code:, content_handling: nil, response_parameters: nil, response_templates: nil, selection_pattern: nil)
  @status_code = status_code
  Jsii::Type.check_type(@status_code, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "statusCode")
  @content_handling = content_handling
  Jsii::Type.check_type(@content_handling, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "contentHandling") unless @content_handling.nil?
  @response_parameters = response_parameters
  Jsii::Type.check_type(@response_parameters, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsicHJpbWl0aXZlIjoic3RyaW5nIn0sImtpbmQiOiJtYXAifX1dfX0=")), "responseParameters") unless @response_parameters.nil?
  @response_templates = response_templates
  Jsii::Type.check_type(@response_templates, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsicHJpbWl0aXZlIjoic3RyaW5nIn0sImtpbmQiOiJtYXAifX1dfX0=")), "responseTemplates") unless @response_templates.nil?
  @selection_pattern = selection_pattern
  Jsii::Type.check_type(@selection_pattern, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "selectionPattern") unless @selection_pattern.nil?
end

Instance Attribute Details

#content_handlingString? (readonly)

Specifies how to handle response payload content type conversions.

Supported values are CONVERT_TO_BINARY and CONVERT_TO_TEXT , with the following behaviors:

If this property is not defined, the response payload will be passed through from the integration response to the method response without modification.



893
894
895
# File 'api_gateway/cfn_method.rb', line 893

def content_handling
  @content_handling
end

#response_parametersAWSCDK::IResolvable, ... (readonly)

A key-value map specifying response parameters that are passed to the method response from the back end.

The key is a method response header parameter name and the mapped value is an integration response header value, a static value enclosed within a pair of single quotes, or a JSON expression from the integration response body. The mapping key must match the pattern of method.response.header.{name} , where name is a valid and unique header name. The mapped non-static value must match the pattern of integration.response.header.{name} or integration.response.body.{JSON-expression} , where name is a valid and unique response header name and JSON-expression is a valid JSON expression without the $ prefix.



900
901
902
# File 'api_gateway/cfn_method.rb', line 900

def response_parameters
  @response_parameters
end

#response_templatesAWSCDK::IResolvable, ... (readonly)

Specifies the templates used to transform the integration response body.

Response templates are represented as a key/value map, with a content-type as the key and a template as the value.



907
908
909
# File 'api_gateway/cfn_method.rb', line 907

def response_templates
  @response_templates
end

#selection_patternString? (readonly)

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.



914
915
916
# File 'api_gateway/cfn_method.rb', line 914

def selection_pattern
  @selection_pattern
end

#status_codeString (readonly)

Specifies the status code that is used to map the integration response to an existing MethodResponse.



884
885
886
# File 'api_gateway/cfn_method.rb', line 884

def status_code
  @status_code
end

Class Method Details

.jsii_propertiesObject



916
917
918
919
920
921
922
923
924
# File 'api_gateway/cfn_method.rb', line 916

def self.jsii_properties
  {
    :status_code => "statusCode",
    :content_handling => "contentHandling",
    :response_parameters => "responseParameters",
    :response_templates => "responseTemplates",
    :selection_pattern => "selectionPattern",
  }
end

Instance Method Details

#to_jsiiObject



926
927
928
929
930
931
932
933
934
935
936
# File 'api_gateway/cfn_method.rb', line 926

def to_jsii
  result = {}
  result.merge!({
    "statusCode" => @status_code,
    "contentHandling" => @content_handling,
    "responseParameters" => @response_parameters,
    "responseTemplates" => @response_templates,
    "selectionPattern" => @selection_pattern,
  })
  result.compact
end