Skip to content

Commit 0e311ae

Browse files
committed
Enable for async collection clients
1 parent 8cb46fc commit 0e311ae

13 files changed

+80
-51
lines changed

src/apify_client/clients/resource_clients/actor_env_var_collection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from apify_client.clients.resource_clients.actor_env_var import get_actor_env_var_representation
88

99
if TYPE_CHECKING:
10-
from apify_client.clients.base.resource_collection_client import ListPage
10+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
1111

1212

1313
class ActorEnvVarCollectionClient(ResourceCollectionClient):
@@ -62,15 +62,15 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
6262
resource_path = kwargs.pop('resource_path', 'env-vars')
6363
super().__init__(*args, resource_path=resource_path, **kwargs)
6464

65-
async def list(self) -> ListPage[dict]:
65+
def list(self) -> ListPageProtocol[dict]:
6666
"""List the available actor environment variables.
6767
6868
https://docs.apify.com/api/v2#/reference/actors/environment-variable-collection/get-list-of-environment-variables
6969
7070
Returns:
7171
The list of available actor environment variables.
7272
"""
73-
return await self._list()
73+
return self._list_iterable()
7474

7575
async def create(
7676
self,

src/apify_client/clients/resource_clients/actor_version_collection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
if TYPE_CHECKING:
1010
from apify_shared.consts import ActorSourceType
1111

12-
from apify_client.clients.base.resource_collection_client import ListPage
12+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
1313

1414

1515
class ActorVersionCollectionClient(ResourceCollectionClient):
@@ -88,15 +88,15 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
8888
resource_path = kwargs.pop('resource_path', 'versions')
8989
super().__init__(*args, resource_path=resource_path, **kwargs)
9090

91-
async def list(self) -> ListPage[dict]:
91+
def list(self) -> ListPageProtocol[dict]:
9292
"""List the available Actor versions.
9393
9494
https://docs.apify.com/api/v2#/reference/actors/version-collection/get-list-of-versions
9595
9696
Returns:
9797
The list of available Actor versions.
9898
"""
99-
return await self._list()
99+
return self._list_iterable()
100100

101101
async def create(
102102
self,

src/apify_client/clients/resource_clients/build_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
66

77
if TYPE_CHECKING:
8-
from apify_client.clients.base.resource_collection_client import ListPage
8+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
99

1010

1111
class BuildCollectionClient(ResourceCollectionClient):
@@ -48,13 +48,13 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
4848
resource_path = kwargs.pop('resource_path', 'actor-builds')
4949
super().__init__(*args, resource_path=resource_path, **kwargs)
5050

51-
async def list(
51+
def list(
5252
self,
5353
*,
5454
limit: int | None = None,
5555
offset: int | None = None,
5656
desc: bool | None = None,
57-
) -> ListPage[dict]:
57+
) -> ListPageProtocol[dict]:
5858
"""List all Actor builds.
5959
6060
List all Actor builds, either of a single Actor, or all user's Actors, depending on where this client
@@ -71,4 +71,4 @@ async def list(
7171
Returns:
7272
The retrieved Actor builds.
7373
"""
74-
return await self._list(limit=limit, offset=offset, desc=desc)
74+
return self._list_iterable(limit=limit, offset=offset, desc=desc)

src/apify_client/clients/resource_clients/dataset_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
77

88
if TYPE_CHECKING:
9-
from apify_client.clients.base.resource_collection_client import ListPage
9+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
1010

1111

1212
class DatasetCollectionClient(ResourceCollectionClient):
@@ -61,14 +61,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
6161
resource_path = kwargs.pop('resource_path', 'datasets')
6262
super().__init__(*args, resource_path=resource_path, **kwargs)
6363

64-
async def list(
64+
def list(
6565
self,
6666
*,
6767
unnamed: bool | None = None,
6868
limit: int | None = None,
6969
offset: int | None = None,
7070
desc: bool | None = None,
71-
) -> ListPage[dict]:
71+
) -> ListPageProtocol[dict]:
7272
"""List the available datasets.
7373
7474
https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/get-list-of-datasets
@@ -82,7 +82,7 @@ async def list(
8282
Returns:
8383
The list of available datasets matching the specified filters.
8484
"""
85-
return await self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc)
85+
return self._list_iterable(unnamed=unnamed, limit=limit, offset=offset, desc=desc)
8686

8787
async def get_or_create(
8888
self,

src/apify_client/clients/resource_clients/key_value_store_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
77

88
if TYPE_CHECKING:
9-
from apify_client.clients.base.resource_collection_client import ListPage
9+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
1010

1111

1212
class KeyValueStoreCollectionClient(ResourceCollectionClient):
@@ -66,14 +66,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
6666
resource_path = kwargs.pop('resource_path', 'key-value-stores')
6767
super().__init__(*args, resource_path=resource_path, **kwargs)
6868

69-
async def list(
69+
def list(
7070
self,
7171
*,
7272
unnamed: bool | None = None,
7373
limit: int | None = None,
7474
offset: int | None = None,
7575
desc: bool | None = None,
76-
) -> ListPage[dict]:
76+
) -> ListPageProtocol[dict]:
7777
"""List the available key-value stores.
7878
7979
https://docs.apify.com/api/v2#/reference/key-value-stores/store-collection/get-list-of-key-value-stores
@@ -87,7 +87,7 @@ async def list(
8787
Returns:
8888
The list of available key-value stores matching the specified filters.
8989
"""
90-
return await self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc)
90+
return self._list_iterable(unnamed=unnamed, limit=limit, offset=offset, desc=desc)
9191

9292
async def get_or_create(
9393
self,

src/apify_client/clients/resource_clients/request_queue_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
66

77
if TYPE_CHECKING:
8-
from apify_client.clients.base.resource_collection_client import ListPage
8+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
99

1010

1111
class RequestQueueCollectionClient(ResourceCollectionClient):
@@ -59,14 +59,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
5959
resource_path = kwargs.pop('resource_path', 'request-queues')
6060
super().__init__(*args, resource_path=resource_path, **kwargs)
6161

62-
async def list(
62+
def list(
6363
self,
6464
*,
6565
unnamed: bool | None = None,
6666
limit: int | None = None,
6767
offset: int | None = None,
6868
desc: bool | None = None,
69-
) -> ListPage[dict]:
69+
) -> ListPageProtocol[dict]:
7070
"""List the available request queues.
7171
7272
https://docs.apify.com/api/v2#/reference/request-queues/queue-collection/get-list-of-request-queues
@@ -80,7 +80,7 @@ async def list(
8080
Returns:
8181
The list of available request queues matching the specified filters.
8282
"""
83-
return await self._list(unnamed=unnamed, limit=limit, offset=offset, desc=desc)
83+
return self._list_iterable(unnamed=unnamed, limit=limit, offset=offset, desc=desc)
8484

8585
async def get_or_create(self, *, name: str | None = None) -> dict:
8686
"""Retrieve a named request queue, or create a new one when it doesn't exist.

src/apify_client/clients/resource_clients/run_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from apify_shared.consts import ActorJobStatus
1212

13-
from apify_client.clients.base.resource_collection_client import ListPage
13+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
1414

1515

1616
class RunCollectionClient(ResourceCollectionClient):
@@ -71,7 +71,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
7171
resource_path = kwargs.pop('resource_path', 'actor-runs')
7272
super().__init__(*args, resource_path=resource_path, **kwargs)
7373

74-
async def list(
74+
def list(
7575
self,
7676
*,
7777
limit: int | None = None,
@@ -80,7 +80,7 @@ async def list(
8080
status: ActorJobStatus | list[ActorJobStatus] | None = None,
8181
started_before: str | datetime | None = None,
8282
started_after: str | datetime | None = None,
83-
) -> ListPage[dict]:
83+
) -> ListPageProtocol[dict]:
8484
"""List all Actor runs.
8585
8686
List all Actor runs, either of a single Actor, or all user's Actors, depending on where this client
@@ -105,7 +105,7 @@ async def list(
105105
else:
106106
status_param = maybe_extract_enum_member_value(status)
107107

108-
return await self._list(
108+
return self._list_iterable(
109109
limit=limit,
110110
offset=offset,
111111
desc=desc,

src/apify_client/clients/resource_clients/schedule_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from apify_client.clients.resource_clients.schedule import _get_schedule_representation
88

99
if TYPE_CHECKING:
10-
from apify_client.clients.base.resource_collection_client import ListPage
10+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
1111

1212

1313
class ScheduleCollectionClient(ResourceCollectionClient):
@@ -93,13 +93,13 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
9393
resource_path = kwargs.pop('resource_path', 'schedules')
9494
super().__init__(*args, resource_path=resource_path, **kwargs)
9595

96-
async def list(
96+
def list(
9797
self,
9898
*,
9999
limit: int | None = None,
100100
offset: int | None = None,
101101
desc: bool | None = None,
102-
) -> ListPage[dict]:
102+
) -> ListPageProtocol[dict]:
103103
"""List the available schedules.
104104
105105
https://docs.apify.com/api/v2#/reference/schedules/schedules-collection/get-list-of-schedules
@@ -112,7 +112,7 @@ async def list(
112112
Returns:
113113
The list of available schedules matching the specified filters.
114114
"""
115-
return await self._list(limit=limit, offset=offset, desc=desc)
115+
return self._list_iterable(limit=limit, offset=offset, desc=desc)
116116

117117
async def create(
118118
self,

src/apify_client/clients/resource_clients/store_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from apify_client.clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
66

77
if TYPE_CHECKING:
8-
from apify_client.clients.base.resource_collection_client import ListPage
8+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
99

1010

1111
class StoreCollectionClient(ResourceCollectionClient):
@@ -61,7 +61,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
6161
resource_path = kwargs.pop('resource_path', 'store')
6262
super().__init__(*args, resource_path=resource_path, **kwargs)
6363

64-
async def list(
64+
def list(
6565
self,
6666
*,
6767
limit: int | None = None,
@@ -71,7 +71,7 @@ async def list(
7171
category: str | None = None,
7272
username: str | None = None,
7373
pricing_model: str | None = None,
74-
) -> ListPage[dict]:
74+
) -> ListPageProtocol[dict]:
7575
"""List Actors in Apify store.
7676
7777
https://docs.apify.com/api/v2/#/reference/store/store-actors-collection/get-list-of-actors-in-store
@@ -89,7 +89,7 @@ async def list(
8989
Returns:
9090
The list of available tasks matching the specified filters.
9191
"""
92-
return await self._list(
92+
return self._list_iterable(
9393
limit=limit,
9494
offset=offset,
9595
search=search,

src/apify_client/clients/resource_clients/task_collection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from apify_client.clients.resource_clients.task import get_task_representation
88

99
if TYPE_CHECKING:
10-
from apify_client.clients.base.resource_collection_client import ListPage
10+
from apify_client.clients.base.resource_collection_client import ListPage, ListPageProtocol
1111

1212

1313
class TaskCollectionClient(ResourceCollectionClient):
@@ -114,13 +114,13 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
114114
resource_path = kwargs.pop('resource_path', 'actor-tasks')
115115
super().__init__(*args, resource_path=resource_path, **kwargs)
116116

117-
async def list(
117+
def list(
118118
self,
119119
*,
120120
limit: int | None = None,
121121
offset: int | None = None,
122122
desc: bool | None = None,
123-
) -> ListPage[dict]:
123+
) -> ListPageProtocol[dict]:
124124
"""List the available tasks.
125125
126126
https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/get-list-of-tasks
@@ -133,7 +133,7 @@ async def list(
133133
Returns:
134134
The list of available tasks matching the specified filters.
135135
"""
136-
return await self._list(limit=limit, offset=offset, desc=desc)
136+
return self._list_iterable(limit=limit, offset=offset, desc=desc)
137137

138138
async def create(
139139
self,

0 commit comments

Comments
 (0)