from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

from ..types import UNSET, Unset
from typing import cast

if TYPE_CHECKING:
  from ..models.update_trigger_request_out_schema_type_0 import UpdateTriggerRequestOutSchemaType0
  from ..models.update_trigger_request_param_schema_type_0 import UpdateTriggerRequestParamSchemaType0





T = TypeVar("T", bound="UpdateTriggerRequest")



@_attrs_define
class UpdateTriggerRequest:
    """ Request DTO for updating a trigger

        Attributes:
            out_schema (None | UpdateTriggerRequestOutSchemaType0): Output schema
            param_schema (None | UpdateTriggerRequestParamSchemaType0): Parameter schema
            description (None | str | Unset): Trigger description Example: Updated webhook trigger description.
            enabled (bool | None | Unset): Whether the trigger is enabled Example: True.
            label (None | str | Unset): Human-readable label Example: Webhook Trigger (Updated).
     """

    out_schema: None | UpdateTriggerRequestOutSchemaType0
    param_schema: None | UpdateTriggerRequestParamSchemaType0
    description: None | str | Unset = UNSET
    enabled: bool | None | Unset = UNSET
    label: None | str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)





    def to_dict(self) -> dict[str, Any]:
        from ..models.update_trigger_request_out_schema_type_0 import UpdateTriggerRequestOutSchemaType0
        from ..models.update_trigger_request_param_schema_type_0 import UpdateTriggerRequestParamSchemaType0
        out_schema: dict[str, Any] | None
        if isinstance(self.out_schema, UpdateTriggerRequestOutSchemaType0):
            out_schema = self.out_schema.to_dict()
        else:
            out_schema = self.out_schema

        param_schema: dict[str, Any] | None
        if isinstance(self.param_schema, UpdateTriggerRequestParamSchemaType0):
            param_schema = self.param_schema.to_dict()
        else:
            param_schema = self.param_schema

        description: None | str | Unset
        if isinstance(self.description, Unset):
            description = UNSET
        else:
            description = self.description

        enabled: bool | None | Unset
        if isinstance(self.enabled, Unset):
            enabled = UNSET
        else:
            enabled = self.enabled

        label: None | str | Unset
        if isinstance(self.label, Unset):
            label = UNSET
        else:
            label = self.label


        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({
            "out_schema": out_schema,
            "param_schema": param_schema,
        })
        if description is not UNSET:
            field_dict["description"] = description
        if enabled is not UNSET:
            field_dict["enabled"] = enabled
        if label is not UNSET:
            field_dict["label"] = label

        return field_dict



    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.update_trigger_request_out_schema_type_0 import UpdateTriggerRequestOutSchemaType0
        from ..models.update_trigger_request_param_schema_type_0 import UpdateTriggerRequestParamSchemaType0
        d = dict(src_dict)
        def _parse_out_schema(data: object) -> None | UpdateTriggerRequestOutSchemaType0:
            if data is None:
                return data
            try:
                if not isinstance(data, dict):
                    raise TypeError()
                out_schema_type_0 = UpdateTriggerRequestOutSchemaType0.from_dict(data)



                return out_schema_type_0
            except (TypeError, ValueError, AttributeError, KeyError):
                pass
            return cast(None | UpdateTriggerRequestOutSchemaType0, data)

        out_schema = _parse_out_schema(d.pop("out_schema"))


        def _parse_param_schema(data: object) -> None | UpdateTriggerRequestParamSchemaType0:
            if data is None:
                return data
            try:
                if not isinstance(data, dict):
                    raise TypeError()
                param_schema_type_0 = UpdateTriggerRequestParamSchemaType0.from_dict(data)



                return param_schema_type_0
            except (TypeError, ValueError, AttributeError, KeyError):
                pass
            return cast(None | UpdateTriggerRequestParamSchemaType0, data)

        param_schema = _parse_param_schema(d.pop("param_schema"))


        def _parse_description(data: object) -> None | str | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(None | str | Unset, data)

        description = _parse_description(d.pop("description", UNSET))


        def _parse_enabled(data: object) -> bool | None | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(bool | None | Unset, data)

        enabled = _parse_enabled(d.pop("enabled", UNSET))


        def _parse_label(data: object) -> None | str | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(None | str | Unset, data)

        label = _parse_label(d.pop("label", UNSET))


        update_trigger_request = cls(
            out_schema=out_schema,
            param_schema=param_schema,
            description=description,
            enabled=enabled,
            label=label,
        )


        update_trigger_request.additional_properties = d
        return update_trigger_request

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
