# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class CredentialHealthStatus(UniversalBaseModel):
    """
    Health status for a credential.
    """

    credential_id: str = pydantic.Field()
    """
    Credential ID
    """

    tool_key: str = pydantic.Field()
    """
    Tool key
    """

    status: str = pydantic.Field()
    """
    Health status: healthy, unhealthy, or unknown
    """

    is_active: bool = pydantic.Field()
    """
    Whether credential is active in DB
    """

    connection_status: typing.Optional[str] = pydantic.Field(default=None)
    """
    Connection status
    """

    reason: typing.Optional[str] = pydantic.Field(default=None)
    """
    Reason for unhealthy status
    """

    last_checked_at: dt.datetime = pydantic.Field()
    """
    Timestamp of health check
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
