[
https://issues.apache.org/jira/browse/AIRFLOW-2780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16670132#comment-16670132
]
ASF GitHub Bot commented on AIRFLOW-2780:
-----------------------------------------
feluelle opened a new pull request #4119: [AIRFLOW-2780] Add IMAP Hook to
retrieve email attachments
URL: https://github.com/apache/incubator-airflow/pull/4119
### JIRA
- [x] My PR addresses the following [Airflow
JIRA](https://issues.apache.org/jira/browse/AIRFLOW-2780) issues and references
them in the PR title.
### Description
- [x] My PR adds the feature to be able to interact with a mail server via
the IMAP Protocol. It exposes the following methods:
- `has_mail_attachment`: Can be used in a `Sensor` to poke the mail server
for attachments with the given name and returns True if at least one has been
found and False if not.
- `retrieve_mail_attachments`: Can be used in an `Operator` to do sth. with
the attachments returned as list of tuple (filename, payload).
- `download_mail_attachments`: Can be used in an `Operator` to download the
attachment.
### Tests
- [x] My PR adds the following unit tests __OR__ does not need testing for
this extremely good reason:
- `test_connect_and_disconnect`: this tests calls the ImapHook as
ContextManager and so it tests for both (on enter/connect and on
exit/disconnect)
- `test_has_mail_attachments_found`
- `test_has_mail_attachments_not_found`
- `test_has_mail_attachments_with_regex_found`
- `test_has_mail_attachments_with_regex_not_found`
- `test_retrieve_mail_attachments_found`
- `test_retrieve_mail_attachments_not_found`
- `test_retrieve_mail_attachments_with_regex_found`
- `test_retrieve_mail_attachments_with_regex_not_found`
- `test_retrieve_mail_attachments_latest_only`
- `test_download_mail_attachments_found`
- `test_download_mail_attachments_not_found`
- `test_download_mail_attachments_with_regex_found`
- `test_download_mail_attachments_with_regex_not_found`
- `test_download_mail_attachments_with_latest_only`
- `test_download_mail_attachments_with_escaping_chars`
- `test_download_mail_attachments_with_symlink`
### Commits
- [x] My commits all reference JIRA issues in their subject lines, and I
have squashed multiple commits if they address the same issue. In addition, my
commits follow the guidelines from "[How to write a good git commit
message](http://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
2. Subject is limited to 50 characters
3. Subject does not end with a period
4. Subject uses the imperative mood ("add", not "adding")
5. Body wraps at 72 characters
6. Body explains "what" and "why", not "how"
### Documentation
- [x] In case of new functionality, my PR adds documentation that describes
how to use it.
- When adding new operators/hooks/sensors, the autoclass documentation
generation needs to be added.
### Code Quality
- [x] Passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Adds IMAP Hook to interact with a mail server
> ---------------------------------------------
>
> Key: AIRFLOW-2780
> URL: https://issues.apache.org/jira/browse/AIRFLOW-2780
> Project: Apache Airflow
> Issue Type: New Feature
> Reporter: Felix Uellendall
> Assignee: Felix Uellendall
> Priority: Major
>
> This Hook connects to a mail server via IMAP to be able to retrieve email
> attachments by using [Python's IMAP
> Library.|https://docs.python.org/3.6/library/imaplib.html]
> Features:
> - `has_mail_attachment`: Can be used in a `Sensor` to check if there is an
> attachment on the mail server with the given name.
> - `retrieve_mail_attachments`: Can be used in an `Operator` to do sth. with
> the attachments returned as list of tuple.
> - `download_mail_attachments`: Can be used in an `Operator` to download the
> attachment.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)