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

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Literal

from workos._types import _raise_deserialize_error


@dataclass(slots=True)
class JwksResponseKeys:
    """Jwks Response Keys model."""

    alg: Literal["RS256"]
    """Algorithm."""
    kty: Literal["RSA"]
    """Key type."""
    use: Literal["sig"]
    """Key use (signature)."""
    x_5_c: list[str]
    """X.509 certificate chain."""
    n: str
    """RSA modulus."""
    e: str
    """RSA exponent."""
    kid: str
    """Key ID."""
    x_5_t_s_256: str
    """X.509 certificate SHA-256 thumbprint."""

    @classmethod
    def from_dict(cls, data: dict[str, Any]) -> JwksResponseKeys:
        """Deserialize from a dictionary."""
        try:
            return cls(
                alg=data.get("alg", "RS256"),
                kty=data.get("kty", "RSA"),
                use=data.get("use", "sig"),
                x_5_c=data["x5c"],
                n=data["n"],
                e=data["e"],
                kid=data["kid"],
                x_5_t_s_256=data["x5t#S256"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("JwksResponseKeys", e)

    def to_dict(self) -> dict[str, Any]:
        """Serialize to a dictionary."""
        result: dict[str, Any] = {}
        result["alg"] = self.alg
        result["kty"] = self.kty
        result["use"] = self.use
        result["x5c"] = self.x_5_c
        result["n"] = self.n
        result["e"] = self.e
        result["kid"] = self.kid
        result["x5t#S256"] = self.x_5_t_s_256
        return result
