(num_days)
Sends a reminder email to the enterprise admin email addresses specified on
    the IdP's owner account for any IdPs with certificates that will expire on
    the date `num_days` from today.

    :param num_days: Query IdP certs expiring `num_days` from today.
Sends a reminder email to the enterprise admin email addresses specified on
    the IdP's owner account for any IdPs with certificates that will expire on
    the date `num_days` from today.
Sends a reminder email to the enterprise admin email addresses specified on the IdP s owner account for any IdPs with certificates that will expire on the date num_days from today .
def send_idp_cert_expires_reminder_emails(num_days):
    """
    Sends a reminder email to the enterprise admin email addresses specified on
    the IdP's owner account for any IdPs with certificates that will expire on
    the date `num_days` from today.

    :param num_days: Query IdP certs expiring `num_days` from today.
    """
    today = datetime.datetime.utcnow().date()
    date_in_n_days = today + datetime.timedelta(days=num_days)
    day_after_that = date_in_n_days + datetime.timedelta(days=1)
    queryset = IdentityProvider.objects.filter(
        is_active=True,
        date_idp_cert_expiration__gte=date_in_n_days,
        date_idp_cert_expiration__lt=day_after_that,
    )
    for idp in queryset.all():
        context = get_idp_cert_expiration_email_context(idp)
        if not context["to"]:
            log.error(f"no admin email addresses for IdP: {idp}")
        try:
            for send_to in context["to"]:
                send_html_email_async.delay(
                    context["subject"],
                    send_to,
                    context["html"],
                    text_content=context["plaintext"],
                    email_from=context["from"],
                    bcc=context["bcc"],
                )
                log.info(
                    "Sent %(num_days)s-day certificate expiration reminder "
                    "email for %(idp_name)s to %(send_to)s." % {
                        "num_days": num_days,
                        "idp_name": idp.name,
                        "send_to": send_to,
                    }
                )
        except Exception as exc:
            log.error(
                f"Failed to send cert reminder email for IdP {idp}: {exc!s}",
                exc_info=True,
            )
def send_idp_cert_expires_reminder_emails ( num_days ) : today = datetime . datetime . utcnow ( ) . date ( ) date_in_n_days = today + datetime . timedelta ( days = num_days ) day_after_that = date_in_n_days + datetime . timedelta ( days = 1 ) queryset = IdentityProvider . objects . filter ( is_active = True , date_idp_cert_expiration__gte = date_in_n_days , date_idp_cert_expiration__lt = day_after_that , ) for idp in queryset . all ( ) : context = get_idp_cert_expiration_email_context ( idp ) if not context [ "to" ] : log . error ( f"no admin email addresses for IdP: {idp}" ) try : for send_to in context [ "to" ] : send_html_email_async . delay ( context [ "subject" ] , send_to , context [ "html" ] , text_content = context [ "plaintext" ] , email_from = context [ "from" ] , bcc = context [ "bcc" ] , ) log . info ( "Sent %(num_days)s-day certificate expiration reminder " "email for %(idp_name)s to %(send_to)s." % { "num_days" : num_days , "idp_name" : idp . name , "send_to" : send_to , } ) except Exception as exc : log . error ( f"Failed to send cert reminder email for IdP {idp}: {exc!s}" , exc_info = True , )