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

from __future__ import annotations
from .v2deploygitcommit import V2DeployGitCommit, V2DeployGitCommitTypedDict
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 V2DeployCreateDeploymentRequestBodyTypedDict(TypedDict):
    r"""Create a deployment from a pre-built Docker image"""

    project: str
    r"""Project slug"""
    app: str
    r"""App slug within the project"""
    branch: str
    r"""Git branch name"""
    environment_slug: str
    r"""Environment slug (e.g., \"production\", \"staging\")"""
    docker_image: str
    r"""Docker image reference to deploy"""
    keyspace_id: NotRequired[str]
    r"""Optional keyspace ID for authentication context"""
    git_commit: NotRequired[V2DeployGitCommitTypedDict]
    r"""Optional git commit information"""


class V2DeployCreateDeploymentRequestBody(BaseModel):
    r"""Create a deployment from a pre-built Docker image"""

    project: str
    r"""Project slug"""

    app: str
    r"""App slug within the project"""

    branch: str
    r"""Git branch name"""

    environment_slug: Annotated[str, pydantic.Field(alias="environmentSlug")]
    r"""Environment slug (e.g., \"production\", \"staging\")"""

    docker_image: Annotated[str, pydantic.Field(alias="dockerImage")]
    r"""Docker image reference to deploy"""

    keyspace_id: Annotated[Optional[str], pydantic.Field(alias="keyspaceId")] = None
    r"""Optional keyspace ID for authentication context"""

    git_commit: Annotated[
        Optional[V2DeployGitCommit], pydantic.Field(alias="gitCommit")
    ] = None
    r"""Optional git commit information"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["keyspaceId", "gitCommit"])
        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:
    V2DeployCreateDeploymentRequestBody.model_rebuild()
except NameError:
    pass
