from typing import Any, Dict, Type, TypeVar, Union

import attr

from ..types import UNSET, Unset

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


try:
    from ..models import details
except ImportError:
    import sys

    details = sys.modules[__package__ + "details"]


@attr.s(auto_attribs=True)
class ClientCertificateUserDetails(details.Details):
    """ """

    thumbprint: "Union[Unset, str]" = UNSET
    common_name: "Union[Unset, str]" = UNSET
    disabled: "Union[Unset, bool]" = UNSET

    def to_dict(self) -> Dict[str, Any]:
        thumbprint = self.thumbprint
        common_name = self.common_name
        disabled = self.disabled

        field_dict: Dict[str, Any] = {}
        _Details_dict = super().to_dict()
        field_dict.update(_Details_dict)
        field_dict.update({})
        if thumbprint is not UNSET:
            field_dict["thumbprint"] = thumbprint
        if common_name is not UNSET:
            field_dict["commonName"] = common_name
        if disabled is not UNSET:
            field_dict["disabled"] = disabled

        return field_dict

    @classmethod
    def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:

        d = src_dict.copy()

        _Details_kwargs = super().from_dict(src_dict=d).to_dict()
        _Details_kwargs.pop("$type")

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

        common_name = d.pop("commonName", UNSET)

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

        client_certificate_user_details = cls(
            thumbprint=thumbprint,
            common_name=common_name,
            disabled=disabled,
            **_Details_kwargs,
        )

        return client_certificate_user_details
