airflow.contrib.operators.imap_attachment_to_s3_operator

This module allows you to transfer mail attachments from a mail server into s3 bucket.

Module Contents

class airflow.contrib.operators.imap_attachment_to_s3_operator.ImapAttachmentToS3Operator(imap_attachment_name, s3_key, imap_check_regex=False, imap_mail_folder='INBOX', imap_mail_filter='All', s3_overwrite=False, imap_conn_id='imap_default', s3_conn_id='aws_default', *args, **kwargs)[source]

Bases: airflow.models.BaseOperator

Transfers a mail attachment from a mail server into s3 bucket.

Parameters
  • imap_attachment_name (str) – The file name of the mail attachment that you want to transfer.

  • s3_key (str) – The destination file name in the s3 bucket for the attachment.

  • imap_check_regex (bool) – If set checks the imap_attachment_name for a regular expression.

  • imap_mail_folder (str) – The folder on the mail server to look for the attachment.

  • imap_mail_filter (str) – If set other than ‘All’ only specific mails will be checked. See imaplib.IMAP4.search() for details.

  • s3_overwrite (bool) – If set overwrites the s3 key if already exists.

  • imap_conn_id (str) – The reference to the connection details of the mail server.

  • s3_conn_id (str) – The reference to the s3 connection details.

template_fields = ['imap_attachment_name', 's3_key', 'imap_mail_filter'][source]
execute(self, context)[source]

This function executes the transfer from the email server (via imap) into s3.

Parameters

context (dict) – The context while executing.