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

from __future__ import annotations
from amds.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from amds.utils import FieldMetadata, PathParamMetadata, RequestMetadata
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class UploadFileRequestBodyTypedDict(TypedDict):
    content: NotRequired[str]
    format_: NotRequired[str]
    type: NotRequired[str]


class UploadFileRequestBody(BaseModel):
    content: Optional[str] = None

    format_: Annotated[Optional[str], pydantic.Field(alias="format")] = None

    type: Optional[str] = None


class UploadFileRequestTypedDict(TypedDict):
    server_name: str
    path: str
    request_body: NotRequired[UploadFileRequestBodyTypedDict]


class UploadFileRequest(BaseModel):
    server_name: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]

    path: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]

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


class UploadFileContentTypedDict(TypedDict):
    content: NotRequired[Nullable[Any]]
    created: NotRequired[str]
    format_: NotRequired[Nullable[Any]]
    last_modified: NotRequired[str]
    mimetype: NotRequired[str]
    name: NotRequired[str]
    path: NotRequired[str]
    server_path: NotRequired[str]
    size: NotRequired[float]
    type: NotRequired[str]
    writable: NotRequired[bool]


class UploadFileContent(BaseModel):
    content: OptionalNullable[Any] = UNSET

    created: Optional[str] = None

    format_: Annotated[OptionalNullable[Any], pydantic.Field(alias="format")] = UNSET

    last_modified: Optional[str] = None

    mimetype: Optional[str] = None

    name: Optional[str] = None

    path: Optional[str] = None

    server_path: Annotated[Optional[str], pydantic.Field(alias="serverPath")] = None

    size: Optional[float] = None

    type: Optional[str] = None

    writable: Optional[bool] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "content",
            "created",
            "format",
            "last_modified",
            "mimetype",
            "name",
            "path",
            "serverPath",
            "size",
            "type",
            "writable",
        ]
        nullable_fields = ["content", "format"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class UploadFileResponseBodyTypedDict(TypedDict):
    r"""Upload File"""

    content: NotRequired[UploadFileContentTypedDict]
    status: NotRequired[str]


class UploadFileResponseBody(BaseModel):
    r"""Upload File"""

    content: Optional[UploadFileContent] = None

    status: Optional[str] = None


class UploadFileResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: UploadFileResponseBodyTypedDict


class UploadFileResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: UploadFileResponseBody
