Skip to content

Commit 8f66d17

Browse files
committed
Merge branch 'morosi-fix' into 'master'
Add minimum_compression_size to RestApi See merge request it/e3-aws!68
2 parents b21750f + c4ea389 commit 8f66d17

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/e3/aws/troposphere/apigateway/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ def __init__(
731731
integration_uri: str | Ref | Sub | None = None,
732732
iam_path: str = "/",
733733
policy: list[PolicyStatement] | None = None,
734+
minimum_compression_size: int | None = None,
734735
):
735736
"""Initialize a Rest API.
736737
@@ -770,6 +771,9 @@ def __init__(
770771
(must be either / or a string starting and ending with /)
771772
:param policy: the policy document that contains the permissions for
772773
the RestApi resource.
774+
:param minimum_compression_size: a nullable integer that is used to
775+
enable compression (with non-negative between 0 and 10485760 (10M)
776+
bytes, inclusive) or disable compression (with a null value) on an API
773777
"""
774778
super().__init__(
775779
name=name,
@@ -787,6 +791,7 @@ def __init__(
787791
assert iam_path.endswith("/"), "iam_path must end with '/'"
788792
self.iam_path = iam_path
789793
self.policy = policy
794+
self.minimum_compression_size = minimum_compression_size
790795

791796
# For backward compatibility
792797
if resource_list is None:
@@ -1208,6 +1213,9 @@ def resources(self, stack: Stack) -> list[AWSObject]:
12081213
if self.policy:
12091214
api_params["Policy"] = PolicyDocument(statements=self.policy).as_dict
12101215

1216+
if self.minimum_compression_size is not None:
1217+
api_params["MinimumCompressionSize"] = self.minimum_compression_size
1218+
12111219
result.append(apigateway.RestApi(self.logical_id, **api_params))
12121220

12131221
# Create API resources and methods

tests/tests_e3_aws/troposphere/apigateway/apigateway_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ def test_rest_api_custom_domain(stack: Stack, lambda_fun: PyFunction) -> None:
635635
condition={"NotIpAddress": {"aws:SourceIp": ["1.2.3.4"]}},
636636
),
637637
],
638+
# Compression can be enabled this way
639+
minimum_compression_size=0,
638640
)
639641
rest_api.add_cognito_authorizer(
640642
name="testauthorizer",
@@ -692,6 +694,8 @@ def test_rest_api_custom_domain_stages(stack: Stack, lambda_fun: PyFunction) ->
692694
condition={"NotIpAddress": {"aws:SourceIp": ["1.2.3.4"]}},
693695
),
694696
],
697+
# Compression can be enabled this way
698+
minimum_compression_size=0,
695699
)
696700
rest_api.add_cognito_authorizer(
697701
name="testauthorizer",

tests/tests_e3_aws/troposphere/apigateway/apigatewayv1_test_custom_domain.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
}
5151
}
5252
]
53-
}
53+
},
54+
"MinimumCompressionSize": 0
5455
},
5556
"Type": "AWS::ApiGateway::RestApi"
5657
},

tests/tests_e3_aws/troposphere/apigateway/apigatewayv1_test_custom_domain_stages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
}
5151
}
5252
]
53-
}
53+
},
54+
"MinimumCompressionSize": 0
5455
},
5556
"Type": "AWS::ApiGateway::RestApi"
5657
},

0 commit comments

Comments
 (0)