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

from ..core.pydantic_utilities import UniversalBaseModel
import typing_extensions
import typing
from ..core.serialization import FieldMetadata
import pydantic
from .v_1_member_type import V1MemberType
from .context_access_type import ContextAccessType
from .context_auth_mode import ContextAuthMode
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class AuditEventContext(UniversalBaseModel):
    """
    Context for an audit event.
    """

    change_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="changeID")] = pydantic.Field(
        default=None
    )
    """
    ID for the audit event.
    """

    request_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="requestID")] = pydantic.Field(
        default=None
    )
    """
    ID for the request that caused the event.
    """

    trace_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="traceID")] = pydantic.Field(
        default=None
    )
    """
    ID for the request set by the service that received the request.
    """

    session_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="sessionID")] = pydantic.Field(
        default=None
    )
    """
    ID for the session in which the request was sent.
    """

    actor: typing.Optional[str] = pydantic.Field(default=None)
    """
    Member who sent the request. Depending on `actorType`, this may be a user ID or a service account ID.
    """

    actor_type: typing_extensions.Annotated[typing.Optional[V1MemberType], FieldMetadata(alias="actorType")] = None
    access_type: typing_extensions.Annotated[typing.Optional[ContextAccessType], FieldMetadata(alias="accessType")] = (
        None
    )
    ip_address: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="ipAddress")] = pydantic.Field(
        default=None
    )
    """
    IP Address of the client that made the request.
    """

    origin: typing.Optional[str] = pydantic.Field(default=None)
    """
    HTTP Origin request header (including scheme, hostname, and port) of the request.
    """

    auth_mode: typing_extensions.Annotated[typing.Optional[ContextAuthMode], FieldMetadata(alias="authMode")] = None
    jwt_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="jwtID")] = pydantic.Field(
        default=None
    )
    """
    ID of the JWT token.
    """

    bearer_token_context_id: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="bearerTokenContextID")
    ] = pydantic.Field(default=None)
    """
    Embedded User Context.
    """

    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
