Skip to content

Commit

Permalink
APIGateway: add connection type field to integration model (#5867)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvernaz authored Jan 23, 2023
1 parent 00ad788 commit 931bb6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions moto/apigateway/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __init__(
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
Expand All @@ -174,6 +175,7 @@ def __init__(
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]:
Expand All @@ -196,6 +198,7 @@ def to_json(self) -> Dict[str, Any]:
"requestParameters": self.request_parameters,
"contentHandling": self.content_handling,
"credentials": self.credentials,
"connectionType": self.connection_type,
}

def create_integration_response(
Expand Down Expand Up @@ -502,6 +505,7 @@ def add_integration(
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(
Expand All @@ -516,6 +520,7 @@ def add_integration(
request_parameters=request_parameters,
content_handling=content_handling,
credentials=credentials,
connection_type=connection_type,
)
self.resource_methods[method_type].method_integration = integration
return integration
Expand Down Expand Up @@ -1911,6 +1916,7 @@ def put_integration(
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(
Expand Down Expand Up @@ -1955,6 +1961,7 @@ def put_integration(
request_parameters=request_parameters,
content_handling=content_handling,
credentials=credentials,
connection_type=connection_type,
)
return integration

Expand Down
2 changes: 2 additions & 0 deletions moto/apigateway/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def integrations(self, request: Any, full_url: str, headers: Dict[str, str]) ->
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(
Expand All @@ -491,6 +492,7 @@ def integrations(self, request: Any, full_url: str, headers: Dict[str, str]) ->
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":
Expand Down
4 changes: 4 additions & 0 deletions tests/test_apigateway/test_apigateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
}
)

Expand All @@ -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",
}
)

Expand All @@ -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",
}
)

Expand Down

0 comments on commit 931bb6d

Please sign in to comment.