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

from __future__ import annotations
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
from paygentic_sdk.utils import FieldMetadata, PathParamMetadata, RequestMetadata
from pydantic import model_serializer
from typing import Dict, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


UpdateFeatureType = Literal[
    "metered",
    "static",
    "boolean",
]
r"""Updated feature type"""


class UpdateFeatureRequestBodyTypedDict(TypedDict):
    key: NotRequired[str]
    r"""Updated feature key slug. Sample values: 'increased-api-limit', 'new-storage-tier'"""
    name: NotRequired[str]
    r"""Updated feature name."""
    type: NotRequired[UpdateFeatureType]
    r"""Updated feature type"""
    metadata: NotRequired[Dict[str, str]]
    r"""Updated metadata for the feature"""


class UpdateFeatureRequestBody(BaseModel):
    key: Optional[str] = None
    r"""Updated feature key slug. Sample values: 'increased-api-limit', 'new-storage-tier'"""

    name: Optional[str] = None
    r"""Updated feature name."""

    type: Optional[UpdateFeatureType] = None
    r"""Updated feature type"""

    metadata: Optional[Dict[str, str]] = None
    r"""Updated metadata for the feature"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["key", "name", "type", "metadata"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class UpdateFeatureRequestTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the feature"""
    request_body: UpdateFeatureRequestBodyTypedDict


class UpdateFeatureRequest(BaseModel):
    id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The unique identifier of the feature"""

    request_body: Annotated[
        UpdateFeatureRequestBody,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]
