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

from __future__ import annotations
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
from unkey.py.types import BaseModel, UNSET_SENTINEL


class V2DeployGitCommitTypedDict(TypedDict):
    r"""Optional git commit information"""

    commit_sha: NotRequired[str]
    r"""Git commit SHA"""
    commit_message: NotRequired[str]
    r"""Git commit message"""
    author_handle: NotRequired[str]
    r"""Git author handle/username"""
    author_avatar_url: NotRequired[str]
    r"""Git author avatar URL"""
    timestamp: NotRequired[int]
    r"""Commit timestamp in milliseconds"""


class V2DeployGitCommit(BaseModel):
    r"""Optional git commit information"""

    commit_sha: Annotated[Optional[str], pydantic.Field(alias="commitSha")] = None
    r"""Git commit SHA"""

    commit_message: Annotated[Optional[str], pydantic.Field(alias="commitMessage")] = (
        None
    )
    r"""Git commit message"""

    author_handle: Annotated[Optional[str], pydantic.Field(alias="authorHandle")] = None
    r"""Git author handle/username"""

    author_avatar_url: Annotated[
        Optional[str], pydantic.Field(alias="authorAvatarUrl")
    ] = None
    r"""Git author avatar URL"""

    timestamp: Optional[int] = None
    r"""Commit timestamp in milliseconds"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "commitSha",
                "commitMessage",
                "authorHandle",
                "authorAvatarUrl",
                "timestamp",
            ]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    V2DeployGitCommit.model_rebuild()
except NameError:
    pass
