moto 5.0.2.dev2__py2.py3-none-any.whl → 5.0.2.dev6__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 +23 -22
- moto/events/utils.py +16 -1
- {moto-5.0.2.dev2.dist-info → moto-5.0.2.dev6.dist-info}/METADATA +1 -1
- {moto-5.0.2.dev2.dist-info → moto-5.0.2.dev6.dist-info}/RECORD +10 -10
- {moto-5.0.2.dev2.dist-info → moto-5.0.2.dev6.dist-info}/AUTHORS.md +0 -0
- {moto-5.0.2.dev2.dist-info → moto-5.0.2.dev6.dist-info}/LICENSE +0 -0
- {moto-5.0.2.dev2.dist-info → moto-5.0.2.dev6.dist-info}/WHEEL +0 -0
- {moto-5.0.2.dev2.dist-info → moto-5.0.2.dev6.dist-info}/entry_points.txt +0 -0
- {moto-5.0.2.dev2.dist-info → moto-5.0.2.dev6.dist-info}/top_level.txt +0 -0
moto/__init__.py
CHANGED
moto/events/models.py
CHANGED
|
@@ -34,7 +34,7 @@ from moto.utilities.arns import parse_arn
|
|
|
34
34
|
from moto.utilities.paginator import paginate
|
|
35
35
|
from moto.utilities.tagging_service import TaggingService
|
|
36
36
|
|
|
37
|
-
from .utils import PAGINATION_MODEL
|
|
37
|
+
from .utils import _BASE_EVENT_MESSAGE, PAGINATION_MODEL, EventMessageType
|
|
38
38
|
|
|
39
39
|
# Sentinel to signal the absence of a field for `Exists` pattern matching
|
|
40
40
|
UNDEFINED = object()
|
|
@@ -113,7 +113,7 @@ class Rule(CloudFormationModel):
|
|
|
113
113
|
if index is not None:
|
|
114
114
|
self.targets.pop(index)
|
|
115
115
|
|
|
116
|
-
def send_to_targets(self, event:
|
|
116
|
+
def send_to_targets(self, event: EventMessageType) -> None:
|
|
117
117
|
if not self.event_pattern.matches_event(event):
|
|
118
118
|
return
|
|
119
119
|
|
|
@@ -166,7 +166,7 @@ class Rule(CloudFormationModel):
|
|
|
166
166
|
else:
|
|
167
167
|
raise NotImplementedError(f"Expr not defined for {type(self)}")
|
|
168
168
|
|
|
169
|
-
def _send_to_cw_log_group(self, name: str, event:
|
|
169
|
+
def _send_to_cw_log_group(self, name: str, event: EventMessageType) -> None:
|
|
170
170
|
from moto.logs import logs_backends
|
|
171
171
|
|
|
172
172
|
event_copy = copy.deepcopy(event)
|
|
@@ -183,7 +183,9 @@ class Rule(CloudFormationModel):
|
|
|
183
183
|
log_backend.create_log_stream(name, log_stream_name)
|
|
184
184
|
log_backend.put_log_events(name, log_stream_name, log_events)
|
|
185
185
|
|
|
186
|
-
def _send_to_events_archive(
|
|
186
|
+
def _send_to_events_archive(
|
|
187
|
+
self, resource_id: str, event: EventMessageType
|
|
188
|
+
) -> None:
|
|
187
189
|
archive_name, archive_uuid = resource_id.split(":")
|
|
188
190
|
archive = events_backends[self.account_id][self.region_name].archives.get(
|
|
189
191
|
archive_name
|
|
@@ -197,7 +199,7 @@ class Rule(CloudFormationModel):
|
|
|
197
199
|
return backend.destinations[destination_name]
|
|
198
200
|
|
|
199
201
|
def _send_to_sqs_queue(
|
|
200
|
-
self, resource_id: str, event:
|
|
202
|
+
self, resource_id: str, event: EventMessageType, group_id: Optional[str] = None
|
|
201
203
|
) -> None:
|
|
202
204
|
from moto.sqs import sqs_backends
|
|
203
205
|
|
|
@@ -557,7 +559,7 @@ class Archive(CloudFormationModel):
|
|
|
557
559
|
self.state = "ENABLED"
|
|
558
560
|
self.uuid = str(random.uuid4())
|
|
559
561
|
|
|
560
|
-
self.events: List[
|
|
562
|
+
self.events: List[EventMessageType] = []
|
|
561
563
|
self.event_bus_name = source_arn.split("/")[-1]
|
|
562
564
|
|
|
563
565
|
def describe_short(self) -> Dict[str, Any]:
|
|
@@ -873,16 +875,18 @@ class EventPattern:
|
|
|
873
875
|
def get_pattern(self) -> Dict[str, Any]:
|
|
874
876
|
return self._pattern
|
|
875
877
|
|
|
876
|
-
def matches_event(self, event:
|
|
878
|
+
def matches_event(self, event: EventMessageType) -> bool:
|
|
877
879
|
if not self._pattern:
|
|
878
880
|
return True
|
|
879
881
|
event = json.loads(json.dumps(event))
|
|
880
882
|
return self._does_event_match(event, self._pattern)
|
|
881
883
|
|
|
882
|
-
def _does_event_match(
|
|
884
|
+
def _does_event_match(
|
|
885
|
+
self, event: EventMessageType, pattern: Dict[str, Any]
|
|
886
|
+
) -> bool:
|
|
883
887
|
items_and_filters = [(event.get(k, UNDEFINED), v) for k, v in pattern.items()]
|
|
884
888
|
nested_filter_matches = [
|
|
885
|
-
self._does_event_match(item, nested_filter)
|
|
889
|
+
self._does_event_match(item, nested_filter) # type: ignore
|
|
886
890
|
for item, nested_filter in items_and_filters
|
|
887
891
|
if isinstance(nested_filter, dict)
|
|
888
892
|
]
|
|
@@ -1352,19 +1356,16 @@ class EventsBackend(BaseBackend):
|
|
|
1352
1356
|
|
|
1353
1357
|
event_bus = self.describe_event_bus(event_bus_name)
|
|
1354
1358
|
for rule in event_bus.rules.values():
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
"detail": json.loads(event["Detail"]),
|
|
1366
|
-
},
|
|
1367
|
-
)
|
|
1359
|
+
event_msg = copy.deepcopy(_BASE_EVENT_MESSAGE)
|
|
1360
|
+
event_msg["id"] = event_id
|
|
1361
|
+
event_msg["detail-type"] = event["DetailType"]
|
|
1362
|
+
event_msg["source"] = event["Source"]
|
|
1363
|
+
event_msg["account"] = self.account_id
|
|
1364
|
+
event_msg["time"] = event.get("Time", unix_time())
|
|
1365
|
+
event_msg["region"] = self.region_name
|
|
1366
|
+
event_msg["resources"] = event.get("Resources", [])
|
|
1367
|
+
event_msg["detail"] = json.loads(event["Detail"])
|
|
1368
|
+
rule.send_to_targets(event_msg)
|
|
1368
1369
|
|
|
1369
1370
|
return entries
|
|
1370
1371
|
|
moto/events/utils.py
CHANGED
|
@@ -13,11 +13,14 @@ EventMessageType = TypedDict(
|
|
|
13
13
|
"detail-type": "Required[Union[str, List[str]]]",
|
|
14
14
|
"source": "Required[Union[str, List[str]]]",
|
|
15
15
|
"account": str,
|
|
16
|
-
|
|
16
|
+
# support float type for internal use of moto.
|
|
17
|
+
"time": "Union[str, float]",
|
|
18
|
+
"replay-name": str,
|
|
17
19
|
"region": str,
|
|
18
20
|
"resources": List[str],
|
|
19
21
|
"detail": "Required[Dict[str, Any]]",
|
|
20
22
|
},
|
|
23
|
+
total=False,
|
|
21
24
|
)
|
|
22
25
|
|
|
23
26
|
PAGINATION_MODEL = {
|
|
@@ -36,3 +39,15 @@ PAGINATION_MODEL = {
|
|
|
36
39
|
"fail_on_invalid_token": False,
|
|
37
40
|
},
|
|
38
41
|
}
|
|
42
|
+
|
|
43
|
+
_BASE_EVENT_MESSAGE: EventMessageType = {
|
|
44
|
+
"version": "0",
|
|
45
|
+
"id": "17793124-05d4-b198-2fde-7ededc63b103",
|
|
46
|
+
"detail-type": "",
|
|
47
|
+
"source": "",
|
|
48
|
+
"account": "",
|
|
49
|
+
"time": "",
|
|
50
|
+
"region": "",
|
|
51
|
+
"resources": [],
|
|
52
|
+
"detail": {},
|
|
53
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
moto/__init__.py,sha256=
|
|
1
|
+
moto/__init__.py,sha256=R1T_ZsJ4JC3vDYQ_4vJmEQFERIyZzQuaZoJfjK-sva0,100
|
|
2
2
|
moto/backend_index.py,sha256=0ZXW2MoTfOl-F3w0DiRCg4XefVIWvLgAmZW-3Pcx7f4,10951
|
|
3
3
|
moto/backends.py,sha256=uM9-6lJ6cqPJuKKFymnhidN1iqslTmOUfnYDT3mvOPI,24575
|
|
4
4
|
moto/proxy.py,sha256=5oz1ZGQP4SoWDYycZApQSRmOv9M-TpjeJpJY9fG3oxY,3113
|
|
@@ -542,11 +542,11 @@ moto/es/responses.py,sha256=MjUsfcyIIejHXe0-El08fcq4QHnBmWH133yBVdlNA_U,4602
|
|
|
542
542
|
moto/es/urls.py,sha256=spYTCinfXys6ZCLFt7rvNFxaQjRzV8-Om888KVz2flM,999
|
|
543
543
|
moto/events/__init__.py,sha256=zTpRuXb_eook9vvfCaegnHiJfa8dGnK4fr5QayZPPms,50
|
|
544
544
|
moto/events/exceptions.py,sha256=4bQfnqMRqQV8DsuPYb9wvxHUN2dPb1iHkEAwfpEiLzU,1025
|
|
545
|
-
moto/events/models.py,sha256=
|
|
545
|
+
moto/events/models.py,sha256=9UCJcS9cM_AoxwME4YmSsg5zadUCVUBuugLVw1WFeRY,69576
|
|
546
546
|
moto/events/notifications.py,sha256=hiPLHKXIbJjA3hsuhnk55H9VtQ_mdUnw-leYVlfuWpg,2336
|
|
547
547
|
moto/events/responses.py,sha256=SIG-ogISYoTq5uRv270Iu1_CzAHsclURc4QxTuSPnKg,19733
|
|
548
548
|
moto/events/urls.py,sha256=yELCNN-ribykHt6twtyoaqU0eAjzFzlAYvYHV2igeOI,139
|
|
549
|
-
moto/events/utils.py,sha256=
|
|
549
|
+
moto/events/utils.py,sha256=RuC8_LmnBVKes0F6GPcL8i26pPl68704DOmeMvjXWS8,1430
|
|
550
550
|
moto/firehose/__init__.py,sha256=95mzSVYcMa0BR1xw1JomGW3XTVPGrOUGt1sLB99XMu4,52
|
|
551
551
|
moto/firehose/exceptions.py,sha256=D5PSq99g1SnwTROetmw1jMPuuza8pUkVTbC2CZ8wASs,1486
|
|
552
552
|
moto/firehose/models.py,sha256=R1woPAbR_5V0naa-LYDGAA6Q_F4iRf82oW2PhsL9owQ,29639
|
|
@@ -1070,10 +1070,10 @@ moto/xray/mock_client.py,sha256=_hckCof1BgtizZ4u-Da0tpXX9JNGTbVs7AhbkxBnuGU,3811
|
|
|
1070
1070
|
moto/xray/models.py,sha256=NbevJjH4Qly1A6YM0SswSv7gTBc44547Zl5XnRMd84s,11229
|
|
1071
1071
|
moto/xray/responses.py,sha256=StNwTGhzvkqCmghSo2O9tMfTRQSN4BWYzLODyKMUj-s,6316
|
|
1072
1072
|
moto/xray/urls.py,sha256=R6T3gMwobWipukWcC1DQ36CU1Rjt6oqBDoe-7HqaIZU,393
|
|
1073
|
-
moto-5.0.2.
|
|
1074
|
-
moto-5.0.2.
|
|
1075
|
-
moto-5.0.2.
|
|
1076
|
-
moto-5.0.2.
|
|
1077
|
-
moto-5.0.2.
|
|
1078
|
-
moto-5.0.2.
|
|
1079
|
-
moto-5.0.2.
|
|
1073
|
+
moto-5.0.2.dev6.dist-info/AUTHORS.md,sha256=dDUhasV8HGSkzb7zj7a0b3alnqY0P1LPOyOUNoo8Mpo,2976
|
|
1074
|
+
moto-5.0.2.dev6.dist-info/LICENSE,sha256=8S75_TlqE-kIeGMLG0-rRxxu2ct6SM8quyUWKBYyIY4,10834
|
|
1075
|
+
moto-5.0.2.dev6.dist-info/METADATA,sha256=jAT_dMop8mjDGvyQLRxhpNlTMf_-DRN4wUyxK8EQVr0,12754
|
|
1076
|
+
moto-5.0.2.dev6.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
|
|
1077
|
+
moto-5.0.2.dev6.dist-info/entry_points.txt,sha256=QWCojULQb54Hi_2KamEEYHA6Cwek_vN685aS8DbI9rU,78
|
|
1078
|
+
moto-5.0.2.dev6.dist-info/top_level.txt,sha256=TETRKAPcAAvoZDkSkwQiZtTSr-1gzaEAXVm9FmZKj8s,5
|
|
1079
|
+
moto-5.0.2.dev6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|