"""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


Scope = Literal[
    "git:read",
    "git:write",
    "repo:read",
    "repo:create",
    "repo:delete",
    "webhook:read",
    "webhook:write",
    "admin",
]


class PostByOrgAPIKeysRequestBodyTypedDict(TypedDict):
    name: NotRequired[str]
    scopes: NotRequired[List[Scope]]


class PostByOrgAPIKeysRequestBody(BaseModel):
    name: Optional[str] = None

    scopes: Optional[List[Scope]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["name", "scopes"])
        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 PostByOrgAPIKeysRequestTypedDict(TypedDict):
    org: str
    body: NotRequired[PostByOrgAPIKeysRequestBodyTypedDict]


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

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


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


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


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


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


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


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


class PostByOrgAPIKeysBadRequestError(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 PostByOrgAPIKeysResponseTypedDict(TypedDict):
    r"""API key created"""

    id: str
    key: str
    name: Nullable[str]
    scopes: List[str]
    created_at: str


class PostByOrgAPIKeysResponse(BaseModel):
    r"""API key created"""

    id: str

    key: str

    name: Nullable[str]

    scopes: List[str]

    created_at: 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
