# 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
from .attachment_summary import AttachmentSummary


class RuleListResponse(UniversalBaseModel):
    """
    Response schema for rule list (optimized without full content).
    """

    id: str = pydantic.Field()
    """
    Rule ID with rule_ prefix
    """

    name: str = pydantic.Field()
    """
    Rule name
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Rule description
    """

    content_preview: str = pydantic.Field()
    """
    First 200 characters of rule content
    """

    content_length: int = pydantic.Field()
    """
    Total character count of content
    """

    category: typing.Optional[str] = pydantic.Field(default=None)
    """
    Rule category
    """

    rule_type: typing.Optional[str] = pydantic.Field(default=None)
    """
    Rule type
    """

    scope: typing.Optional[str] = pydantic.Field(default=None)
    """
    Rule scope
    """

    apply_mode: typing.Optional[str] = pydantic.Field(default=None)
    """
    Rule apply mode
    """

    organization_id: str = pydantic.Field()
    """
    Organization ID
    """

    created_by: str = pydantic.Field()
    """
    User ID who created the rule
    """

    is_public: bool = pydantic.Field()
    """
    Whether rule is public
    """

    is_active: bool = pydantic.Field()
    """
    Whether rule is active
    """

    version: int = pydantic.Field()
    """
    Rule version number
    """

    usage_count: int = pydantic.Field()
    """
    Number of active attachments
    """

    can_edit: bool = pydantic.Field()
    """
    Whether current user can edit this rule
    """

    created_at: dt.datetime = pydantic.Field()
    """
    Creation timestamp
    """

    updated_at: dt.datetime = pydantic.Field()
    """
    Last update timestamp
    """

    attached_entities: typing.Optional[typing.List[AttachmentSummary]] = pydantic.Field(default=None)
    """
    List of attached entities (only included when include_attachments=true)
    """

    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
