-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (43 loc) · 1.49 KB
/
Copy pathmain.py
File metadata and controls
54 lines (43 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json
import logging
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
import stackref.settings as settings
from stackref.settings import return_error
from stackref.process_post_method import process_post_method
print(':: Loading function')
sentry_sdk.init(
dsn="https://YOUR_SENTRY_KEY@oYOUR_ORG.ingest.sentry.io/YOUR_PROJECT",
integrations=[
AwsLambdaIntegration()
],
enable_tracing=True,
profiles_sample_rate=1.0,
traces_sample_rate=1.0
)
'''
main
'''
def main(event, context):
log.debug(f":: Received event: {json.dumps(event, indent=2)}")
if 'headers' in event and 'x-sr-organization-uuid' in event['headers']:
organization_uuid = event['headers']['x-sr-organization-uuid']
elif 'queryStringParameters' in event and 'organization_uuid' in event['queryStringParameters']:
organization_uuid = event['queryStringParameters']['organization_uuid']
if (
'requestContext' in event and
'http' in event['requestContext'] and
'method' in event['requestContext']['http']
):
if event['requestContext']['http']['method'] == "POST":
return process_post_method(event)
else:
return return_error(405, 'main: unhandled method')
return return_error(500, 'main')
settings.init()
logging.basicConfig(level=logging.ERROR)
log = logging.getLogger(__name__)
settings.logging_config()
log.setLevel(settings.log_level)
if __name__ == "__main__":
main()