@@ -266,13 +266,7 @@ def last_run(self: TaskClient, *, status: ActorJobStatus | None = None, origin:
266
266
Returns:
267
267
RunClient: The resource client for the last run of this task.
268
268
"""
269
- # Note:
270
- # The API does not provide a direct endpoint for aborting the last task run using a URL like:
271
- # https://api.apify.com/v2/actor-tasks/{task_id}/runs/last/abort
272
- # To achieve this, we need to implement a workaround using the following URL format:
273
- # https://api.apify.com/v2/acts/{actorId}/runs/{runId}/abort
274
-
275
- last_run_client = RunClient (
269
+ return RunClient (
276
270
** self ._sub_resource_init_options (
277
271
resource_id = 'last' ,
278
272
resource_path = 'runs' ,
@@ -283,21 +277,6 @@ def last_run(self: TaskClient, *, status: ActorJobStatus | None = None, origin:
283
277
)
284
278
)
285
279
286
- last_run_client_info = last_run_client .get ()
287
- actor_id = last_run_client_info ['actId' ] # type: ignore
288
- actor_run_id = last_run_client_info ['id' ] # type: ignore
289
-
290
- return RunClient (
291
- ** self ._sub_resource_init_options (
292
- base_url = 'https://api.apify.com/v2' ,
293
- resource_path = f'acts/{ actor_id } /runs/{ actor_run_id } ' ,
294
- params = self ._params (
295
- status = maybe_extract_enum_member_value (status ),
296
- origin = maybe_extract_enum_member_value (origin ),
297
- ),
298
- )
299
- )
300
-
301
280
def webhooks (self : TaskClient ) -> WebhookCollectionClient :
302
281
"""Retrieve a client for webhooks associated with this task."""
303
282
return WebhookCollectionClient (** self ._sub_resource_init_options ())
@@ -512,7 +491,7 @@ def runs(self: TaskClientAsync) -> RunCollectionClientAsync:
512
491
"""Retrieve a client for the runs of this task."""
513
492
return RunCollectionClientAsync (** self ._sub_resource_init_options (resource_path = 'runs' ))
514
493
515
- async def last_run (self : TaskClientAsync , * , status : ActorJobStatus | None = None , origin : MetaOrigin | None = None ) -> RunClientAsync :
494
+ def last_run (self : TaskClientAsync , * , status : ActorJobStatus | None = None , origin : MetaOrigin | None = None ) -> RunClientAsync :
516
495
"""Retrieve the client for the last run of this task.
517
496
518
497
Last run is retrieved based on the start time of the runs.
@@ -524,13 +503,7 @@ async def last_run(self: TaskClientAsync, *, status: ActorJobStatus | None = Non
524
503
Returns:
525
504
RunClientAsync: The resource client for the last run of this task.
526
505
"""
527
- # Note:
528
- # The API does not provide a direct endpoint for aborting the last task run using a URL like:
529
- # https://api.apify.com/v2/actor-tasks/{task_id}/runs/last/abort
530
- # To achieve this, we need to implement a workaround using the following URL format:
531
- # https://api.apify.com/v2/acts/{actorId}/runs/{runId}/abort
532
-
533
- last_run_client = RunClientAsync (
506
+ return RunClientAsync (
534
507
** self ._sub_resource_init_options (
535
508
resource_id = 'last' ,
536
509
resource_path = 'runs' ,
@@ -541,21 +514,6 @@ async def last_run(self: TaskClientAsync, *, status: ActorJobStatus | None = Non
541
514
)
542
515
)
543
516
544
- last_run_client_info = await last_run_client .get ()
545
- actor_id = last_run_client_info ['actId' ] # type: ignore
546
- actor_run_id = last_run_client_info ['id' ] # type: ignore
547
-
548
- return RunClientAsync (
549
- ** self ._sub_resource_init_options (
550
- base_url = 'https://api.apify.com/v2' ,
551
- resource_path = f'acts/{ actor_id } /runs/{ actor_run_id } ' ,
552
- params = self ._params (
553
- status = maybe_extract_enum_member_value (status ),
554
- origin = maybe_extract_enum_member_value (origin ),
555
- ),
556
- )
557
- )
558
-
559
517
def webhooks (self : TaskClientAsync ) -> WebhookCollectionClientAsync :
560
518
"""Retrieve a client for webhooks associated with this task."""
561
519
return WebhookCollectionClientAsync (** self ._sub_resource_init_options ())
0 commit comments