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

from __future__ import annotations

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


@dataclass(slots=True)
class CreateDataKeyResponse:
    """Create Data Key Response model."""

    context: Dict[str, str]
    """Map of values used to determine the encryption key."""
    data_key: str
    """Base64-encoded data encryption key."""
    encrypted_keys: str
    """Base64-encoded encrypted data key blob."""
    id: str
    """Unique identifier for the generated data key."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "CreateDataKeyResponse":
        """Deserialize from a dictionary."""
        try:
            return cls(
                context=data["context"],
                data_key=data["data_key"],
                encrypted_keys=data["encrypted_keys"],
                id=data["id"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("CreateDataKeyResponse", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["context"] = self.context
        result["data_key"] = self.data_key
        result["encrypted_keys"] = self.encrypted_keys
        result["id"] = self.id
        return result
