Class: AWSCDK::APIGateway::MockIntegration

Inherits:
Integration
  • Object
show all
Defined in:
api_gateway/mock_integration.rb

Overview

This type of integration lets API Gateway return a response without sending the request further to the backend.

This is useful for API testing because it can be used to test the integration set up without incurring charges for using the backend and to enable collaborative development of an API. In collaborative development, a team can isolate their development effort by setting up simulations of API components owned by other teams by using the MOCK integrations. It is also used to return CORS-related headers to ensure that the API method permits CORS access. In fact, the API Gateway console integrates the OPTIONS method to support CORS with a mock integration. Gateway responses are other examples of mock integrations.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ MockIntegration

Returns a new instance of MockIntegration.

Parameters:



19
20
21
22
23
# File 'api_gateway/mock_integration.rb', line 19

def initialize(options = nil)
  options = options.is_a?(Hash) ? ::AWSCDK::APIGateway::IntegrationOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5JbnRlZ3JhdGlvbk9wdGlvbnMifQ==")), "options") unless options.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(options)
end

Class Method Details

.jsii_overridable_methodsObject



25
26
27
28
29
# File 'api_gateway/mock_integration.rb', line 25

def self.jsii_overridable_methods
  {
    :bind => { kind: :method, name: "bind", is_optional: false },
  }
end

Instance Method Details

#bind(method) ⇒ AWSCDK::APIGateway::IntegrationConfig

Can be overridden by subclasses to allow the integration to interact with the method being integrated, access the REST API object, method ARNs, etc.



35
36
37
38
# File 'api_gateway/mock_integration.rb', line 35

def bind(method)
  Jsii::Type.check_type(method, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBpZ2F0ZXdheS5NZXRob2QifQ==")), "method")
  jsii_call_method("bind", [method])
end