Enhancement : API-Gateway Put Integration Response - Adding support f… (#3058)
* Enhancement : API-Gateway Put Integration Response - Adding support for contentHandling. * Added tests where the contentHandling is None also gets tested. * Linting Co-authored-by: usmankb <usman@krazybee.com> Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
parent
e32a60185f
commit
b1d515c929
3 changed files with 73 additions and 4 deletions
|
|
@ -56,13 +56,21 @@ class Deployment(BaseModel, dict):
|
|||
|
||||
|
||||
class IntegrationResponse(BaseModel, dict):
|
||||
def __init__(self, status_code, selection_pattern=None, response_templates=None):
|
||||
def __init__(
|
||||
self,
|
||||
status_code,
|
||||
selection_pattern=None,
|
||||
response_templates=None,
|
||||
content_handling=None,
|
||||
):
|
||||
if response_templates is None:
|
||||
response_templates = {"application/json": None}
|
||||
self["responseTemplates"] = response_templates
|
||||
self["statusCode"] = status_code
|
||||
if selection_pattern:
|
||||
self["selectionPattern"] = selection_pattern
|
||||
if content_handling:
|
||||
self["contentHandling"] = content_handling
|
||||
|
||||
|
||||
class Integration(BaseModel, dict):
|
||||
|
|
@ -75,12 +83,12 @@ class Integration(BaseModel, dict):
|
|||
self["integrationResponses"] = {"200": IntegrationResponse(200)}
|
||||
|
||||
def create_integration_response(
|
||||
self, status_code, selection_pattern, response_templates
|
||||
self, status_code, selection_pattern, response_templates, content_handling
|
||||
):
|
||||
if response_templates == {}:
|
||||
response_templates = None
|
||||
integration_response = IntegrationResponse(
|
||||
status_code, selection_pattern, response_templates
|
||||
status_code, selection_pattern, response_templates, content_handling
|
||||
)
|
||||
self["integrationResponses"][status_code] = integration_response
|
||||
return integration_response
|
||||
|
|
@ -959,12 +967,13 @@ class APIGatewayBackend(BaseBackend):
|
|||
status_code,
|
||||
selection_pattern,
|
||||
response_templates,
|
||||
content_handling,
|
||||
):
|
||||
if response_templates is None:
|
||||
raise InvalidRequestInput()
|
||||
integration = self.get_integration(function_id, resource_id, method_type)
|
||||
integration_response = integration.create_integration_response(
|
||||
status_code, selection_pattern, response_templates
|
||||
status_code, selection_pattern, response_templates, content_handling
|
||||
)
|
||||
return integration_response
|
||||
|
||||
|
|
|
|||
|
|
@ -387,6 +387,7 @@ class APIGatewayResponse(BaseResponse):
|
|||
elif self.method == "PUT":
|
||||
selection_pattern = self._get_param("selectionPattern")
|
||||
response_templates = self._get_param("responseTemplates")
|
||||
content_handling = self._get_param("contentHandling")
|
||||
integration_response = self.backend.create_integration_response(
|
||||
function_id,
|
||||
resource_id,
|
||||
|
|
@ -394,6 +395,7 @@ class APIGatewayResponse(BaseResponse):
|
|||
status_code,
|
||||
selection_pattern,
|
||||
response_templates,
|
||||
content_handling,
|
||||
)
|
||||
elif self.method == "DELETE":
|
||||
integration_response = self.backend.delete_integration_response(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue