add openapi-python-client generator + client
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
from .. import types
|
||||
from ..models.unit_membership_role_enum import UnitMembershipRoleEnum
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="UnitMembership")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UnitMembership:
|
||||
"""Serializer for UnitMembership model
|
||||
|
||||
Attributes:
|
||||
id (int):
|
||||
user (int):
|
||||
unit (int):
|
||||
user_email (str):
|
||||
role (Union[Unset, UnitMembershipRoleEnum]): * `owner` - Owner
|
||||
* `member` - Member
|
||||
"""
|
||||
|
||||
id: int
|
||||
user: int
|
||||
unit: int
|
||||
user_email: str
|
||||
role: Union[Unset, UnitMembershipRoleEnum] = UNSET
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
id = self.id
|
||||
|
||||
user = self.user
|
||||
|
||||
unit = self.unit
|
||||
|
||||
user_email = self.user_email
|
||||
|
||||
role: Union[Unset, str] = UNSET
|
||||
if not isinstance(self.role, Unset):
|
||||
role = self.role.value
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"id": id,
|
||||
"user": user,
|
||||
"unit": unit,
|
||||
"user_email": user_email,
|
||||
}
|
||||
)
|
||||
if role is not UNSET:
|
||||
field_dict["role"] = role
|
||||
|
||||
return field_dict
|
||||
|
||||
def to_multipart(self) -> types.RequestFiles:
|
||||
files: types.RequestFiles = []
|
||||
|
||||
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
||||
|
||||
files.append(("user", (None, str(self.user).encode(), "text/plain")))
|
||||
|
||||
files.append(("unit", (None, str(self.unit).encode(), "text/plain")))
|
||||
|
||||
files.append(("user_email", (None, str(self.user_email).encode(), "text/plain")))
|
||||
|
||||
if not isinstance(self.role, Unset):
|
||||
files.append(("role", (None, str(self.role.value).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")
|
||||
|
||||
user = d.pop("user")
|
||||
|
||||
unit = d.pop("unit")
|
||||
|
||||
user_email = d.pop("user_email")
|
||||
|
||||
_role = d.pop("role", UNSET)
|
||||
role: Union[Unset, UnitMembershipRoleEnum]
|
||||
if isinstance(_role, Unset):
|
||||
role = UNSET
|
||||
else:
|
||||
role = UnitMembershipRoleEnum(_role)
|
||||
|
||||
unit_membership = cls(
|
||||
id=id,
|
||||
user=user,
|
||||
unit=unit,
|
||||
user_email=user_email,
|
||||
role=role,
|
||||
)
|
||||
|
||||
unit_membership.additional_properties = d
|
||||
return unit_membership
|
||||
|
||||
@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