122 lines
3.5 KiB
Python
122 lines
3.5 KiB
Python
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from ..types import UNSET, Unset
|
|
|
|
if TYPE_CHECKING:
|
|
from ..models.application import Application
|
|
|
|
|
|
T = TypeVar("T", bound="PaginatedApplicationList")
|
|
|
|
|
|
@_attrs_define
|
|
class PaginatedApplicationList:
|
|
"""
|
|
Attributes:
|
|
count (int): Example: 123.
|
|
results (list['Application']):
|
|
next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4.
|
|
previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2.
|
|
"""
|
|
|
|
count: int
|
|
results: list["Application"]
|
|
next_: Union[None, Unset, str] = UNSET
|
|
previous: Union[None, Unset, str] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
count = self.count
|
|
|
|
results = []
|
|
for results_item_data in self.results:
|
|
results_item = results_item_data.to_dict()
|
|
results.append(results_item)
|
|
|
|
next_: Union[None, Unset, str]
|
|
if isinstance(self.next_, Unset):
|
|
next_ = UNSET
|
|
else:
|
|
next_ = self.next_
|
|
|
|
previous: Union[None, Unset, str]
|
|
if isinstance(self.previous, Unset):
|
|
previous = UNSET
|
|
else:
|
|
previous = self.previous
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"count": count,
|
|
"results": results,
|
|
}
|
|
)
|
|
if next_ is not UNSET:
|
|
field_dict["next"] = next_
|
|
if previous is not UNSET:
|
|
field_dict["previous"] = previous
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
|
from ..models.application import Application
|
|
|
|
d = src_dict.copy()
|
|
count = d.pop("count")
|
|
|
|
results = []
|
|
_results = d.pop("results")
|
|
for results_item_data in _results:
|
|
results_item = Application.from_dict(results_item_data)
|
|
|
|
results.append(results_item)
|
|
|
|
def _parse_next_(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
next_ = _parse_next_(d.pop("next", UNSET))
|
|
|
|
def _parse_previous(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
previous = _parse_previous(d.pop("previous", UNSET))
|
|
|
|
paginated_application_list = cls(
|
|
count=count,
|
|
results=results,
|
|
next_=next_,
|
|
previous=previous,
|
|
)
|
|
|
|
paginated_application_list.additional_properties = d
|
|
return paginated_application_list
|
|
|
|
@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
|