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

from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime
from typing import cast
from typing import Any, Dict, Optional
from workos._types import _raise_deserialize_error
from workos._types import _format_datetime, _parse_datetime

from .agent_registration_claim_claim_completion import (
    AgentRegistrationClaimClaimCompletion,
)


@dataclass(slots=True)
class AgentRegistrationClaim:
    """Agent Registration Claim model."""

    id: str
    """Unique identifier of the claim."""
    claim_completion: Optional["AgentRegistrationClaimClaimCompletion"]
    """The completion record for the claim, or `null` if the claim has not been completed."""
    created_at: datetime
    """The timestamp when the claim was created."""
    updated_at: datetime
    """The timestamp when the claim was last updated."""
    expires_at: datetime
    """The timestamp when the claim expires."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "AgentRegistrationClaim":
        """Deserialize from a dictionary."""
        try:
            return cls(
                id=data["id"],
                claim_completion=AgentRegistrationClaimClaimCompletion.from_dict(
                    cast(Dict[str, Any], _v_claim_completion)
                )
                if (_v_claim_completion := data["claim_completion"]) is not None
                else None,
                created_at=_parse_datetime(data["created_at"]),
                updated_at=_parse_datetime(data["updated_at"]),
                expires_at=_parse_datetime(data["expires_at"]),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AgentRegistrationClaim", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["id"] = self.id
        if self.claim_completion is not None:
            result["claim_completion"] = self.claim_completion.to_dict()
        else:
            result["claim_completion"] = None
        result["created_at"] = _format_datetime(self.created_at)
        result["updated_at"] = _format_datetime(self.updated_at)
        result["expires_at"] = _format_datetime(self.expires_at)
        return result
