Skip to content

Commit 047ea82

Browse files
committed
feat: Add unlock_requests method to RequestQueue clients
Introduce the `unlock_requests` method to both sync and async RequestQueue clients, allowing users to unlock all requests locked by the same clientKey or Actor run.
1 parent ed6d3c7 commit 047ea82

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/apify_client/clients/resource_clients/request_queue.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,24 @@ def list_requests(
404404

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

407+
def unlock_requests(self: RequestQueueClient) -> dict:
408+
"""Unlock all requests in the queue, which were locked by the same clientKey or from the same Actor run.
409+
410+
https://docs.apify.com/api/v2#/reference/request-queues/request-collection/unlock-requests
411+
412+
Returns:
413+
dict: Result of the unlock operation
414+
"""
415+
request_params = self._params(clientKey=self.client_key)
416+
417+
response = self.http_client.call(
418+
url=self._url('requests/unlock'),
419+
method='POST',
420+
params=request_params,
421+
)
422+
423+
return parse_date_fields(pluck_data(response.json()))
424+
407425

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

815833
return parse_date_fields(pluck_data(response.json()))
834+
835+
async def unlock_requests(self: RequestQueueClientAsync) -> dict:
836+
"""Unlock all requests in the queue, which were locked by the same clientKey or from the same Actor run.
837+
838+
https://docs.apify.com/api/v2#/reference/request-queues/request-collection/unlock-requests
839+
840+
Returns:
841+
dict: Result of the unlock operation
842+
"""
843+
request_params = self._params(clientKey=self.client_key)
844+
845+
response = await self.http_client.call(
846+
url=self._url('requests/unlock'),
847+
method='POST',
848+
params=request_params,
849+
)
850+
851+
return parse_date_fields(pluck_data(response.json()))

0 commit comments

Comments
 (0)