-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.py
74 lines (50 loc) · 1.68 KB
/
handler.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import json
import os
import boto3
from xref_service import xref_service
dynamodb = boto3.resource('dynamodb')
table_name = os.environ['DYNAMODB_TABLE']
table = dynamodb.Table(table_name)
def get_ids(event, context):
path_parameters = event['pathParameters']
system = path_parameters['system1']
system_id = path_parameters['system1_id']
system_object = {'system': system, 'id': system_id}
ids = xref_service.get_ids(table, system_object)
response = {
"statusCode": 200,
"body": json.dumps(ids)
}
return response
def new_global_id(event, context):
global_id = xref_service.create_new_key(table)
response = {
"statusCode": 200,
"body": json.dumps(global_id)
}
return response
def link_system_ids(event, context):
path_parameters = event['pathParameters']
system1 = path_parameters['system1']
system1_id = path_parameters['system1_id']
system_object1 = {'system': system1, 'id': system1_id}
system2 = path_parameters['system2']
system2_id = path_parameters['system2_id']
system_object2 = {'system': system2, 'id': system2_id}
changes = xref_service.link_system_ids(table, system_object1,
system_object2)
response = {
"statusCode": 200,
"body": json.dumps(changes)
}
return response
def delete_id(event, context):
path_parameters = event['pathParameters']
system = path_parameters['system1']
system_id = path_parameters['system1_id']
system_object = {'system': system, 'id': system_id}
xref_service.delete_id(table, system_object)
response = {
"statusCode": 200
}
return response