"""
This file is generated by the openapi-python-client tool via the generate_api_client.py script

It is a customized template from the openapi-python-client tool's default template:
https://github.com/openapi-generators/openapi-python-client/blob/861ef5622f10fc96d240dc9becb0edf94e61446c/openapi_python_client/templates/model.py.jinja

The main change is:
- Fix typing issues
"""

# flake8: noqa: C901

from typing import Any, Type, TypeVar, Union, cast

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

from ..types import UNSET, Unset

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


@_attrs_define
class CascadeEditSuggestionsRequest:
    """
    Attributes:
        old_label (int):
        new_label (int):
        max_neighbors (Union[Unset, int]):  Default: 50.
        max_validation_neighbors (Union[Unset, int]):  Default: 10.
        similarity_threshold (Union[None, Unset, float]):
        only_if_has_old_label (Union[Unset, bool]):  Default: True.
        exclude_if_new_label (Union[Unset, bool]):  Default: True.
        suggestion_cooldown_time (Union[Unset, float]):  Default: 86400.0.
        label_confirmation_cooldown_time (Union[Unset, float]):  Default: 604800.0.
    """

    old_label: int
    new_label: int
    max_neighbors: Union[Unset, int] = 50
    max_validation_neighbors: Union[Unset, int] = 10
    similarity_threshold: Union[None, Unset, float] = UNSET
    only_if_has_old_label: Union[Unset, bool] = True
    exclude_if_new_label: Union[Unset, bool] = True
    suggestion_cooldown_time: Union[Unset, float] = 86400.0
    label_confirmation_cooldown_time: Union[Unset, float] = 604800.0
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        old_label = self.old_label

        new_label = self.new_label

        max_neighbors = self.max_neighbors

        max_validation_neighbors = self.max_validation_neighbors

        similarity_threshold: Union[None, Unset, float]
        if isinstance(self.similarity_threshold, Unset):
            similarity_threshold = UNSET
        else:
            similarity_threshold = self.similarity_threshold

        only_if_has_old_label = self.only_if_has_old_label

        exclude_if_new_label = self.exclude_if_new_label

        suggestion_cooldown_time = self.suggestion_cooldown_time

        label_confirmation_cooldown_time = self.label_confirmation_cooldown_time

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update(
            {
                "old_label": old_label,
                "new_label": new_label,
            }
        )
        if max_neighbors is not UNSET:
            field_dict["max_neighbors"] = max_neighbors
        if max_validation_neighbors is not UNSET:
            field_dict["max_validation_neighbors"] = max_validation_neighbors
        if similarity_threshold is not UNSET:
            field_dict["similarity_threshold"] = similarity_threshold
        if only_if_has_old_label is not UNSET:
            field_dict["only_if_has_old_label"] = only_if_has_old_label
        if exclude_if_new_label is not UNSET:
            field_dict["exclude_if_new_label"] = exclude_if_new_label
        if suggestion_cooldown_time is not UNSET:
            field_dict["suggestion_cooldown_time"] = suggestion_cooldown_time
        if label_confirmation_cooldown_time is not UNSET:
            field_dict["label_confirmation_cooldown_time"] = label_confirmation_cooldown_time

        return field_dict

    @classmethod
    def from_dict(cls: Type[T], src_dict: dict[str, Any]) -> T:
        d = src_dict.copy()
        old_label = d.pop("old_label")

        new_label = d.pop("new_label")

        max_neighbors = d.pop("max_neighbors", UNSET)

        max_validation_neighbors = d.pop("max_validation_neighbors", UNSET)

        def _parse_similarity_threshold(data: object) -> Union[None, Unset, float]:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(Union[None, Unset, float], data)

        similarity_threshold = _parse_similarity_threshold(d.pop("similarity_threshold", UNSET))

        only_if_has_old_label = d.pop("only_if_has_old_label", UNSET)

        exclude_if_new_label = d.pop("exclude_if_new_label", UNSET)

        suggestion_cooldown_time = d.pop("suggestion_cooldown_time", UNSET)

        label_confirmation_cooldown_time = d.pop("label_confirmation_cooldown_time", UNSET)

        cascade_edit_suggestions_request = cls(
            old_label=old_label,
            new_label=new_label,
            max_neighbors=max_neighbors,
            max_validation_neighbors=max_validation_neighbors,
            similarity_threshold=similarity_threshold,
            only_if_has_old_label=only_if_has_old_label,
            exclude_if_new_label=exclude_if_new_label,
            suggestion_cooldown_time=suggestion_cooldown_time,
            label_confirmation_cooldown_time=label_confirmation_cooldown_time,
        )

        cascade_edit_suggestions_request.additional_properties = d
        return cascade_edit_suggestions_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
