Skip to content

Commit d4f0018

Browse files
authored
feat: Add unlock_requests method to RequestQueue clients (#408)
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 d03ae95 commit d4f0018

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
@@ -403,6 +403,24 @@ def list_requests(
403403

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

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

407425
class RequestQueueClientAsync(ResourceClientAsync):
408426
"""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)