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.pkg_routes_misc_change import PkgRoutesMiscChange


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


@_attrs_define
class PkgRoutesMiscChangeLogRequest:
    """
    Attributes:
        changes (list[PkgRoutesMiscChange] | Unset):
        release_date (str | Unset):
        version (str | Unset):
    """

    changes: list[PkgRoutesMiscChange] | Unset = UNSET
    release_date: str | Unset = UNSET
    version: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        changes: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.changes, Unset):
            changes = []
            for changes_item_data in self.changes:
                changes_item = changes_item_data.to_dict()
                changes.append(changes_item)

        release_date = self.release_date

        version = self.version

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if changes is not UNSET:
            field_dict["changes"] = changes
        if release_date is not UNSET:
            field_dict["release_date"] = release_date
        if version is not UNSET:
            field_dict["version"] = version

        return field_dict

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

        d = dict(src_dict)
        _changes = d.pop("changes", UNSET)
        changes: list[PkgRoutesMiscChange] | Unset = UNSET
        if _changes is not UNSET:
            changes = []
            for changes_item_data in _changes:
                changes_item = PkgRoutesMiscChange.from_dict(changes_item_data)

                changes.append(changes_item)

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

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

        pkg_routes_misc_change_log_request = cls(
            changes=changes,
            release_date=release_date,
            version=version,
        )

        pkg_routes_misc_change_log_request.additional_properties = d
        return pkg_routes_misc_change_log_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
