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_create_initial_context_response_raw import (
        PkgRoutesMiscCreateInitialContextResponseRaw,
    )


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


@_attrs_define
class PkgRoutesMiscCreateInitialContextResponse:
    """
    Attributes:
        context (str | Unset):
        raw (PkgRoutesMiscCreateInitialContextResponseRaw | Unset):
    """

    context: str | Unset = UNSET
    raw: PkgRoutesMiscCreateInitialContextResponseRaw | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

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

        return field_dict

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

        d = dict(src_dict)
        context = d.pop("context", UNSET)

        _raw = d.pop("raw", UNSET)
        raw: PkgRoutesMiscCreateInitialContextResponseRaw | Unset
        if isinstance(_raw, Unset):
            raw = UNSET
        else:
            raw = PkgRoutesMiscCreateInitialContextResponseRaw.from_dict(_raw)

        pkg_routes_misc_create_initial_context_response = cls(
            context=context,
            raw=raw,
        )

        pkg_routes_misc_create_initial_context_response.additional_properties = d
        return pkg_routes_misc_create_initial_context_response

    @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
