# 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 PrincipalContextEntity(UniversalBaseModel):
    """
    Principal context representing an authenticated user or service user.

    The member_id is:
    - For human users: WorkOS user ID (e.g., "user_xyz")
    - For service users: Service user ID (e.g., "svc_abc123")

    This is the primary identifier used for authorization checks in OpenFGA.
    """

    api_key_id: typing.Optional[str] = None
    email: typing.Optional[str] = None
    is_service_user: typing.Optional[bool] = None
    member_id: str
    name: typing.Optional[str] = None
    org_id: typing.Optional[str] = None
    role: typing.Optional[str] = None

    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
