cognee/cognee-mcp/cognee-api-client/cognee_api_client/models/user_read.py
2025-10-09 17:48:48 +01:00

127 lines
3.5 KiB
Python

from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
T = TypeVar("T", bound="UserRead")
@_attrs_define
class UserRead:
"""
Attributes:
id (UUID):
email (str):
is_active (Union[Unset, bool]): Default: True.
is_superuser (Union[Unset, bool]): Default: False.
is_verified (Union[Unset, bool]): Default: False.
tenant_id (Union[None, UUID, Unset]):
"""
id: UUID
email: str
is_active: Union[Unset, bool] = True
is_superuser: Union[Unset, bool] = False
is_verified: Union[Unset, bool] = False
tenant_id: Union[None, UUID, Unset] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
id = str(self.id)
email = self.email
is_active = self.is_active
is_superuser = self.is_superuser
is_verified = self.is_verified
tenant_id: Union[None, Unset, str]
if isinstance(self.tenant_id, Unset):
tenant_id = UNSET
elif isinstance(self.tenant_id, UUID):
tenant_id = str(self.tenant_id)
else:
tenant_id = self.tenant_id
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"id": id,
"email": email,
}
)
if is_active is not UNSET:
field_dict["is_active"] = is_active
if is_superuser is not UNSET:
field_dict["is_superuser"] = is_superuser
if is_verified is not UNSET:
field_dict["is_verified"] = is_verified
if tenant_id is not UNSET:
field_dict["tenant_id"] = tenant_id
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
id = UUID(d.pop("id"))
email = d.pop("email")
is_active = d.pop("is_active", UNSET)
is_superuser = d.pop("is_superuser", UNSET)
is_verified = d.pop("is_verified", UNSET)
def _parse_tenant_id(data: object) -> Union[None, UUID, Unset]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
tenant_id_type_0 = UUID(data)
return tenant_id_type_0
except: # noqa: E722
pass
return cast(Union[None, UUID, Unset], data)
tenant_id = _parse_tenant_id(d.pop("tenant_id", UNSET))
user_read = cls(
id=id,
email=email,
is_active=is_active,
is_superuser=is_superuser,
is_verified=is_verified,
tenant_id=tenant_id,
)
user_read.additional_properties = d
return user_read
@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