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

from __future__ import annotations

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


@dataclass(slots=True)
class ConnectionSAMLCertificateRenewalRequiredDataConnection:
    """The connection with the expiring certificate."""

    id: str
    """Unique identifier of the connection."""
    organization_id: Optional[str] = None
    """The ID of the organization the connection belongs to."""

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

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