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

from __future__ import annotations

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


@dataclass(slots=True)
class UserApiKeyCreatedDataOwner:
    """User Api Key Created Data Owner model."""

    type: Literal["user"]
    """The type of the API key owner."""
    id: str
    """The unique identifier of the user who owns the API key."""
    organization_id: str
    """The unique identifier of the organization the API key belongs to."""

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

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