Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Provider Deprecations in SendGrid #44637

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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