· 5 years ago · Aug 18, 2020, 03:00 PM
1def APICall():
2 # API KEY to be included here to authenticate to REST API
3
4 headers = {
5 'Authorization': 'ApiKey MTAzNDI6NDQ3YzJkNWItY2U1My00MjI4LWIyOTQtNmMwNmRjYWQ0M2U4',
6 }
7
8 # Prints the response from API
9
10 r = requests.get('https://api.youmanage.co.uk/Employees', headers=headers)
11
12 print(r.text)
13
14 with open('youmanage_data.txt', 'w') as apioutput:
15 apioutput.write(r.text)
16
17
18def S3Upload():
19 bucketName = "pythontesting2"
20 Key = "youmanage_data.txt"
21 outPutname = "youmanage_data.txt"
22
23 s3 = boto3.client('s3')
24 s3.upload_file(Key, bucketName, outPutname)
25
26
27def YouManage_Client_Lambda(event, context):
28 APICall()
29 S3Upload()
30# Calls functions sequentially