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="LegacytypesUsageLimits")


@_attrs_define
class LegacytypesUsageLimits:
    """
    Attributes:
        base_storage (int | Unset):
        dashboard_users (int | Unset):
        max_users (int | Unset):
        usage (int | Unset):
    """

    base_storage: int | Unset = UNSET
    dashboard_users: int | Unset = UNSET
    max_users: int | Unset = UNSET
    usage: int | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        dashboard_users = self.dashboard_users

        max_users = self.max_users

        usage = self.usage

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if base_storage is not UNSET:
            field_dict["base_storage"] = base_storage
        if dashboard_users is not UNSET:
            field_dict["dashboard_users"] = dashboard_users
        if max_users is not UNSET:
            field_dict["max_users"] = max_users
        if usage is not UNSET:
            field_dict["usage"] = usage

        return field_dict

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

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

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

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

        legacytypes_usage_limits = cls(
            base_storage=base_storage,
            dashboard_users=dashboard_users,
            max_users=max_users,
            usage=usage,
        )

        legacytypes_usage_limits.additional_properties = d
        return legacytypes_usage_limits

    @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
