def expiring(ttl, deployment):
    """
    Returns certificates expiring in the next n days.
    """
    headers = ["Common Name", "Owner", "Issuer", "Validity End", "Endpoint"]
    rows = []

    for cert in expiring_certificates(ttl=ttl, deployment=deployment).all():
        for endpoint in cert.endpoints:
            rows.append(
                [cert.cn, cert.owner, cert.issuer, cert.not_after, endpoint.dnsname]
            )

    click.echo(tabulate(rows, headers=headers))

    Returns certificates expiring in the next n days.
    
lemur/reporting/cli.py