Adding source code files for Chapter 12

This commit is contained in:
muassif
2021-07-15 15:29:26 +04:00
committed by GitHub
parent 822894f3ea
commit 7b9db1b3fc
5 changed files with 44 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail, Email, To, Content
def handle_storage_event(event, context):
from_email = Email("masif.72@gmail.com")
to_emails = To("masif.carleton@gmail.com")
subject = "Your Storage Bucket Notification"
content = Content("text/plain",
f"Bucket Impacted:{event['bucket']} \n" +
f"File Impacted: {event['name']} \n " +
f"Event Time: {event['timeCreated']} \n" +
f"Event ID: {context.event_id} \n" +
f"Event Type: {context.event_type}"
)
mail = Mail(from_email, to_emails, subject, content)
mail_json = mail.get()
sg = SendGridAPIClient()
response = sg.client.mail.send.post(request_body=mail_json)
print(response.status_code) # for logging purpose
print(response.headers)
@@ -0,0 +1,3 @@
python-http-client==3.3.2
sendgrid==6.7.1
starkbank-ecdsa==1.1.1
+1
View File
@@ -0,0 +1 @@
This is empty file for testing