Class: AWSCDK::APIGateway::IntegrationResponse

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

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) ⇒ IntegrationResponse

Returns a new instance of IntegrationResponse.

Parameters:

  • status_code (String)

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

  • content_handling (AWSCDK::APIGateway::ContentHandling, nil) (defaults to: nil)

    Specifies how to handle request payload content type conversions.

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

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

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

    The templates that are 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.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'api_gateway/integration_response.rb', line 11

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("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5Db250ZW50SGFuZGxpbmcifQ==")), "contentHandling") unless @content_handling.nil?
  @response_parameters = response_parameters
  Jsii::Type.check_type(@response_parameters, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "responseParameters") unless @response_parameters.nil?
  @response_templates = response_templates
  Jsii::Type.check_type(@response_templates, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "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_handlingAWSCDK::APIGateway::ContentHandling? (readonly)

Note:

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

Specifies how to handle request payload content type conversions.



32
33
34
# File 'api_gateway/integration_response.rb', line 32

def content_handling
  @content_handling
end

#response_parametersHash{String => String}? (readonly)

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.


46
47
48
# File 'api_gateway/integration_response.rb', line 46

def response_parameters
  @response_parameters
end

#response_templatesHash{String => String}? (readonly)

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.



54
55
56
# File 'api_gateway/integration_response.rb', line 54

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.



64
65
66
# File 'api_gateway/integration_response.rb', line 64

def selection_pattern
  @selection_pattern
end

#status_codeString (readonly)

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

Returns:

  • (String)


27
28
29
# File 'api_gateway/integration_response.rb', line 27

def status_code
  @status_code
end

Class Method Details

.jsii_propertiesObject



66
67
68
69
70
71
72
73
74
# File 'api_gateway/integration_response.rb', line 66

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



76
77
78
79
80
81
82
83
84
85
86
# File 'api_gateway/integration_response.rb', line 76

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