# This file is auto-generated by oagen. Do not edit.

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Dict, Optional, Union
from workos._types import _raise_deserialize_error


@dataclass(slots=True)
class AuditLogEventActor:
    """Audit Log Event Actor model."""

    id: str
    """Actor identifier."""
    type: str
    """Actor type."""
    name: Optional[str] = None
    """Optional actor name."""
    metadata: Optional[Dict[str, Union[str, float, bool]]] = None
    """Additional data associated with the event or entity."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "AuditLogEventActor":
        """Deserialize from a dictionary."""
        try:
            return cls(
                id=data["id"],
                type=data["type"],
                name=data.get("name"),
                metadata=data.get("metadata"),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AuditLogEventActor", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["id"] = self.id
        result["type"] = self.type
        if self.name is not None:
            result["name"] = self.name
        if self.metadata is not None:
            result["metadata"] = self.metadata
        return result
