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

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, cast

from workos._types import _raise_deserialize_error

from .jwks_response_keys import JwksResponseKeys


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

    keys: list[JwksResponseKeys]
    """The public keys used for verifying access tokens."""

    @classmethod
    def from_dict(cls, data: dict[str, Any]) -> JwksResponse:
        """Deserialize from a dictionary."""
        try:
            return cls(
                keys=[
                    JwksResponseKeys.from_dict(cast(dict[str, Any], item))
                    for item in cast(list[Any], data["keys"])
                ],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("JwksResponse", e)

    def to_dict(self) -> dict[str, Any]:
        """Serialize to a dictionary."""
        result: dict[str, Any] = {}
        result["keys"] = [item.to_dict() for item in self.keys]
        return result
