"""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
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


UpdateSourceProcessingMode = Literal[
    "automatic",
    "manual",
]
r"""How events are processed - automatic (immediate) or manual (requires approval)"""


class UpdateSourceRequestBodyTypedDict(TypedDict):
    config: NotRequired[Dict[str, Any]]
    r"""Configuration specific to the source type"""
    description: NotRequired[str]
    r"""Description of the source"""
    enabled: NotRequired[bool]
    r"""Whether the source is enabled"""
    metadata: NotRequired[Dict[str, Any]]
    r"""Metadata for the source"""
    name: NotRequired[str]
    r"""Display name for the source"""
    processing_mode: NotRequired[UpdateSourceProcessingMode]
    r"""How events are processed - automatic (immediate) or manual (requires approval)"""


class UpdateSourceRequestBody(BaseModel):
    config: Optional[Dict[str, Any]] = None
    r"""Configuration specific to the source type"""

    description: Optional[str] = None
    r"""Description of the source"""

    enabled: Optional[bool] = None
    r"""Whether the source is enabled"""

    metadata: Optional[Dict[str, Any]] = None
    r"""Metadata for the source"""

    name: Optional[str] = None
    r"""Display name for the source"""

    processing_mode: Annotated[
        Optional[UpdateSourceProcessingMode], pydantic.Field(alias="processingMode")
    ] = None
    r"""How events are processed - automatic (immediate) or manual (requires approval)"""

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

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

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

        return m


class UpdateSourceRequestTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the source"""
    request_body: UpdateSourceRequestBodyTypedDict


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

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


try:
    UpdateSourceRequestBody.model_rebuild()
except NameError:
    pass
