from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar

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

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.btm_suppression_state_1924 import BTMSuppressionState1924


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


@_attrs_define
class BTInstanceControlNode750:
    """
    Attributes:
        bt_type (str | Unset): Type of JSON object.
        import_microversion (str | Unset): Microversion that resulted from the import.
        node_id (str | Unset):
        parent_suppressed (bool | Unset):
        suppressed (bool | Unset):
        suppressed_field_index (int | Unset):
        suppression_configured (bool | Unset): `true` if the suppression is configured in the Part Studio.
        suppression_state (BTMSuppressionState1924 | Unset):
        suppression_state_field_index (int | Unset):
    """

    bt_type: str | Unset = UNSET
    import_microversion: str | Unset = UNSET
    node_id: str | Unset = UNSET
    parent_suppressed: bool | Unset = UNSET
    suppressed: bool | Unset = UNSET
    suppressed_field_index: int | Unset = UNSET
    suppression_configured: bool | Unset = UNSET
    suppression_state: BTMSuppressionState1924 | Unset = UNSET
    suppression_state_field_index: int | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        import_microversion = self.import_microversion

        node_id = self.node_id

        parent_suppressed = self.parent_suppressed

        suppressed = self.suppressed

        suppressed_field_index = self.suppressed_field_index

        suppression_configured = self.suppression_configured

        suppression_state: dict[str, Any] | Unset = UNSET
        if not isinstance(self.suppression_state, Unset):
            suppression_state = self.suppression_state.to_dict()

        suppression_state_field_index = self.suppression_state_field_index

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if bt_type is not UNSET:
            field_dict["btType"] = bt_type
        if import_microversion is not UNSET:
            field_dict["importMicroversion"] = import_microversion
        if node_id is not UNSET:
            field_dict["nodeId"] = node_id
        if parent_suppressed is not UNSET:
            field_dict["parentSuppressed"] = parent_suppressed
        if suppressed is not UNSET:
            field_dict["suppressed"] = suppressed
        if suppressed_field_index is not UNSET:
            field_dict["suppressedFieldIndex"] = suppressed_field_index
        if suppression_configured is not UNSET:
            field_dict["suppressionConfigured"] = suppression_configured
        if suppression_state is not UNSET:
            field_dict["suppressionState"] = suppression_state
        if suppression_state_field_index is not UNSET:
            field_dict["suppressionStateFieldIndex"] = suppression_state_field_index

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.btm_suppression_state_1924 import BTMSuppressionState1924

        d = dict(src_dict)
        bt_type = d.pop("btType", UNSET)

        import_microversion = d.pop("importMicroversion", UNSET)

        node_id = d.pop("nodeId", UNSET)

        parent_suppressed = d.pop("parentSuppressed", UNSET)

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

        suppressed_field_index = d.pop("suppressedFieldIndex", UNSET)

        suppression_configured = d.pop("suppressionConfigured", UNSET)

        _suppression_state = d.pop("suppressionState", UNSET)
        suppression_state: BTMSuppressionState1924 | Unset
        if isinstance(_suppression_state, Unset):
            suppression_state = UNSET
        else:
            suppression_state = BTMSuppressionState1924.from_dict(_suppression_state)

        suppression_state_field_index = d.pop("suppressionStateFieldIndex", UNSET)

        bt_instance_control_node_750 = cls(
            bt_type=bt_type,
            import_microversion=import_microversion,
            node_id=node_id,
            parent_suppressed=parent_suppressed,
            suppressed=suppressed,
            suppressed_field_index=suppressed_field_index,
            suppression_configured=suppression_configured,
            suppression_state=suppression_state,
            suppression_state_field_index=suppression_state_field_index,
        )

        bt_instance_control_node_750.additional_properties = d
        return bt_instance_control_node_750

    @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
