|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from typing import Any, Generic, TypeVar |
| 3 | +from typing import Any |
4 | 4 |
|
| 5 | +from apify_client._types import ListPage |
5 | 6 | from apify_client._utils import pluck_data |
6 | 7 | from apify_client.clients.base.base_client import BaseClient, BaseClientAsync |
7 | 8 |
|
8 | | -T = TypeVar('T') |
9 | | - |
10 | | - |
11 | | -class ListPage(Generic[T]): |
12 | | - """A single page of items returned from a list() method.""" |
13 | | - |
14 | | - items: list[T] |
15 | | - """List of returned objects on this page""" |
16 | | - |
17 | | - count: int |
18 | | - """Count of the returned objects on this page""" |
19 | | - |
20 | | - offset: int |
21 | | - """The limit on the number of returned objects offset specified in the API call""" |
22 | | - |
23 | | - limit: int |
24 | | - """The offset of the first object specified in the API call""" |
25 | | - |
26 | | - total: int |
27 | | - """Total number of objects matching the API call criteria""" |
28 | | - |
29 | | - desc: bool |
30 | | - """Whether the listing is descending or not""" |
31 | | - |
32 | | - def __init__(self, data: dict) -> None: |
33 | | - """Initialize a ListPage instance from the API response data.""" |
34 | | - self.items = data.get('items', []) |
35 | | - self.offset = data.get('offset', 0) |
36 | | - self.limit = data.get('limit', 0) |
37 | | - self.count = data['count'] if 'count' in data else len(self.items) |
38 | | - self.total = data['total'] if 'total' in data else self.offset + self.count |
39 | | - self.desc = data.get('desc', False) |
40 | | - |
41 | 9 |
|
42 | 10 | class ResourceCollectionClient(BaseClient): |
43 | 11 | """Base class for sub-clients manipulating a resource collection.""" |
|
0 commit comments