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

from __future__ import annotations
from enum import Enum
from panora_sdk.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Optional, TypedDict, Union
from typing_extensions import Annotated, NotRequired


class PassThroughRequestDtoMethod(str, Enum):
    GET = "GET"
    POST = "POST"

class DataTypedDict(TypedDict):
    pass
    

class Data(BaseModel):
    pass
    

class HeadersTypedDict(TypedDict):
    pass
    

class Headers(BaseModel):
    pass
    

class PassThroughRequestDtoTypedDict(TypedDict):
    method: PassThroughRequestDtoMethod
    path: Nullable[str]
    data: NotRequired[DataTypedDict]
    request_format: NotRequired[Nullable[RequestFormatTypedDict]]
    override_base_url: NotRequired[Nullable[Dict[str, Any]]]
    headers: NotRequired[HeadersTypedDict]
    

class PassThroughRequestDto(BaseModel):
    method: PassThroughRequestDtoMethod
    path: Nullable[str]
    data: Optional[Data] = None
    request_format: OptionalNullable[RequestFormat] = UNSET
    override_base_url: Annotated[OptionalNullable[Dict[str, Any]], pydantic.Field(alias="overrideBaseUrl")] = UNSET
    headers: Optional[Headers] = None
    
    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["data", "request_format", "overrideBaseUrl", "headers"]
        nullable_fields = ["path", "request_format", "overrideBaseUrl"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields
                or (
                    k in optional_fields
                    and k in nullable_fields
                    and (
                        self.__pydantic_fields_set__.intersection({n})
                        or k in null_default_fields
                    )  # pylint: disable=no-member
                )
            ):
                m[k] = val

        return m
        

RequestFormatTypedDict = Union[Dict[str, Any], List[Dict[str, Any]]]


RequestFormat = Union[Dict[str, Any], List[Dict[str, Any]]]

