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

from __future__ import annotations
from mesa_sdk.types import BaseModel, UNSET_SENTINEL
from mesa_sdk.utils import (
    FieldMetadata,
    PathParamMetadata,
    RequestMetadata,
    validate_const,
)
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class PostByOrgByRepoCommitsAuthorTypedDict(TypedDict):
    name: str
    email: str
    date_: NotRequired[str]


class PostByOrgByRepoCommitsAuthor(BaseModel):
    name: str

    email: str

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["date"])
        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 FileDeleteTypedDict(TypedDict):
    path: str
    action: Literal["delete"]


class FileDelete(BaseModel):
    path: str

    action: Annotated[
        Annotated[Literal["delete"], AfterValidator(validate_const("delete"))],
        pydantic.Field(alias="action"),
    ] = "delete"


Encoding = Literal[
    "utf-8",
    "base64",
]


class FileUpsertTypedDict(TypedDict):
    path: str
    content: str
    encoding: NotRequired[Encoding]
    action: Literal["upsert"]


class FileUpsert(BaseModel):
    path: str

    content: str

    encoding: Optional[Encoding] = "utf-8"

    action: Annotated[
        Annotated[
            Optional[Literal["upsert"]], AfterValidator(validate_const("upsert"))
        ],
        pydantic.Field(alias="action"),
    ] = "upsert"

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


FileTypedDict = TypeAliasType(
    "FileTypedDict", Union[FileDeleteTypedDict, FileUpsertTypedDict]
)


File = TypeAliasType("File", Union[FileDelete, FileUpsert])


class PostByOrgByRepoCommitsRequestBodyTypedDict(TypedDict):
    branch: str
    message: str
    author: PostByOrgByRepoCommitsAuthorTypedDict
    files: List[FileTypedDict]
    base_sha: NotRequired[str]


class PostByOrgByRepoCommitsRequestBody(BaseModel):
    branch: str

    message: str

    author: PostByOrgByRepoCommitsAuthor

    files: List[File]

    base_sha: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["base_sha"])
        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 PostByOrgByRepoCommitsRequestTypedDict(TypedDict):
    org: str
    repo: str
    body: NotRequired[PostByOrgByRepoCommitsRequestBodyTypedDict]


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

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

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

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


class PostByOrgByRepoCommitsInternalServerErrorError(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 PostByOrgByRepoCommitsConflictErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class PostByOrgByRepoCommitsConflictError(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 PostByOrgByRepoCommitsNotAcceptableErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class PostByOrgByRepoCommitsNotAcceptableError(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 PostByOrgByRepoCommitsNotFoundErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class PostByOrgByRepoCommitsNotFoundError(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 PostByOrgByRepoCommitsForbiddenErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class PostByOrgByRepoCommitsForbiddenError(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 PostByOrgByRepoCommitsUnauthorizedErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class PostByOrgByRepoCommitsUnauthorizedError(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 PostByOrgByRepoCommitsBadRequestErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


class PostByOrgByRepoCommitsBadRequestError(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 PostByOrgByRepoCommitsResponseTypedDict(TypedDict):
    r"""Commit created"""

    sha: str
    branch: str
    message: str


class PostByOrgByRepoCommitsResponse(BaseModel):
    r"""Commit created"""

    sha: str

    branch: str

    message: str
