-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplyJob.py
27 lines (26 loc) · 1.05 KB
/
applyJob.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
import json
import boto3
def lambda_handler(event, context):
# TODO implement
print(event)
dynamo = boto3.client('dynamodb')
dynamoDB = boto3.resource('dynamodb')
body = json.loads(event['body'])
candidates = dynamo.get_item(TableName="candidateJobApplication", Key={'jobId': {'S': body['jobId']}})
if 'Item' in candidates.keys():
print(candidates)
finalCandidates = str(candidates['Item']['candidateId']['S']) + ',' +body['candidateId']
dynamo.put_item(TableName='candidateJobApplication', Item={'jobId':{'S': body['jobId']},
'candidateId': {'S': finalCandidates}})
else:
dynamo.put_item(TableName='candidateJobApplication', Item={'jobId':{'S': body['jobId']},
'candidateId': {'S': body['candidateId']}})
return {
'statusCode': 200,
'headers': {
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'POST, OPTIONS'
},
'body': json.dumps('Hello from Lambda!')
}