common_reports.emails.providers.gmail
Complete Gmail API mailbox provider plus compatible app-password SMTP mode.
Classes
GmailProvider
Bases: BaseProvider
Gmail backend using either SMTP/IMAP or delegated Gmail API credentials.
__init__
def __init__(gmail: GmailConfig, imap: Optional[ImapConfig] = None)Fields and properties declared here; inherited members belong to the bases above.
backend
backend = 'gmail'capabilities
capabilities = frozenset({EmailCapability.SEND})gmail
gmail = gmailimap
imap = imaplogger
logger = structlog.get_logger(self.__class__.__name__).bind(backend=(self.backend), user=(gmail.user), mode=('api' if gmail.use_api else 'smtp'))mailbox
Read-only property.
mailbox: MailboxRefclose
def close() -> NoneClose every transport this provider opened and drop the service; a later call opens fresh ones. Close once the calls in flight have finished.
create_draft
def create_draft(mime: Message, thread_id: str | None, recipients: builtins.list[str] | None = None) -> Mapping[str, Any]create_label
def create_label(request: LabelCreateRequest) -> EmailLabelRecorddelete_draft
def delete_draft(draft_id: str) -> Nonedelete_label
def delete_label(label_id: str) -> Noneget_attachment
def get_attachment(message_id: str, attachment_id: str) -> tuple[EmailAttachmentRecord, bytes]get_backend_info
def get_backend_info() -> Mapping[str, Any]get_message
def get_message(message_id: str) -> EmailMessageRecordget_profile
def get_profile() -> MailboxProfileget_thread
def get_thread(thread_id: str) -> EmailThreadRecordlist
def list(folder: str = 'INBOX', limit: int = 10, unseen_only: bool = False) -> builtins.list[ReadResult]list_history
def list_history(query: HistoryQuery) -> tuple[str | None, builtins.list[EmailHistoryChange], str | None]list_labels
def list_labels() -> builtins.list[EmailLabelRecord]list_message_refs
def list_message_refs(query: MessageQuery) -> tuple[builtins.list[MessageRef], str | None, int | None]list_thread_refs
def list_thread_refs(query: MessageQuery) -> tuple[builtins.list[ThreadRef], str | None, int | None]modify_labels
def modify_labels(update: LabelUpdate) -> Mapping[str, Any]reply
def reply(mime: Message, recipients: list[str], thread_id: str | None) -> EmailDeliveryRecordsearch
def search(query: MessageQuery) -> tuple[builtins.list[EmailMessageRecord], str | None, int | None]send
def send(mime: Message, recipients: list[str]) -> str | EmailDeliveryRecordsend_draft
def send_draft(draft_id: str) -> Mapping[str, Any]stop_watch
def stop_watch() -> Nonewatch
def watch(request: WatchRequest) -> tuple[str | None, datetime | None]