Functional Weave
Code in Python

monitor.cert-check@1.0.0

impl/python.py

667 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from .monitor_cert_expiry import CertExpiryState  ← from monitor.cert-expiry ^1.0.0 · built alongside by fune
from .monitor_check_status import CheckStatus  ← from monitor.check-status ^1.0.0 · built alongside by fune

_STATUS = {"ok": "up", "warning": "up", "critical": "degraded", "expired": "down"}


def cert_check(state: CertExpiryState) -> CheckStatus:
    """A certificate as one check behind a status page component. A warning
    is work for the operator, not something a visitor notices, so it stays
    up; critical is degraded because renewal is now urgent; an expired
    certificate breaks every client, so it is down."""
    if state not in _STATUS:
        raise ValueError("unknown certificate state: %s" % (state,))
    return _STATUS[state]  # type: ignore[return-value]