APIGateway - add request parameters to integration model (#5224)
This commit is contained in:
parent
9640ec20d1
commit
1698c52740
@ -131,6 +131,7 @@ class Integration(BaseModel, dict):
|
|||||||
tls_config=None,
|
tls_config=None,
|
||||||
cache_namespace=None,
|
cache_namespace=None,
|
||||||
timeout_in_millis=None,
|
timeout_in_millis=None,
|
||||||
|
request_parameters=None,
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self["type"] = integration_type
|
self["type"] = integration_type
|
||||||
@ -146,6 +147,7 @@ class Integration(BaseModel, dict):
|
|||||||
self["tlsConfig"] = tls_config
|
self["tlsConfig"] = tls_config
|
||||||
self["cacheNamespace"] = cache_namespace
|
self["cacheNamespace"] = cache_namespace
|
||||||
self["timeoutInMillis"] = timeout_in_millis
|
self["timeoutInMillis"] = timeout_in_millis
|
||||||
|
self["requestParameters"] = request_parameters
|
||||||
|
|
||||||
def create_integration_response(
|
def create_integration_response(
|
||||||
self, status_code, selection_pattern, response_templates, content_handling
|
self, status_code, selection_pattern, response_templates, content_handling
|
||||||
@ -378,6 +380,7 @@ class Resource(CloudFormationModel):
|
|||||||
tls_config=None,
|
tls_config=None,
|
||||||
cache_namespace=None,
|
cache_namespace=None,
|
||||||
timeout_in_millis=None,
|
timeout_in_millis=None,
|
||||||
|
request_parameters=None,
|
||||||
):
|
):
|
||||||
integration_method = integration_method or method_type
|
integration_method = integration_method or method_type
|
||||||
integration = Integration(
|
integration = Integration(
|
||||||
@ -389,6 +392,7 @@ class Resource(CloudFormationModel):
|
|||||||
tls_config=tls_config,
|
tls_config=tls_config,
|
||||||
cache_namespace=cache_namespace,
|
cache_namespace=cache_namespace,
|
||||||
timeout_in_millis=timeout_in_millis,
|
timeout_in_millis=timeout_in_millis,
|
||||||
|
request_parameters=request_parameters,
|
||||||
)
|
)
|
||||||
self.resource_methods[method_type]["methodIntegration"] = integration
|
self.resource_methods[method_type]["methodIntegration"] = integration
|
||||||
return integration
|
return integration
|
||||||
@ -1568,6 +1572,7 @@ class APIGatewayBackend(BaseBackend):
|
|||||||
tls_config=None,
|
tls_config=None,
|
||||||
cache_namespace=None,
|
cache_namespace=None,
|
||||||
timeout_in_millis=None,
|
timeout_in_millis=None,
|
||||||
|
request_parameters=None,
|
||||||
):
|
):
|
||||||
resource = self.get_resource(function_id, resource_id)
|
resource = self.get_resource(function_id, resource_id)
|
||||||
if credentials and not re.match(
|
if credentials and not re.match(
|
||||||
@ -1609,6 +1614,7 @@ class APIGatewayBackend(BaseBackend):
|
|||||||
tls_config=tls_config,
|
tls_config=tls_config,
|
||||||
cache_namespace=cache_namespace,
|
cache_namespace=cache_namespace,
|
||||||
timeout_in_millis=timeout_in_millis,
|
timeout_in_millis=timeout_in_millis,
|
||||||
|
request_parameters=request_parameters,
|
||||||
)
|
)
|
||||||
return integration
|
return integration
|
||||||
|
|
||||||
|
@ -446,6 +446,7 @@ class APIGatewayResponse(BaseResponse):
|
|||||||
tls_config = self._get_param("tlsConfig")
|
tls_config = self._get_param("tlsConfig")
|
||||||
cache_namespace = self._get_param("cacheNamespace")
|
cache_namespace = self._get_param("cacheNamespace")
|
||||||
timeout_in_millis = self._get_param("timeoutInMillis")
|
timeout_in_millis = self._get_param("timeoutInMillis")
|
||||||
|
request_parameters = self._get_param("requestParameters")
|
||||||
self.backend.get_method(function_id, resource_id, method_type)
|
self.backend.get_method(function_id, resource_id, method_type)
|
||||||
|
|
||||||
integration_http_method = self._get_param(
|
integration_http_method = self._get_param(
|
||||||
@ -465,6 +466,7 @@ class APIGatewayResponse(BaseResponse):
|
|||||||
tls_config=tls_config,
|
tls_config=tls_config,
|
||||||
cache_namespace=cache_namespace,
|
cache_namespace=cache_namespace,
|
||||||
timeout_in_millis=timeout_in_millis,
|
timeout_in_millis=timeout_in_millis,
|
||||||
|
request_parameters=request_parameters,
|
||||||
)
|
)
|
||||||
elif self.method == "DELETE":
|
elif self.method == "DELETE":
|
||||||
integration_response = self.backend.delete_integration(
|
integration_response = self.backend.delete_integration(
|
||||||
|
@ -520,6 +520,7 @@ def test_integrations():
|
|||||||
passthroughBehavior="WHEN_NO_TEMPLATES",
|
passthroughBehavior="WHEN_NO_TEMPLATES",
|
||||||
uri="http://httpbin.org/robots.txt",
|
uri="http://httpbin.org/robots.txt",
|
||||||
integrationHttpMethod="POST",
|
integrationHttpMethod="POST",
|
||||||
|
requestParameters={"integration.request.header.X-Custom": "'Custom'"},
|
||||||
)
|
)
|
||||||
# this is hard to match against, so remove it
|
# this is hard to match against, so remove it
|
||||||
response["ResponseMetadata"].pop("HTTPHeaders", None)
|
response["ResponseMetadata"].pop("HTTPHeaders", None)
|
||||||
@ -532,6 +533,7 @@ def test_integrations():
|
|||||||
"uri": "http://httpbin.org/robots.txt",
|
"uri": "http://httpbin.org/robots.txt",
|
||||||
"passthroughBehavior": "WHEN_NO_TEMPLATES",
|
"passthroughBehavior": "WHEN_NO_TEMPLATES",
|
||||||
"cacheKeyParameters": [],
|
"cacheKeyParameters": [],
|
||||||
|
"requestParameters": {"integration.request.header.X-Custom": "'Custom'"},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -549,6 +551,7 @@ def test_integrations():
|
|||||||
"uri": "http://httpbin.org/robots.txt",
|
"uri": "http://httpbin.org/robots.txt",
|
||||||
"passthroughBehavior": "WHEN_NO_TEMPLATES",
|
"passthroughBehavior": "WHEN_NO_TEMPLATES",
|
||||||
"cacheKeyParameters": [],
|
"cacheKeyParameters": [],
|
||||||
|
"requestParameters": {"integration.request.header.X-Custom": "'Custom'"},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -565,6 +568,7 @@ def test_integrations():
|
|||||||
"uri": "http://httpbin.org/robots.txt",
|
"uri": "http://httpbin.org/robots.txt",
|
||||||
"cacheKeyParameters": [],
|
"cacheKeyParameters": [],
|
||||||
"passthroughBehavior": "WHEN_NO_TEMPLATES",
|
"passthroughBehavior": "WHEN_NO_TEMPLATES",
|
||||||
|
"requestParameters": {"integration.request.header.X-Custom": "'Custom'"},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ def test_http_integration():
|
|||||||
type="HTTP",
|
type="HTTP",
|
||||||
uri="http://httpbin.org/robots.txt",
|
uri="http://httpbin.org/robots.txt",
|
||||||
integrationHttpMethod="GET",
|
integrationHttpMethod="GET",
|
||||||
|
requestParameters={"integration.request.header.X-Custom": "'Custom'"},
|
||||||
)
|
)
|
||||||
|
|
||||||
stage_name = "staging"
|
stage_name = "staging"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user