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

from __future__ import annotations

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


@dataclass(slots=True)
class AuditLogSchemaTarget:
    """Audit Log Schema Target model."""

    type: str
    """The type of the target resource."""
    metadata: Optional[Dict[str, Any]] = None
    """Additional data associated with the event or entity."""

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

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