Skip to content

feat: Add unlock_requests method to RequestQueue clients #408

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 1 commit 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
36 changes: 36 additions & 0 deletions src/apify_client/clients/resource_clients/request_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,24 @@ def list_requests(

return parse_date_fields(pluck_data(response.json()))

def unlock_requests(self: RequestQueueClient) -> dict:
"""Unlock all requests in the queue, which were locked by the same clientKey or from the same Actor run.

https://docs.apify.com/api/v2#/reference/request-queues/request-collection/unlock-requests

Returns:
dict: Result of the unlock operation
"""
request_params = self._params(clientKey=self.client_key)

response = self.http_client.call(
url=self._url('requests/unlock'),
method='POST',
params=request_params,
)

return parse_date_fields(pluck_data(response.json()))


class RequestQueueClientAsync(ResourceClientAsync):
"""Async sub-client for manipulating a single request queue."""
Expand Down Expand Up @@ -813,3 +831,21 @@ async def list_requests(
)

return parse_date_fields(pluck_data(response.json()))

async def unlock_requests(self: RequestQueueClientAsync) -> dict:
"""Unlock all requests in the queue, which were locked by the same clientKey or from the same Actor run.

https://docs.apify.com/api/v2#/reference/request-queues/request-collection/unlock-requests

Returns:
dict: Result of the unlock operation
"""
request_params = self._params(clientKey=self.client_key)

response = await self.http_client.call(
url=self._url('requests/unlock'),
method='POST',
params=request_params,
)

return parse_date_fields(pluck_data(response.json()))
Loading