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

from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, List
from workos._types import _raise_deserialize_error
from .vault_dek_read_data_actor_source import VaultDekReadDataActorSource


@dataclass(slots=True)
class VaultDekReadData:
    """The event payload."""

    actor_id: str
    """The unique identifier of the actor."""
    actor_source: "VaultDekReadDataActorSource"
    actor_name: str
    """The name of the actor."""
    key_ids: List[str]
    """The unique identifiers of the data encryption keys."""
    key_context: Dict[str, str]

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "VaultDekReadData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                actor_id=data["actor_id"],
                actor_source=VaultDekReadDataActorSource(data["actor_source"]),
                actor_name=data["actor_name"],
                key_ids=data["key_ids"],
                key_context=data["key_context"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("VaultDekReadData", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["actor_id"] = self.actor_id
        result["actor_source"] = (
            self.actor_source.value
            if isinstance(self.actor_source, Enum)
            else self.actor_source
        )
        result["actor_name"] = self.actor_name
        result["key_ids"] = self.key_ids
        result["key_context"] = self.key_context
        return result
