add openapi-python-client generator + client
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from .. import types
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="PolyTicketUser")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class PolyTicketUser:
|
||||
"""
|
||||
Attributes:
|
||||
id (int):
|
||||
username (str):
|
||||
email (str):
|
||||
first_name (Union[Unset, str]):
|
||||
last_name (Union[Unset, str]):
|
||||
personal_unit (Union[None, Unset, int]):
|
||||
is_active (Union[Unset, bool]):
|
||||
is_deleted (Union[Unset, bool]):
|
||||
"""
|
||||
|
||||
id: int
|
||||
username: str
|
||||
email: str
|
||||
first_name: Union[Unset, str] = UNSET
|
||||
last_name: Union[Unset, str] = UNSET
|
||||
personal_unit: Union[None, Unset, int] = UNSET
|
||||
is_active: Union[Unset, bool] = UNSET
|
||||
is_deleted: Union[Unset, bool] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
id = self.id
|
||||
|
||||
username = self.username
|
||||
|
||||
email = self.email
|
||||
|
||||
first_name = self.first_name
|
||||
|
||||
last_name = self.last_name
|
||||
|
||||
personal_unit: Union[None, Unset, int]
|
||||
if isinstance(self.personal_unit, Unset):
|
||||
personal_unit = UNSET
|
||||
else:
|
||||
personal_unit = self.personal_unit
|
||||
|
||||
is_active = self.is_active
|
||||
|
||||
is_deleted = self.is_deleted
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"id": id,
|
||||
"username": username,
|
||||
"email": email,
|
||||
}
|
||||
)
|
||||
if first_name is not UNSET:
|
||||
field_dict["first_name"] = first_name
|
||||
if last_name is not UNSET:
|
||||
field_dict["last_name"] = last_name
|
||||
if personal_unit is not UNSET:
|
||||
field_dict["personal_unit"] = personal_unit
|
||||
if is_active is not UNSET:
|
||||
field_dict["is_active"] = is_active
|
||||
if is_deleted is not UNSET:
|
||||
field_dict["is_deleted"] = is_deleted
|
||||
|
||||
return field_dict
|
||||
|
||||
def to_multipart(self) -> types.RequestFiles:
|
||||
files: types.RequestFiles = []
|
||||
|
||||
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
||||
|
||||
files.append(("username", (None, str(self.username).encode(), "text/plain")))
|
||||
|
||||
files.append(("email", (None, str(self.email).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.first_name, Unset):
|
||||
files.append(("first_name", (None, str(self.first_name).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.last_name, Unset):
|
||||
files.append(("last_name", (None, str(self.last_name).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.personal_unit, Unset):
|
||||
if isinstance(self.personal_unit, int):
|
||||
files.append(("personal_unit", (None, str(self.personal_unit).encode(), "text/plain")))
|
||||
else:
|
||||
files.append(("personal_unit", (None, str(self.personal_unit).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.is_active, Unset):
|
||||
files.append(("is_active", (None, str(self.is_active).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.is_deleted, Unset):
|
||||
files.append(("is_deleted", (None, str(self.is_deleted).encode(), "text/plain")))
|
||||
|
||||
for prop_name, prop in self.additional_properties.items():
|
||||
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
||||
|
||||
return files
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
||||
d = dict(src_dict)
|
||||
id = d.pop("id")
|
||||
|
||||
username = d.pop("username")
|
||||
|
||||
email = d.pop("email")
|
||||
|
||||
first_name = d.pop("first_name", UNSET)
|
||||
|
||||
last_name = d.pop("last_name", UNSET)
|
||||
|
||||
def _parse_personal_unit(data: object) -> Union[None, Unset, int]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
return cast(Union[None, Unset, int], data)
|
||||
|
||||
personal_unit = _parse_personal_unit(d.pop("personal_unit", UNSET))
|
||||
|
||||
is_active = d.pop("is_active", UNSET)
|
||||
|
||||
is_deleted = d.pop("is_deleted", UNSET)
|
||||
|
||||
poly_ticket_user = cls(
|
||||
id=id,
|
||||
username=username,
|
||||
email=email,
|
||||
first_name=first_name,
|
||||
last_name=last_name,
|
||||
personal_unit=personal_unit,
|
||||
is_active=is_active,
|
||||
is_deleted=is_deleted,
|
||||
)
|
||||
|
||||
poly_ticket_user.additional_properties = d
|
||||
return poly_ticket_user
|
||||
|
||||
@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
|
||||
Reference in New Issue
Block a user