Skip to content
Merged
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
36 changes: 32 additions & 4 deletions src/apify_client/clients/resource_clients/key_value_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,33 @@ def delete(self) -> None:
"""
return self._delete(timeout_secs=_SMALL_TIMEOUT)

def list_keys(self, *, limit: int | None = None, exclusive_start_key: str | None = None) -> dict:
def list_keys(
self,
*,
limit: int | None = None,
exclusive_start_key: str | None = None,
collection: str | None = None,
prefix: str | None = None,
) -> dict:
"""List the keys in the key-value store.

https://docs.apify.com/api/v2#/reference/key-value-stores/key-collection/get-list-of-keys

Args:
limit: Number of keys to be returned. Maximum value is 1000.
exclusive_start_key: All keys up to this one (including) are skipped from the result.
collection: The name of the collection in store schema to list keys from.
prefix: The prefix of the keys to be listed.

Returns:
The list of keys in the key-value store matching the given arguments.
"""
request_params = self._params(limit=limit, exclusiveStartKey=exclusive_start_key)
request_params = self._params(
limit=limit,
exclusiveStartKey=exclusive_start_key,
collection=collection,
prefix=prefix,
)

response = self.http_client.call(
url=self._url('keys'),
Expand Down Expand Up @@ -292,19 +306,33 @@ async def delete(self) -> None:
"""
return await self._delete(timeout_secs=_SMALL_TIMEOUT)

async def list_keys(self, *, limit: int | None = None, exclusive_start_key: str | None = None) -> dict:
async def list_keys(
self,
*,
limit: int | None = None,
exclusive_start_key: str | None = None,
collection: str | None = None,
prefix: str | None = None,
) -> dict:
"""List the keys in the key-value store.

https://docs.apify.com/api/v2#/reference/key-value-stores/key-collection/get-list-of-keys

Args:
limit: Number of keys to be returned. Maximum value is 1000.
exclusive_start_key: All keys up to this one (including) are skipped from the result.
collection: The name of the collection in store schema to list keys from.
prefix: The prefix of the keys to be listed.

Returns:
The list of keys in the key-value store matching the given arguments.
"""
request_params = self._params(limit=limit, exclusiveStartKey=exclusive_start_key)
request_params = self._params(
limit=limit,
exclusiveStartKey=exclusive_start_key,
collection=collection,
prefix=prefix,
)

response = await self.http_client.call(
url=self._url('keys'),
Expand Down