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

from __future__ import annotations
from .resourcetopublishdto import ResourceToPublishDto, ResourceToPublishDtoTypedDict
from novu_py.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class PublishEnvironmentRequestDtoTypedDict(TypedDict):
    source_environment_id: NotRequired[str]
    r"""Source environment ID to sync from. Defaults to the Development environment if not provided."""
    dry_run: NotRequired[bool]
    r"""Perform a dry run without making actual changes"""
    resources: NotRequired[List[ResourceToPublishDtoTypedDict]]
    r"""Array of specific resources to publish. If not provided, all resources will be published."""


class PublishEnvironmentRequestDto(BaseModel):
    source_environment_id: Annotated[
        Optional[str], pydantic.Field(alias="sourceEnvironmentId")
    ] = None
    r"""Source environment ID to sync from. Defaults to the Development environment if not provided."""

    dry_run: Annotated[Optional[bool], pydantic.Field(alias="dryRun")] = False
    r"""Perform a dry run without making actual changes"""

    resources: Optional[List[ResourceToPublishDto]] = None
    r"""Array of specific resources to publish. If not provided, all resources will be published."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["sourceEnvironmentId", "dryRun", "resources"])
        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


try:
    PublishEnvironmentRequestDto.model_rebuild()
except NameError:
    pass
