"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .booleanentitlementdetail import (
    BooleanEntitlementDetail,
    BooleanEntitlementDetailTypedDict,
)
from .meteredentitlementdetail import (
    MeteredEntitlementDetail,
    MeteredEntitlementDetailTypedDict,
)
from .staticentitlementdetail import (
    StaticEntitlementDetail,
    StaticEntitlementDetailTypedDict,
)
from functools import partial
from paygentic_sdk.types import BaseModel
from paygentic_sdk.utils.unions import parse_open_union
from pydantic import ConfigDict
from pydantic.functional_validators import BeforeValidator
from typing import Any, Literal, Union
from typing_extensions import Annotated, TypeAliasType


EntitlementDetailTypedDict = TypeAliasType(
    "EntitlementDetailTypedDict",
    Union[
        BooleanEntitlementDetailTypedDict,
        StaticEntitlementDetailTypedDict,
        MeteredEntitlementDetailTypedDict,
    ],
)
r"""A specific entitlement. The response shape varies by featureType."""


class UnknownEntitlementDetail(BaseModel):
    r"""A EntitlementDetail variant the SDK doesn't recognize. Preserves the raw payload."""

    feature_type: Literal["UNKNOWN"] = "UNKNOWN"
    raw: Any
    is_unknown: Literal[True] = True

    model_config = ConfigDict(frozen=True)


_ENTITLEMENT_DETAIL_VARIANTS: dict[str, Any] = {
    "boolean": BooleanEntitlementDetail,
    "static": StaticEntitlementDetail,
    "metered": MeteredEntitlementDetail,
}


EntitlementDetail = Annotated[
    Union[
        BooleanEntitlementDetail,
        StaticEntitlementDetail,
        MeteredEntitlementDetail,
        UnknownEntitlementDetail,
    ],
    BeforeValidator(
        partial(
            parse_open_union,
            disc_key="featureType",
            variants=_ENTITLEMENT_DETAIL_VARIANTS,
            unknown_cls=UnknownEntitlementDetail,
            union_name="EntitlementDetail",
        )
    ),
]
r"""A specific entitlement. The response shape varies by featureType."""
