modmex-lambda 0.6.1__py3-none-any.whl → 0.6.2__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.
- modmex_lambda/stream/events/s3.py +52 -0
- {modmex_lambda-0.6.1.dist-info → modmex_lambda-0.6.2.dist-info}/METADATA +1 -1
- {modmex_lambda-0.6.1.dist-info → modmex_lambda-0.6.2.dist-info}/RECORD +5 -5
- {modmex_lambda-0.6.1.dist-info → modmex_lambda-0.6.2.dist-info}/WHEEL +0 -0
- {modmex_lambda-0.6.1.dist-info → modmex_lambda-0.6.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,6 +2,15 @@ import json
|
|
|
2
2
|
import pydash
|
|
3
3
|
from pydash import get
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
'from_s3',
|
|
8
|
+
'from_sqs_eventbridge_s3',
|
|
9
|
+
'from_sqs_sns_s3',
|
|
10
|
+
'to_s3_records',
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
|
|
5
14
|
def from_s3(event):
|
|
6
15
|
return pydash.map_(
|
|
7
16
|
event['Records'],
|
|
@@ -27,6 +36,41 @@ def from_sqs_sns_s3(event):
|
|
|
27
36
|
).flatten().value()
|
|
28
37
|
|
|
29
38
|
|
|
39
|
+
def from_sqs_eventbridge_s3(event):
|
|
40
|
+
"""Normalize an S3 EventBridge notification delivered through SQS."""
|
|
41
|
+
return pydash._(event['Records']).map(
|
|
42
|
+
lambda sqs_record: _from_sqs_eventbridge_record(sqs_record)
|
|
43
|
+
).flatten().value()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _from_sqs_eventbridge_record(sqs_record):
|
|
47
|
+
eventbridge_record = json.loads(sqs_record['body'])
|
|
48
|
+
detail = eventbridge_record['detail']
|
|
49
|
+
s3_record = {
|
|
50
|
+
**eventbridge_record,
|
|
51
|
+
'eventName': _eventbridge_s3_event_name(eventbridge_record),
|
|
52
|
+
's3': detail,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return pydash.map_(from_s3({'Records': [s3_record]}), lambda uow: {
|
|
56
|
+
**uow,
|
|
57
|
+
'record': {
|
|
58
|
+
'sqs': sqs_record,
|
|
59
|
+
'eventbridge': eventbridge_record,
|
|
60
|
+
's3': uow['record'],
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _eventbridge_s3_event_name(eventbridge_record):
|
|
66
|
+
detail_type = eventbridge_record.get('detail-type', '')
|
|
67
|
+
if detail_type.startswith('Object Created'):
|
|
68
|
+
return 'ObjectCreated:Put'
|
|
69
|
+
if detail_type.startswith('Object Deleted'):
|
|
70
|
+
return 'ObjectCreated:Delete'
|
|
71
|
+
return detail_type
|
|
72
|
+
|
|
73
|
+
|
|
30
74
|
def _from_sqs_record(sqs_record):
|
|
31
75
|
sns_record = json.loads(sqs_record['body'])
|
|
32
76
|
s3_event = json.loads(sns_record['Message'])
|
|
@@ -92,3 +136,11 @@ def to_s3_records(notifications):
|
|
|
92
136
|
for i,n in enumerate(notifications)
|
|
93
137
|
]
|
|
94
138
|
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
__all__ = [
|
|
142
|
+
'from_s3',
|
|
143
|
+
'from_sqs_sns_s3',
|
|
144
|
+
'from_sqs_eventbridge_s3',
|
|
145
|
+
'to_s3_records',
|
|
146
|
+
]
|
|
@@ -77,7 +77,7 @@ modmex_lambda/stream/schedulers.py,sha256=A_wFD1e7CGFGO6--QHln8Eho08fdH5W-OVWfho
|
|
|
77
77
|
modmex_lambda/stream/events/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
78
|
modmex_lambda/stream/events/dynamodb.py,sha256=T1g9j4QpWC1gBYaFm11YdcQ9Ma0konHIVF48mOAD_PE,4895
|
|
79
79
|
modmex_lambda/stream/events/kinesis.py,sha256=BDSO7mwAV6utXROBxbyv36fbNspwOkHpvnysmFNDz0Q,1154
|
|
80
|
-
modmex_lambda/stream/events/s3.py,sha256=
|
|
80
|
+
modmex_lambda/stream/events/s3.py,sha256=618h_xKpkA_6OfXzjVii3QwJWJUjqMn_FeMG2hoqit0,4417
|
|
81
81
|
modmex_lambda/stream/events/sns.py,sha256=MHtLaKKYvmhPOQjqCMgxNFXpBuYfW4wGaC1BxwWTaIw,2073
|
|
82
82
|
modmex_lambda/stream/events/sqs.py,sha256=AnaIdTJA5emzPKMXG-8OQTmhmB6PrGu4zXDepcHqxNE,1470
|
|
83
83
|
modmex_lambda/stream/filters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -144,7 +144,7 @@ modmex_lambda/stream/utils/time.py,sha256=dnsL2xeWpa1FXm2p8y9rWXtICMBlCBkgLaJ_en
|
|
|
144
144
|
modmex_lambda/stream/utils/uow.py,sha256=8WSPVE7AiHInkFDfBEeKOvdirY6GAgBoS7qkF1f1JVM,3207
|
|
145
145
|
modmex_lambda/stream/utils/data_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
146
146
|
modmex_lambda/stream/utils/data_classes/dynamodb.py,sha256=h_7MtUyRkvvV1r2QECrRDu7RR4Hh94SwSjc_8K2_XGM,363
|
|
147
|
-
modmex_lambda-0.6.
|
|
148
|
-
modmex_lambda-0.6.
|
|
149
|
-
modmex_lambda-0.6.
|
|
150
|
-
modmex_lambda-0.6.
|
|
147
|
+
modmex_lambda-0.6.2.dist-info/METADATA,sha256=vHq4XiLw3MfkwjyqYeg1yyHqBbrBLqJD1ZDBgDjR93Q,35443
|
|
148
|
+
modmex_lambda-0.6.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
149
|
+
modmex_lambda-0.6.2.dist-info/licenses/LICENSE,sha256=_C2TDTOsYeJvE4vn9VB51laKvleBKbdNnn96wJVtXhQ,1063
|
|
150
|
+
modmex_lambda-0.6.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|