Skip to content

Commit

Permalink
Remove Provider Deprecations in SendGrid (#44637)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason810496 authored Dec 6, 2024
1 parent e625e7f commit cba3e38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
12 changes: 12 additions & 0 deletions providers/src/airflow/providers/sendgrid/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
Changelog
---------

main
.....

.. warning::
All deprecated classes, parameters and features have been removed from the SendGrid provider package.
The following breaking changes were introduced:

* Utils

* Removed Fetching SendGrid credentials from environment variables. Use ``Connection`` to set credentials instead.


3.6.0
.....

Expand Down
18 changes: 2 additions & 16 deletions providers/src/airflow/providers/sendgrid/utils/emailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import logging
import mimetypes
import os
import warnings
from collections.abc import Iterable
from typing import Union

Expand All @@ -40,7 +39,6 @@
SandBoxMode,
)

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.hooks.base import BaseHook
from airflow.utils.email import get_email_address_list

Expand Down Expand Up @@ -126,20 +124,8 @@ def send_email(


def _post_sendgrid_mail(mail_data: dict, conn_id: str = "sendgrid_default") -> None:
api_key = None
try:
conn = BaseHook.get_connection(conn_id)
api_key = conn.password
except AirflowException:
pass
if api_key is None:
warnings.warn(
"Fetching Sendgrid credentials from environment variables will be deprecated in a future "
"release. Please set credentials using a connection instead.",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
api_key = os.environ.get("SENDGRID_API_KEY")
conn = BaseHook.get_connection(conn_id)
api_key = conn.password
sendgrid_client = sendgrid.SendGridAPIClient(api_key=api_key)
response = sendgrid_client.client.mail.send.post(request_body=mail_data)
# 2xx status code.
Expand Down

0 comments on commit cba3e38

Please sign in to comment.