# 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
from workos._types import _raise_deserialize_error
from .vault_kek_created_data_actor_source import VaultKekCreatedDataActorSource


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

    actor_id: str
    """The unique identifier of the actor."""
    actor_source: "VaultKekCreatedDataActorSource"
    actor_name: str
    """The name of the actor."""
    key_name: str
    """The name of the key encryption key."""
    key_id: str
    """The unique identifier of the key encryption key."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "VaultKekCreatedData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                actor_id=data["actor_id"],
                actor_source=VaultKekCreatedDataActorSource(data["actor_source"]),
                actor_name=data["actor_name"],
                key_name=data["key_name"],
                key_id=data["key_id"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("VaultKekCreatedData", 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_name"] = self.key_name
        result["key_id"] = self.key_id
        return result
