moto 4.2.3.dev15__py2.py3-none-any.whl → 4.2.3.dev17__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- moto/__init__.py +1 -1
- moto/events/models.py +26 -0
- moto/s3/responses.py +19 -9
- moto/settings.py +4 -0
- {moto-4.2.3.dev15.dist-info → moto-4.2.3.dev17.dist-info}/METADATA +1 -1
- {moto-4.2.3.dev15.dist-info → moto-4.2.3.dev17.dist-info}/RECORD +11 -11
- {moto-4.2.3.dev15.dist-info → moto-4.2.3.dev17.dist-info}/AUTHORS.md +0 -0
- {moto-4.2.3.dev15.dist-info → moto-4.2.3.dev17.dist-info}/LICENSE +0 -0
- {moto-4.2.3.dev15.dist-info → moto-4.2.3.dev17.dist-info}/WHEEL +0 -0
- {moto-4.2.3.dev15.dist-info → moto-4.2.3.dev17.dist-info}/entry_points.txt +0 -0
- {moto-4.2.3.dev15.dist-info → moto-4.2.3.dev17.dist-info}/top_level.txt +0 -0
moto/__init__.py
CHANGED
moto/events/models.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import os
|
|
3
3
|
import re
|
|
4
|
+
import requests
|
|
4
5
|
import json
|
|
5
6
|
import sys
|
|
6
7
|
import warnings
|
|
@@ -11,6 +12,8 @@ from operator import lt, le, eq, ge, gt
|
|
|
11
12
|
from typing import Any, Dict, List, Optional, Tuple
|
|
12
13
|
|
|
13
14
|
from collections import OrderedDict
|
|
15
|
+
|
|
16
|
+
from moto import settings
|
|
14
17
|
from moto.core.exceptions import JsonRESTError
|
|
15
18
|
from moto.core import BaseBackend, BackendDict, CloudFormationModel, BaseModel
|
|
16
19
|
from moto.core.utils import (
|
|
@@ -142,6 +145,23 @@ class Rule(CloudFormationModel):
|
|
|
142
145
|
"EventBusName": arn.resource_id,
|
|
143
146
|
}
|
|
144
147
|
cross_account_backend.put_events([new_event])
|
|
148
|
+
elif arn.service == "events" and arn.resource_type == "api-destination":
|
|
149
|
+
if settings.events_invoke_http():
|
|
150
|
+
api_destination = self._find_api_destination(arn.resource_id)
|
|
151
|
+
request_parameters = target.get("HttpParameters", {})
|
|
152
|
+
headers = request_parameters.get("HeaderParameters", {})
|
|
153
|
+
qs_params = request_parameters.get("QueryStringParameters", {})
|
|
154
|
+
query_string = "&".join(
|
|
155
|
+
[f"{key}={val}" for key, val in qs_params.items()]
|
|
156
|
+
)
|
|
157
|
+
url = api_destination.invocation_endpoint + (
|
|
158
|
+
f"?{query_string}" if query_string else ""
|
|
159
|
+
)
|
|
160
|
+
requests.request(
|
|
161
|
+
method=api_destination.http_method,
|
|
162
|
+
url=url,
|
|
163
|
+
headers=headers,
|
|
164
|
+
)
|
|
145
165
|
else:
|
|
146
166
|
raise NotImplementedError(f"Expr not defined for {type(self)}")
|
|
147
167
|
|
|
@@ -170,6 +190,11 @@ class Rule(CloudFormationModel):
|
|
|
170
190
|
if archive.uuid == archive_uuid:
|
|
171
191
|
archive.events.append(event)
|
|
172
192
|
|
|
193
|
+
def _find_api_destination(self, resource_id: str) -> "Destination":
|
|
194
|
+
backend: "EventsBackend" = events_backends[self.account_id][self.region_name]
|
|
195
|
+
destination_name = resource_id.split("/")[0]
|
|
196
|
+
return backend.destinations[destination_name]
|
|
197
|
+
|
|
173
198
|
def _send_to_sqs_queue(
|
|
174
199
|
self, resource_id: str, event: Dict[str, Any], group_id: Optional[str] = None
|
|
175
200
|
) -> None:
|
|
@@ -1245,6 +1270,7 @@ class EventsBackend(BaseBackend):
|
|
|
1245
1270
|
- EventBridge Archive
|
|
1246
1271
|
- SQS Queue + FIFO Queue
|
|
1247
1272
|
- Cross-region/account EventBus
|
|
1273
|
+
- HTTP requests (only enabled when MOTO_EVENTS_INVOKE_HTTP=true)
|
|
1248
1274
|
"""
|
|
1249
1275
|
num_events = len(events)
|
|
1250
1276
|
|
moto/s3/responses.py
CHANGED
|
@@ -1169,25 +1169,35 @@ class S3Response(BaseResponse):
|
|
|
1169
1169
|
) -> TYPE_RESPONSE:
|
|
1170
1170
|
length = len(response_content)
|
|
1171
1171
|
last = length - 1
|
|
1172
|
+
|
|
1172
1173
|
_, rspec = request.headers.get("range").split("=")
|
|
1173
1174
|
if "," in rspec:
|
|
1174
|
-
|
|
1175
|
+
return 200, response_headers, response_content
|
|
1176
|
+
|
|
1177
|
+
try:
|
|
1178
|
+
begin, end = [int(i) if i else None for i in rspec.split("-")]
|
|
1179
|
+
except ValueError:
|
|
1180
|
+
# if we can't parse the Range header, S3 just treat the request as a non-range request
|
|
1181
|
+
return 200, response_headers, response_content
|
|
1175
1182
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1183
|
+
if (begin is None and end == 0) or (begin is not None and begin > last):
|
|
1184
|
+
raise InvalidRange(
|
|
1185
|
+
actual_size=str(length), range_requested=request.headers.get("range")
|
|
1186
|
+
)
|
|
1178
1187
|
|
|
1179
|
-
begin, end = map(toint, rspec.split("-"))
|
|
1180
1188
|
if begin is not None: # byte range
|
|
1181
1189
|
end = last if end is None else min(end, last)
|
|
1182
1190
|
elif end is not None: # suffix byte range
|
|
1183
1191
|
begin = length - min(end, length)
|
|
1184
1192
|
end = last
|
|
1185
1193
|
else:
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1194
|
+
# Treat as non-range request
|
|
1195
|
+
return 200, response_headers, response_content
|
|
1196
|
+
|
|
1197
|
+
if begin > min(end, last):
|
|
1198
|
+
# Treat as non-range request if after the logic is applied, the start of the range is greater than the end
|
|
1199
|
+
return 200, response_headers, response_content
|
|
1200
|
+
|
|
1191
1201
|
response_headers["content-range"] = f"bytes {begin}-{end}/{length}"
|
|
1192
1202
|
content = response_content[begin : end + 1]
|
|
1193
1203
|
response_headers["content-length"] = len(content)
|
moto/settings.py
CHANGED
|
@@ -79,6 +79,10 @@ def ecs_new_arn_format() -> bool:
|
|
|
79
79
|
return os.environ.get("MOTO_ECS_NEW_ARN", "true").lower() != "false"
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
def events_invoke_http() -> bool:
|
|
83
|
+
return os.environ.get("MOTO_EVENTS_INVOKE_HTTP", "false").lower() == "true"
|
|
84
|
+
|
|
85
|
+
|
|
82
86
|
def allow_unknown_region() -> bool:
|
|
83
87
|
return os.environ.get("MOTO_ALLOW_NONEXISTENT_REGION", "false").lower() == "true"
|
|
84
88
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
moto/__init__.py,sha256=
|
|
1
|
+
moto/__init__.py,sha256=WsqX_B-R7otRD54x6Vob_NTV2IiwJEGdqe7Nqv_-7N0,9630
|
|
2
2
|
moto/backend_index.py,sha256=CXt1WInpx_9a2USMqIkiEoWFqRdsASOuE7AzbVp5a6A,10629
|
|
3
3
|
moto/backends.py,sha256=rC9WUMUUWmVmX7ZEfXpVKAQAw6oI8qYobCEPxP2Zv9U,1805
|
|
4
4
|
moto/server.py,sha256=cp8kIe5jVOm7Z2BlNN2AMbTfrRvLBEKSb4mt7O8nu34,2858
|
|
5
|
-
moto/settings.py,sha256=
|
|
5
|
+
moto/settings.py,sha256=BTqhtAWFmDoy5aG_o248d7KK5Dj3Hiv1wuX54PJu5tc,5243
|
|
6
6
|
moto/acm/__init__.py,sha256=B2_APiU59fBQznKEMsWt95_xuBxGRG7vhTrQQiPJ_Lw,155
|
|
7
7
|
moto/acm/exceptions.py,sha256=Qq195AJzvOwSMrzn0WwEBWXPCK_PAX5Nnl0gQbhBrio,511
|
|
8
8
|
moto/acm/models.py,sha256=-5aqWPEIGQ4JECONTrenl_eyHsgwd05WjZ6_UEVPIDU,21261
|
|
@@ -531,7 +531,7 @@ moto/es/responses.py,sha256=5W5uCJbMQ3ytaPEjyU-ljydjZcELJfW2Hwb1FM_ORAA,4601
|
|
|
531
531
|
moto/es/urls.py,sha256=uTT_CmUjlQEGoSntUH94tNpfFi8C0-j6jX-UDJkLphI,931
|
|
532
532
|
moto/events/__init__.py,sha256=8SQhM_-HJYC7SfZ2C7PdrxjjjQ5h4x-zPKk1CISHIo0,170
|
|
533
533
|
moto/events/exceptions.py,sha256=j4fkYToNMligsmTZ2NNqvTDVHG54AFd5H9fHSpI2rko,1024
|
|
534
|
-
moto/events/models.py,sha256=
|
|
534
|
+
moto/events/models.py,sha256=JiDv5dEKtd-rd8ouv-v-T3NWdNGBcf4qDcogC_kcvkk,66916
|
|
535
535
|
moto/events/notifications.py,sha256=IugaDUvPaDzBNklhq9CpzabpHYy-wBYgCZE5T1dOjYY,2247
|
|
536
536
|
moto/events/responses.py,sha256=vpkdxkT-qx7ZStsrtiW-fHHq_PexpmULTFyww1k5YOE,18552
|
|
537
537
|
moto/events/urls.py,sha256=yELCNN-ribykHt6twtyoaqU0eAjzFzlAYvYHV2igeOI,139
|
|
@@ -807,7 +807,7 @@ moto/s3/config.py,sha256=xrV-Uj3BMBz40lbyjmktbaLg5UR7Z6Rx8W5yyw7kIUg,4810
|
|
|
807
807
|
moto/s3/exceptions.py,sha256=iIrIq5QfR5LVFIyCULhZfJuOx0jyXdgAyBmXw_CRFgM,15785
|
|
808
808
|
moto/s3/models.py,sha256=koKn0vyVyNbYcv6SDEhggrt5RSDVqs1f0XHfiFhE9Zo,95206
|
|
809
809
|
moto/s3/notifications.py,sha256=0C-jJXnNKApy6TX0jLL8esx7xzQ251a76fwGmdod-FA,4012
|
|
810
|
-
moto/s3/responses.py,sha256=
|
|
810
|
+
moto/s3/responses.py,sha256=gnHN9DShMfoWGTLRwplGQplfXLQRpYcJduaeZCyAsiI,125084
|
|
811
811
|
moto/s3/select_object_content.py,sha256=NxQLKVML2_bqMRO4vQCMVkaKsV7XCE4kUFnMGVzi8h4,2184
|
|
812
812
|
moto/s3/urls.py,sha256=XI4Z2_A7R4Z0I9o5pQ-9NNtkHvbyH0xgzJ__KbJG4hc,1005
|
|
813
813
|
moto/s3/utils.py,sha256=T7eKBz3xDR20af9CxoJQHNgX3PElnHuIhxnr7Dr7neI,7137
|
|
@@ -1030,10 +1030,10 @@ moto/xray/mock_client.py,sha256=nYl8JVJbl3OY-tnUafkVOG4K4-cFm5bsft3Hxo7fKwI,3809
|
|
|
1030
1030
|
moto/xray/models.py,sha256=0QL6nmhpVVwAiyi9aw4pBwVTRhqPW9oIy2uwPDhPKug,11179
|
|
1031
1031
|
moto/xray/responses.py,sha256=p2xsg2-P9h_1DCyuBC7GenmC5L64tXAX6a-XCb2j5-o,6316
|
|
1032
1032
|
moto/xray/urls.py,sha256=R6T3gMwobWipukWcC1DQ36CU1Rjt6oqBDoe-7HqaIZU,393
|
|
1033
|
-
moto-4.2.3.
|
|
1034
|
-
moto-4.2.3.
|
|
1035
|
-
moto-4.2.3.
|
|
1036
|
-
moto-4.2.3.
|
|
1037
|
-
moto-4.2.3.
|
|
1038
|
-
moto-4.2.3.
|
|
1039
|
-
moto-4.2.3.
|
|
1033
|
+
moto-4.2.3.dev17.dist-info/AUTHORS.md,sha256=dDUhasV8HGSkzb7zj7a0b3alnqY0P1LPOyOUNoo8Mpo,2976
|
|
1034
|
+
moto-4.2.3.dev17.dist-info/LICENSE,sha256=8S75_TlqE-kIeGMLG0-rRxxu2ct6SM8quyUWKBYyIY4,10834
|
|
1035
|
+
moto-4.2.3.dev17.dist-info/METADATA,sha256=m1eAV_rSN_gUua1snLkMDTY2pswEyFq1k7_AAEC062g,12102
|
|
1036
|
+
moto-4.2.3.dev17.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
|
|
1037
|
+
moto-4.2.3.dev17.dist-info/entry_points.txt,sha256=aPovbZuFXCwt8_m2vcolpH4Qr3rOF3yXeRElP9Zkauo,49
|
|
1038
|
+
moto-4.2.3.dev17.dist-info/top_level.txt,sha256=TETRKAPcAAvoZDkSkwQiZtTSr-1gzaEAXVm9FmZKj8s,5
|
|
1039
|
+
moto-4.2.3.dev17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|