"""Resource model — the thing being accessed."""

from typing import Any

from pydantic import BaseModel


class Resource(BaseModel):
    """The thing being accessed — a document, user record, endpoint, etc.

    The `type` field is the canonical resource type used for permission matching.
    When you call authorize(user, "write", doc) and doc.type == "documents",
    the action auto-expands to "documents:write".

    Example:
        doc = Resource(
            id="doc-123",
            type="documents",
            owner_id="alice",
            attributes={"classification": "CONFIDENTIAL"},
        )
    """

    id: str
    type: str
    attributes: dict[str, Any] = {}
    owner_id: str | None = None
