from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator

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

from ..types import UNSET, Unset

from typing import cast
from typing import Literal, cast






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



@_attrs_define
class ServerCredentialsApiKeys:
    """ 
        Attributes:
            type_ (Literal['apikey']):
            apikeys (list[list[str]]):
     """

    type_: Literal['apikey']
    apikeys: list[list[str]]
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)





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

        apikeys = []
        for apikeys_item_data in self.apikeys:
            apikeys_item = []
            for apikeys_item_item_data in apikeys_item_data:
                apikeys_item_item: str
                apikeys_item_item = apikeys_item_item_data
                apikeys_item.append(apikeys_item_item)


            apikeys.append(apikeys_item)




        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({
            "type": type_,
            "apikeys": apikeys,
        })

        return field_dict



    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        type_ = cast(Literal['apikey'] , d.pop("type"))
        if type_ != 'apikey':
            raise ValueError(f"type must match const 'apikey', got '{type_}'")

        apikeys = []
        _apikeys = d.pop("apikeys")
        for apikeys_item_data in (_apikeys):
            apikeys_item = []
            _apikeys_item = apikeys_item_data
            for apikeys_item_item_data in (_apikeys_item):
                def _parse_apikeys_item_item(data: object) -> str:
                    return cast(str, data)

                apikeys_item_item = _parse_apikeys_item_item(apikeys_item_item_data)

                apikeys_item.append(apikeys_item_item)

            apikeys.append(apikeys_item)


        server_credentials_api_keys = cls(
            type_=type_,
            apikeys=apikeys,
        )


        server_credentials_api_keys.additional_properties = d
        return server_credentials_api_keys

    @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
