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

from __future__ import annotations
from mesa_sdk.types import BaseModel, UNSET_SENTINEL, UnrecognizedStr
from mesa_sdk.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class GetByOrgByRepoDiffRequestTypedDict(TypedDict):
    org: str
    repo: str
    base: str
    head: str


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

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

    base: Annotated[
        str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True))
    ]

    head: Annotated[
        str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True))
    ]


class GetByOrgByRepoDiffInternalServerErrorErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class GetByOrgByRepoDiffInternalServerErrorError(BaseModel):
    code: str

    message: str

    details: Optional[Dict[str, Any]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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 GetByOrgByRepoDiffConflictErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class GetByOrgByRepoDiffConflictError(BaseModel):
    code: str

    message: str

    details: Optional[Dict[str, Any]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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 GetByOrgByRepoDiffNotAcceptableErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class GetByOrgByRepoDiffNotAcceptableError(BaseModel):
    code: str

    message: str

    details: Optional[Dict[str, Any]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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 GetByOrgByRepoDiffNotFoundErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class GetByOrgByRepoDiffNotFoundError(BaseModel):
    code: str

    message: str

    details: Optional[Dict[str, Any]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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 GetByOrgByRepoDiffForbiddenErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class GetByOrgByRepoDiffForbiddenError(BaseModel):
    code: str

    message: str

    details: Optional[Dict[str, Any]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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 GetByOrgByRepoDiffUnauthorizedErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class GetByOrgByRepoDiffUnauthorizedError(BaseModel):
    code: str

    message: str

    details: Optional[Dict[str, Any]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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 GetByOrgByRepoDiffBadRequestErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class GetByOrgByRepoDiffBadRequestError(BaseModel):
    code: str

    message: str

    details: Optional[Dict[str, Any]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["details"])
        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 GetByOrgByRepoDiffStatsTypedDict(TypedDict):
    files: float
    additions: float
    deletions: float
    changes: float


class GetByOrgByRepoDiffStats(BaseModel):
    files: float

    additions: float

    deletions: float

    changes: float


FileStatus = Union[
    Literal[
        "A",
        "M",
        "D",
        "R",
        "C",
        "T",
    ],
    UnrecognizedStr,
]


class GetByOrgByRepoDiffFileTypedDict(TypedDict):
    path: str
    status: FileStatus
    old_path: NotRequired[str]
    bytes_: NotRequired[float]
    is_eof: NotRequired[bool]
    raw: NotRequired[str]


class GetByOrgByRepoDiffFile(BaseModel):
    path: str

    status: FileStatus

    old_path: Optional[str] = None

    bytes_: Annotated[Optional[float], pydantic.Field(alias="bytes")] = None

    is_eof: Optional[bool] = None

    raw: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["old_path", "bytes", "is_eof", "raw"])
        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


FilteredFileStatus = Union[
    Literal[
        "A",
        "M",
        "D",
        "R",
        "C",
        "T",
    ],
    UnrecognizedStr,
]


class FilteredFileTypedDict(TypedDict):
    path: str
    status: FilteredFileStatus
    old_path: NotRequired[str]
    bytes_: NotRequired[float]
    is_eof: NotRequired[bool]


class FilteredFile(BaseModel):
    path: str

    status: FilteredFileStatus

    old_path: Optional[str] = None

    bytes_: Annotated[Optional[float], pydantic.Field(alias="bytes")] = None

    is_eof: Optional[bool] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["old_path", "bytes", "is_eof"])
        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 GetByOrgByRepoDiffResponseBodyTypedDict(TypedDict):
    r"""Diff response"""

    base: str
    head: str
    stats: GetByOrgByRepoDiffStatsTypedDict
    files: List[GetByOrgByRepoDiffFileTypedDict]
    filtered_files: List[FilteredFileTypedDict]


class GetByOrgByRepoDiffResponseBody(BaseModel):
    r"""Diff response"""

    base: str

    head: str

    stats: GetByOrgByRepoDiffStats

    files: List[GetByOrgByRepoDiffFile]

    filtered_files: List[FilteredFile]


GetByOrgByRepoDiffResponseTypedDict = TypeAliasType(
    "GetByOrgByRepoDiffResponseTypedDict",
    Union[GetByOrgByRepoDiffResponseBodyTypedDict, str],
)


GetByOrgByRepoDiffResponse = TypeAliasType(
    "GetByOrgByRepoDiffResponse", Union[GetByOrgByRepoDiffResponseBody, str]
)
