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

import typing

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


class Rule(UniversalBaseModel):
    name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Name of this rule.
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of this rule.
    """

    enabled: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the rule is enabled (true), or disabled (false).
    """

    script: typing.Optional[str] = pydantic.Field(default=None)
    """
    Code to be executed when this rule runs.
    """

    order: typing.Optional[float] = pydantic.Field(default=None)
    """
    Order that this rule should execute in relative to other rules. Lower-valued rules execute first.
    """

    stage: typing.Optional[str] = pydantic.Field(default=None)
    """
    Execution stage of this rule. Can be `login_success`, `login_failure`, or `pre_authorize`.
    """

    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
