Adding source code files for Chapter 12
This commit is contained in:
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
This is empty file for testing
|
||||
Reference in New Issue
Block a user