Repository: getmoto/moto
Pull request #5867 (2023-01-22 18:45:33)

add connection type field to integration model
Adds the connection type field to the integration model.

https://docs.aws.amazon.com/apigateway/latest/api/API_Integration.html

codecov-commenter: # [Codecov](https://codecov.io/gh/getmoto/moto/pull/5867?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#5867](https://codecov.io/gh/getmoto/moto/pull/5867?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (c64d3d6) into [master](https://codecov.io/gh/getmoto/moto/commit/00ad78897520165c39532d93e81d39d96719fb9d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (00ad788) will **decrease** coverage by `0.01%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##           master    #5867      +/-   ##
==========================================
- Coverage   96.18%   96.17%   -0.01%     
==========================================
  Files         757      757              
  Lines       74403    74405       +2     
==========================================
- Hits        71563    71562       -1     
- Misses       2840     2843       +3     
```

| Flag | Coverage Δ | |
|---|---|---|
| servertests | `36.98% <0.00%> (+<0.01%)` | :arrow_up: |
| unittests | `96.11% <100.00%> (-0.01%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/getmoto/moto/pull/5867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [moto/apigateway/models.py](https://codecov.io/gh/getmoto/moto/pull/5867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-bW90by9hcGlnYXRld2F5L21vZGVscy5weQ==) | `95.66% <100.00%> (+<0.01%)` | :arrow_up: |
| [moto/apigateway/responses.py](https://codecov.io/gh/getmoto/moto/pull/5867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-bW90by9hcGlnYXRld2F5L3Jlc3BvbnNlcy5weQ==) | `95.51% <100.00%> (+<0.01%)` | :arrow_up: |
| [moto/batch/models.py](https://codecov.io/gh/getmoto/moto/pull/5867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-bW90by9iYXRjaC9tb2RlbHMucHk=) | `91.06% <0.00%> (-0.37%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)


Patch:
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":


Test patch:
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",
         }
     )