Skip to content

feat: allow sorting of Actors collection #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/apify_client/clients/resource_clients/actor_collection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal

from apify_shared.utils import filter_out_none_values_recursively, ignore_docs

Expand All @@ -26,6 +26,7 @@ def list(
limit: int | None = None,
offset: int | None = None,
desc: bool | None = None,
sort_by: Literal['createdAt', 'lastRunStartedAt'] | None = 'createdAt',
) -> ListPage[dict]:
"""List the Actors the user has created or used.

Expand All @@ -36,11 +37,12 @@ def list(
limit: How many Actors to list.
offset: What Actor to include as first when retrieving the list.
desc: Whether to sort the Actors in descending order based on their creation date.
sort_by: Field to sort the results by. Allowed values are "createdAt" and "lastRunStartedAt".

Returns:
The list of available Actors matching the specified filters.
"""
return self._list(my=my, limit=limit, offset=offset, desc=desc)
return self._list(my=my, limit=limit, offset=offset, desc=desc, sortBy=sort_by)

def create(
self,
Expand Down Expand Up @@ -150,6 +152,7 @@ async def list(
limit: int | None = None,
offset: int | None = None,
desc: bool | None = None,
sort_by: Literal['createdAt', 'lastRunStartedAt'] | None = 'createdAt',
) -> ListPage[dict]:
"""List the Actors the user has created or used.

Expand All @@ -160,11 +163,12 @@ async def list(
limit: How many Actors to list.
offset: What Actor to include as first when retrieving the list.
desc: Whether to sort the Actors in descending order based on their creation date.
sort_by: Field to sort the results by. Allowed values are "createdAt" and "lastRunStartedAt".

Returns:
The list of available Actors matching the specified filters.
"""
return await self._list(my=my, limit=limit, offset=offset, desc=desc)
return await self._list(my=my, limit=limit, offset=offset, desc=desc, sortBy=sort_by)

async def create(
self,
Expand Down
Loading