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

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


EventRequest = Literal["push",]


class PostByOrgByRepoWebhooksRequestBodyTypedDict(TypedDict):
    url: str
    events: NotRequired[List[EventRequest]]
    branches: NotRequired[List[str]]
    globs: NotRequired[List[str]]
    secret: NotRequired[str]


class PostByOrgByRepoWebhooksRequestBody(BaseModel):
    url: str

    events: Optional[List[EventRequest]] = None

    branches: Optional[List[str]] = None

    globs: Optional[List[str]] = None

    secret: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["events", "branches", "globs", "secret"])
        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 PostByOrgByRepoWebhooksRequestTypedDict(TypedDict):
    org: str
    repo: str
    body: NotRequired[PostByOrgByRepoWebhooksRequestBodyTypedDict]


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

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

    body: Annotated[
        Optional[PostByOrgByRepoWebhooksRequestBody],
        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 PostByOrgByRepoWebhooksInternalServerErrorErrorTypedDict(TypedDict):
    code: str
    message: str
    details: NotRequired[Dict[str, Any]]


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


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


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


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


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


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


class PostByOrgByRepoWebhooksBadRequestError(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


PostByOrgByRepoWebhooksEventResponse = Literal["push",]


class PostByOrgByRepoWebhooksResponseTypedDict(TypedDict):
    r"""Webhook created"""

    id: str
    url: str
    events: List[PostByOrgByRepoWebhooksEventResponse]
    branches: Nullable[List[str]]
    globs: Nullable[List[str]]
    created_at: str
    updated_at: str
    secret: str


class PostByOrgByRepoWebhooksResponse(BaseModel):
    r"""Webhook created"""

    id: str

    url: str

    events: List[PostByOrgByRepoWebhooksEventResponse]

    branches: Nullable[List[str]]

    globs: Nullable[List[str]]

    created_at: str

    updated_at: str

    secret: str

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m
