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

from __future__ import annotations
from .diffenvironmentrequestdto import (
    DiffEnvironmentRequestDto,
    DiffEnvironmentRequestDtoTypedDict,
)
from .diffenvironmentresponsedto import (
    DiffEnvironmentResponseDto,
    DiffEnvironmentResponseDtoTypedDict,
)
from novu_py.types import BaseModel, UNSET_SENTINEL
from novu_py.utils import (
    FieldMetadata,
    HeaderMetadata,
    PathParamMetadata,
    RequestMetadata,
)
import pydantic
from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class EnvironmentsControllerDiffEnvironmentRequestTypedDict(TypedDict):
    target_environment_id: str
    r"""Target environment ID (MongoDB ObjectId) to compare against"""
    diff_environment_request_dto: DiffEnvironmentRequestDtoTypedDict
    r"""Diff request configuration"""
    idempotency_key: NotRequired[str]
    r"""A header for idempotency purposes"""


class EnvironmentsControllerDiffEnvironmentRequest(BaseModel):
    target_environment_id: Annotated[
        str,
        pydantic.Field(alias="targetEnvironmentId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""Target environment ID (MongoDB ObjectId) to compare against"""

    diff_environment_request_dto: Annotated[
        DiffEnvironmentRequestDto,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]
    r"""Diff request configuration"""

    idempotency_key: Annotated[
        Optional[str],
        pydantic.Field(alias="idempotency-key"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None
    r"""A header for idempotency purposes"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["idempotency-key"])
        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 EnvironmentsControllerDiffEnvironmentResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: DiffEnvironmentResponseDtoTypedDict


class EnvironmentsControllerDiffEnvironmentResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: DiffEnvironmentResponseDto
