# 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 cast
from typing import Any, Dict, Literal
from workos._types import _raise_deserialize_error

from .agent_registration_created_data_agent_identity import (
    AgentRegistrationCreatedDataAgentIdentity,
)
from .agent_registration_created_data_kind import AgentRegistrationCreatedDataKind
from .agent_registration_created_data_method import AgentRegistrationCreatedDataMethod
from .agent_registration_created_data_status import AgentRegistrationCreatedDataStatus


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

    object: Literal["agent_registration"]
    """Distinguishes the agent registration object."""
    id: str
    """Unique identifier of the agent registration."""
    agent_identity: "AgentRegistrationCreatedDataAgentIdentity"
    """The agent identity for this registration."""
    organization_id: str
    """The ID of the organization the registration belongs to."""
    status: "AgentRegistrationCreatedDataStatus"
    """The current status of the registration."""
    kind: "AgentRegistrationCreatedDataKind"
    """The kind of the registration."""
    method: "AgentRegistrationCreatedDataMethod"
    """The authentication method of the registration."""
    created_at: str
    """The timestamp when the registration was created."""
    updated_at: str
    """The timestamp when the registration was last updated."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "AgentRegistrationCreatedData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                object=data.get("object", "agent_registration"),
                id=data["id"],
                agent_identity=AgentRegistrationCreatedDataAgentIdentity.from_dict(
                    cast(Dict[str, Any], data["agent_identity"])
                ),
                organization_id=data["organization_id"],
                status=AgentRegistrationCreatedDataStatus(data["status"]),
                kind=AgentRegistrationCreatedDataKind(data["kind"]),
                method=AgentRegistrationCreatedDataMethod(data["method"]),
                created_at=data["created_at"],
                updated_at=data["updated_at"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AgentRegistrationCreatedData", 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["agent_identity"] = self.agent_identity.to_dict()
        result["organization_id"] = self.organization_id
        result["status"] = (
            self.status.value if isinstance(self.status, Enum) else self.status
        )
        result["kind"] = self.kind.value if isinstance(self.kind, Enum) else self.kind
        result["method"] = (
            self.method.value if isinstance(self.method, Enum) else self.method
        )
        result["created_at"] = self.created_at
        result["updated_at"] = self.updated_at
        return result
