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

from __future__ import annotations

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


@dataclass(slots=True)
class AgentRegistrationCreatedDataAgentIdentity:
    """The agent identity for this registration."""

    object: Literal["agent_identity"]
    """Distinguishes the agent identity object."""
    id: str
    """Unique identifier of the agent identity."""
    userland_user_id: Union[str, Optional[Literal["null"]]]
    """The ID of the userland user bound to this agent identity."""

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

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