from __future__ import annotations

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

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

from ..types import UNSET, Unset

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


@_attrs_define
class TypesAutomationLog:
    """
    Attributes:
        execution_time (float | Unset):
        message (str | Unset):
        timestamp (str | Unset):
        traceback (str | Unset):
        type_ (str | Unset):
    """

    execution_time: float | Unset = UNSET
    message: str | Unset = UNSET
    timestamp: str | Unset = UNSET
    traceback: str | Unset = UNSET
    type_: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        message = self.message

        timestamp = self.timestamp

        traceback = self.traceback

        type_ = self.type_

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if execution_time is not UNSET:
            field_dict["execution_time"] = execution_time
        if message is not UNSET:
            field_dict["message"] = message
        if timestamp is not UNSET:
            field_dict["timestamp"] = timestamp
        if traceback is not UNSET:
            field_dict["traceback"] = traceback
        if type_ is not UNSET:
            field_dict["type"] = type_

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        execution_time = d.pop("execution_time", UNSET)

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

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

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

        type_ = d.pop("type", UNSET)

        types_automation_log = cls(
            execution_time=execution_time,
            message=message,
            timestamp=timestamp,
            traceback=traceback,
            type_=type_,
        )

        types_automation_log.additional_properties = d
        return types_automation_log

    @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
