From 931bb6d960a18b3054c824a7ae31914f49665778 Mon Sep 17 00:00:00 2001 From: Cesar Alvernaz Date: Mon, 23 Jan 2023 10:48:59 +0000 Subject: [PATCH] APIGateway: add connection type field to integration model (#5867) --- moto/apigateway/models.py | 7 +++++++ moto/apigateway/responses.py | 2 ++ tests/test_apigateway/test_apigateway.py | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/moto/apigateway/models.py b/moto/apigateway/models.py index e0fa232d5..93fd225f6 100644 --- a/moto/apigateway/models.py +++ b/moto/apigateway/models.py @@ -161,6 +161,7 @@ class Integration(BaseModel): request_parameters: Optional[Dict[str, Any]] = None, content_handling: Optional[str] = None, credentials: Optional[str] = None, + connection_type: Optional[str] = None, ): self.integration_type = integration_type self.uri = uri @@ -174,6 +175,7 @@ class Integration(BaseModel): self.request_parameters = request_parameters self.content_handling = content_handling self.credentials = credentials + self.connection_type = connection_type self.integration_responses: Optional[Dict[str, IntegrationResponse]] = None def to_json(self) -> Dict[str, Any]: @@ -196,6 +198,7 @@ class Integration(BaseModel): "requestParameters": self.request_parameters, "contentHandling": self.content_handling, "credentials": self.credentials, + "connectionType": self.connection_type, } def create_integration_response( @@ -502,6 +505,7 @@ class Resource(CloudFormationModel): request_parameters: Optional[Dict[str, Any]] = None, content_handling: Optional[str] = None, credentials: Optional[str] = None, + connection_type: Optional[str] = None, ) -> Integration: integration_method = integration_method or method_type integration = Integration( @@ -516,6 +520,7 @@ class Resource(CloudFormationModel): request_parameters=request_parameters, content_handling=content_handling, credentials=credentials, + connection_type=connection_type, ) self.resource_methods[method_type].method_integration = integration return integration @@ -1911,6 +1916,7 @@ class APIGatewayBackend(BaseBackend): timeout_in_millis: Optional[str] = None, request_parameters: Optional[Dict[str, Any]] = None, content_handling: Optional[str] = None, + connection_type: Optional[str] = None, ) -> Integration: resource = self.get_resource(function_id, resource_id) if credentials and not re.match( @@ -1955,6 +1961,7 @@ class APIGatewayBackend(BaseBackend): request_parameters=request_parameters, content_handling=content_handling, credentials=credentials, + connection_type=connection_type, ) return integration diff --git a/moto/apigateway/responses.py b/moto/apigateway/responses.py index 13b96d4f9..86e04a869 100644 --- a/moto/apigateway/responses.py +++ b/moto/apigateway/responses.py @@ -470,6 +470,7 @@ class APIGatewayResponse(BaseResponse): timeout_in_millis = self._get_param("timeoutInMillis") request_parameters = self._get_param("requestParameters") content_handling = self._get_param("contentHandling") + connection_type = self._get_param("connectionType") self.backend.get_method(function_id, resource_id, method_type) integration_http_method = self._get_param( @@ -491,6 +492,7 @@ class APIGatewayResponse(BaseResponse): timeout_in_millis=timeout_in_millis, request_parameters=request_parameters, content_handling=content_handling, + connection_type=connection_type, ) return 201, {}, json.dumps(integration_response.to_json()) elif self.method == "DELETE": diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py index 46656353f..60b409499 100644 --- a/tests/test_apigateway/test_apigateway.py +++ b/tests/test_apigateway/test_apigateway.py @@ -533,6 +533,7 @@ def test_integrations(): contentHandling="CONVERT_TO_TEXT", credentials=f"arn:aws:iam::{DEFAULT_ACCOUNT_ID}:role/apigateway-invoke-lambda-exec-role", tlsConfig={"insecureSkipVerification": True}, + connectionType="INTERNET", ) # this is hard to match against, so remove it @@ -550,6 +551,7 @@ def test_integrations(): "contentHandling": "CONVERT_TO_TEXT", "credentials": f"arn:aws:iam::{DEFAULT_ACCOUNT_ID}:role/apigateway-invoke-lambda-exec-role", "tlsConfig": {"insecureSkipVerification": True}, + "connectionType": "INTERNET", } ) @@ -571,6 +573,7 @@ def test_integrations(): "contentHandling": "CONVERT_TO_TEXT", "credentials": f"arn:aws:iam::{DEFAULT_ACCOUNT_ID}:role/apigateway-invoke-lambda-exec-role", "tlsConfig": {"insecureSkipVerification": True}, + "connectionType": "INTERNET", } ) @@ -591,6 +594,7 @@ def test_integrations(): "contentHandling": "CONVERT_TO_TEXT", "credentials": f"arn:aws:iam::{DEFAULT_ACCOUNT_ID}:role/apigateway-invoke-lambda-exec-role", "tlsConfig": {"insecureSkipVerification": True}, + "connectionType": "INTERNET", } )