-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtask.py
More file actions
681 lines (590 loc) · 28.3 KB
/
task.py
File metadata and controls
681 lines (590 loc) · 28.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from apify_client._docs import docs_group
from apify_client._models import (
ActorStandby,
Run,
RunOrigin,
RunResponse,
Task,
TaskInput,
TaskOptions,
TaskResponse,
UpdateTaskRequest,
WebhookCreate,
)
from apify_client._resource_clients._resource_client import ResourceClient, ResourceClientAsync
from apify_client._types import WebhookRepresentationList
from apify_client._utils import catch_not_found_or_throw, response_to_dict, to_seconds
from apify_client.errors import ApifyApiError
if TYPE_CHECKING:
from datetime import timedelta
from apify_client._resource_clients import (
RunClient,
RunClientAsync,
RunCollectionClient,
RunCollectionClientAsync,
WebhookCollectionClient,
WebhookCollectionClientAsync,
)
from apify_client._types import ActorJobStatus, Timeout
@docs_group('Resource clients')
class TaskClient(ResourceClient):
"""Sub-client for managing a specific task.
Provides methods to manage a specific task, e.g. update it, delete it, or start runs. Obtain an instance via an
appropriate method on the `ApifyClient` class.
"""
def __init__(
self,
*,
resource_id: str,
resource_path: str = 'actor-tasks',
**kwargs: Any,
) -> None:
super().__init__(resource_id=resource_id, resource_path=resource_path, **kwargs)
def get(self, *, timeout: Timeout = 'short') -> Task | None:
"""Retrieve the task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/get-task
Args:
timeout: Timeout for the API HTTP request.
Returns:
The retrieved task.
"""
result = self._get(timeout=timeout)
if result is None:
return None
return TaskResponse.model_validate(result).data
def update(
self,
*,
name: str | None = None,
task_input: dict | TaskInput | None = None,
build: str | None = None,
max_items: int | None = None,
memory_mbytes: int | None = None,
run_timeout: timedelta | None = None,
restart_on_error: bool | None = None,
title: str | None = None,
actor_standby_desired_requests_per_actor_run: int | None = None,
actor_standby_max_requests_per_actor_run: int | None = None,
actor_standby_idle_timeout: timedelta | None = None,
actor_standby_build: str | None = None,
actor_standby_memory_mbytes: int | None = None,
timeout: Timeout = 'short',
) -> Task:
"""Update the task with specified fields.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/update-task
Args:
name: Name of the task.
build: Actor build to run. It can be either a build tag or build number. By default, the run uses
the build specified in the task settings (typically latest).
max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result,
you will not be charged for more results than the given limit.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
in the task settings.
run_timeout: Optional timeout for the run. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
task_input: Task input dictionary.
title: A human-friendly equivalent of the name.
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
a single Actor Standby run.
actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for
a single Actor Standby run.
actor_standby_idle_timeout: If the Actor run does not receive any requests for this time,
it will be shut down.
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
timeout: Timeout for the API HTTP request.
Returns:
The updated task.
"""
if isinstance(task_input, dict):
task_input = TaskInput.model_validate(task_input)
task_fields = UpdateTaskRequest(
name=name,
title=title,
input=task_input,
options=TaskOptions(
build=build,
max_items=max_items,
memory_mbytes=memory_mbytes,
timeout_secs=to_seconds(run_timeout, as_int=True),
restart_on_error=restart_on_error,
),
actor_standby=ActorStandby(
desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
build=actor_standby_build,
memory_mbytes=actor_standby_memory_mbytes,
),
)
result = self._update(timeout=timeout, **task_fields.model_dump(by_alias=True, exclude_none=True))
return TaskResponse.model_validate(result).data
def delete(self, *, timeout: Timeout = 'short') -> None:
"""Delete the task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/delete-task
Args:
timeout: Timeout for the API HTTP request.
"""
self._delete(timeout=timeout)
def start(
self,
*,
task_input: dict | TaskInput | None = None,
build: str | None = None,
max_items: int | None = None,
memory_mbytes: int | None = None,
run_timeout: timedelta | None = None,
restart_on_error: bool | None = None,
wait_for_finish: int | None = None,
webhooks: list[WebhookCreate] | list[dict] | None = None,
timeout: Timeout = 'medium',
) -> Run:
"""Start the task and immediately return the Run object.
https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task
Args:
task_input: Task input dictionary.
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
the run uses the build specified in the task settings (typically latest).
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
per result, you will not be charged for more results than the given limit.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
in the task settings.
run_timeout: Optional timeout for the run. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
it is 0, the maximum value is 60.
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed.
If you already have a webhook set up for the Actor or task, you do not have to add it again here.
Each webhook is represented by a dictionary containing these items:
* `event_types`: List of `WebhookEventType` values which trigger the webhook.
* `request_url`: URL to which to send the webhook HTTP request.
* `payload_template`: Optional template for the request payload.
timeout: Timeout for the API HTTP request.
Returns:
The run object.
"""
if isinstance(task_input, dict):
task_input = TaskInput.model_validate(task_input)
request_params = self._build_params(
build=build,
maxItems=max_items,
memory=memory_mbytes,
timeout=to_seconds(run_timeout, as_int=True),
restartOnError=restart_on_error,
waitForFinish=wait_for_finish,
webhooks=WebhookRepresentationList.from_webhooks(webhooks or []).to_base64(),
)
response = self._http_client.call(
url=self._build_url('runs'),
method='POST',
headers={'content-type': 'application/json; charset=utf-8'},
json=task_input.model_dump() if task_input is not None else None,
params=request_params,
timeout=timeout,
)
result = response_to_dict(response)
return RunResponse.model_validate(result).data
def call(
self,
*,
task_input: dict | TaskInput | None = None,
build: str | None = None,
max_items: int | None = None,
memory_mbytes: int | None = None,
run_timeout: timedelta | None = None,
restart_on_error: bool | None = None,
webhooks: list[WebhookCreate] | list[dict] | None = None,
wait_duration: timedelta | None = None,
timeout: Timeout = 'no_timeout',
) -> Run | None:
"""Start a task and wait for it to finish before returning the Run object.
It waits indefinitely, unless the wait_duration argument is provided.
https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task
Args:
task_input: Task input dictionary.
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
the run uses the build specified in the task settings (typically latest).
max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result,
you will not be charged for more results than the given limit.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
in the task settings.
run_timeout: Optional timeout for the run. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
the Actor or task, you do not have to add it again here.
wait_duration: The maximum time the server waits for the task run to finish. If not provided,
waits indefinitely.
timeout: Timeout for the API HTTP request.
Returns:
The run object.
"""
started_run = self.start(
task_input=task_input,
build=build,
max_items=max_items,
memory_mbytes=memory_mbytes,
run_timeout=run_timeout,
restart_on_error=restart_on_error,
webhooks=webhooks,
timeout=timeout,
)
run_client = self._client_registry.run_client(
resource_id=started_run.id,
base_url=self._base_url,
public_base_url=self._public_base_url,
http_client=self._http_client,
client_registry=self._client_registry,
)
return run_client.wait_for_finish(wait_duration=wait_duration)
def get_input(self, *, timeout: Timeout = 'short') -> dict | None:
"""Retrieve the default input for this task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/get-task-input
Args:
timeout: Timeout for the API HTTP request.
Returns:
Retrieved task input.
"""
try:
response = self._http_client.call(
url=self._build_url('input'),
method='GET',
params=self._build_params(),
timeout=timeout,
)
return response_to_dict(response)
except ApifyApiError as exc:
catch_not_found_or_throw(exc)
return None
def update_input(self, *, task_input: dict | TaskInput, timeout: Timeout = 'short') -> dict:
"""Update the default input for this task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/update-task-input
Args:
task_input: The new default input for this task.
timeout: Timeout for the API HTTP request.
Returns:
The updated task input.
"""
if isinstance(task_input, dict):
task_input = TaskInput.model_validate(task_input)
response = self._http_client.call(
url=self._build_url('input'),
method='PUT',
params=self._build_params(),
json=task_input.model_dump(),
timeout=timeout,
)
return response_to_dict(response)
def runs(self) -> RunCollectionClient:
"""Retrieve a client for the runs of this task."""
return self._client_registry.run_collection_client(
resource_path='runs',
**self._base_client_kwargs,
)
def last_run(self, *, status: ActorJobStatus | None = None, origin: RunOrigin | None = None) -> RunClient:
"""Retrieve the client for the last run of this task.
Last run is retrieved based on the start time of the runs.
Args:
status: Consider only runs with this status.
origin: Consider only runs started with this origin.
Returns:
The resource client for the last run of this task.
"""
return self._client_registry.run_client(
resource_id='last',
resource_path='runs',
params=self._build_params(status=status, origin=origin),
**self._base_client_kwargs,
)
def webhooks(self) -> WebhookCollectionClient:
"""Retrieve a client for webhooks associated with this task."""
return self._client_registry.webhook_collection_client(**self._base_client_kwargs)
@docs_group('Resource clients')
class TaskClientAsync(ResourceClientAsync):
"""Sub-client for managing a specific task.
Provides methods to manage a specific task, e.g. update it, delete it, or start runs. Obtain an instance via an
appropriate method on the `ApifyClientAsync` class.
"""
def __init__(
self,
*,
resource_id: str,
resource_path: str = 'actor-tasks',
**kwargs: Any,
) -> None:
super().__init__(resource_id=resource_id, resource_path=resource_path, **kwargs)
async def get(self, *, timeout: Timeout = 'short') -> Task | None:
"""Retrieve the task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/get-task
Args:
timeout: Timeout for the API HTTP request.
Returns:
The retrieved task.
"""
result = await self._get(timeout=timeout)
if result is None:
return None
return TaskResponse.model_validate(result).data
async def update(
self,
*,
name: str | None = None,
task_input: dict | TaskInput | None = None,
build: str | None = None,
max_items: int | None = None,
memory_mbytes: int | None = None,
run_timeout: timedelta | None = None,
restart_on_error: bool | None = None,
title: str | None = None,
actor_standby_desired_requests_per_actor_run: int | None = None,
actor_standby_max_requests_per_actor_run: int | None = None,
actor_standby_idle_timeout: timedelta | None = None,
actor_standby_build: str | None = None,
actor_standby_memory_mbytes: int | None = None,
timeout: Timeout = 'short',
) -> Task:
"""Update the task with specified fields.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/update-task
Args:
name: Name of the task.
build: Actor build to run. It can be either a build tag or build number. By default, the run uses
the build specified in the task settings (typically latest).
max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result,
you will not be charged for more results than the given limit.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
in the task settings.
run_timeout: Optional timeout for the run. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
task_input: Task input dictionary.
title: A human-friendly equivalent of the name.
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
a single Actor Standby run.
actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for
a single Actor Standby run.
actor_standby_idle_timeout: If the Actor run does not receive any requests for this time,
it will be shut down.
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
timeout: Timeout for the API HTTP request.
Returns:
The updated task.
"""
if isinstance(task_input, dict):
task_input = TaskInput.model_validate(task_input)
task_fields = UpdateTaskRequest(
name=name,
title=title,
input=task_input,
options=TaskOptions(
build=build,
max_items=max_items,
memory_mbytes=memory_mbytes,
timeout_secs=to_seconds(run_timeout, as_int=True),
restart_on_error=restart_on_error,
),
actor_standby=ActorStandby(
desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
build=actor_standby_build,
memory_mbytes=actor_standby_memory_mbytes,
),
)
result = await self._update(timeout=timeout, **task_fields.model_dump(by_alias=True, exclude_none=True))
return TaskResponse.model_validate(result).data
async def delete(self, *, timeout: Timeout = 'short') -> None:
"""Delete the task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/delete-task
Args:
timeout: Timeout for the API HTTP request.
"""
await self._delete(timeout=timeout)
async def start(
self,
*,
task_input: dict | TaskInput | None = None,
build: str | None = None,
max_items: int | None = None,
memory_mbytes: int | None = None,
run_timeout: timedelta | None = None,
restart_on_error: bool | None = None,
wait_for_finish: int | None = None,
webhooks: list[WebhookCreate] | list[dict] | None = None,
timeout: Timeout = 'medium',
) -> Run:
"""Start the task and immediately return the Run object.
https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task
Args:
task_input: Task input dictionary.
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
the run uses the build specified in the task settings (typically latest).
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
per result, you will not be charged for more results than the given limit.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
in the task settings.
run_timeout: Optional timeout for the run. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
it is 0, the maximum value is 60.
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed.
If you already have a webhook set up for the Actor or task, you do not have to add it again here.
Each webhook is represented by a dictionary containing these items:
* `event_types`: List of `WebhookEventType` values which trigger the webhook.
* `request_url`: URL to which to send the webhook HTTP request.
* `payload_template`: Optional template for the request payload.
timeout: Timeout for the API HTTP request.
Returns:
The run object.
"""
if isinstance(task_input, dict):
task_input = TaskInput.model_validate(task_input)
request_params = self._build_params(
build=build,
maxItems=max_items,
memory=memory_mbytes,
timeout=to_seconds(run_timeout, as_int=True),
restartOnError=restart_on_error,
waitForFinish=wait_for_finish,
webhooks=WebhookRepresentationList.from_webhooks(webhooks or []).to_base64(),
)
response = await self._http_client.call(
url=self._build_url('runs'),
method='POST',
headers={'content-type': 'application/json; charset=utf-8'},
json=task_input.model_dump() if task_input is not None else None,
params=request_params,
timeout=timeout,
)
result = response_to_dict(response)
return RunResponse.model_validate(result).data
async def call(
self,
*,
task_input: dict | TaskInput | None = None,
build: str | None = None,
max_items: int | None = None,
memory_mbytes: int | None = None,
run_timeout: timedelta | None = None,
restart_on_error: bool | None = None,
webhooks: list[WebhookCreate] | list[dict] | None = None,
wait_duration: timedelta | None = None,
timeout: Timeout = 'no_timeout',
) -> Run | None:
"""Start a task and wait for it to finish before returning the Run object.
It waits indefinitely, unless the wait_duration argument is provided.
https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task
Args:
task_input: Task input dictionary.
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
the run uses the build specified in the task settings (typically latest).
max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result,
you will not be charged for more results than the given limit.
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
in the task settings.
run_timeout: Optional timeout for the run. By default, the run uses timeout specified
in the task settings.
restart_on_error: If true, the Task run process will be restarted whenever it exits with
a non-zero status code.
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
the Actor or task, you do not have to add it again here.
wait_duration: The maximum time the server waits for the task run to finish. If not provided,
waits indefinitely.
timeout: Timeout for the API HTTP request.
Returns:
The run object.
"""
started_run = await self.start(
task_input=task_input,
build=build,
max_items=max_items,
memory_mbytes=memory_mbytes,
run_timeout=run_timeout,
restart_on_error=restart_on_error,
webhooks=webhooks,
timeout=timeout,
)
run_client = self._client_registry.run_client(
resource_id=started_run.id,
base_url=self._base_url,
public_base_url=self._public_base_url,
http_client=self._http_client,
client_registry=self._client_registry,
)
return await run_client.wait_for_finish(wait_duration=wait_duration)
async def get_input(self, *, timeout: Timeout = 'short') -> dict | None:
"""Retrieve the default input for this task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/get-task-input
Args:
timeout: Timeout for the API HTTP request.
Returns:
Retrieved task input.
"""
try:
response = await self._http_client.call(
url=self._build_url('input'),
method='GET',
params=self._build_params(),
timeout=timeout,
)
return response_to_dict(response)
except ApifyApiError as exc:
catch_not_found_or_throw(exc)
return None
async def update_input(self, *, task_input: dict | TaskInput, timeout: Timeout = 'short') -> dict:
"""Update the default input for this task.
https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/update-task-input
Args:
task_input: The new default input for this task.
timeout: Timeout for the API HTTP request.
Returns:
The updated task input.
"""
if isinstance(task_input, dict):
task_input = TaskInput.model_validate(task_input)
response = await self._http_client.call(
url=self._build_url('input'),
method='PUT',
params=self._build_params(),
json=task_input.model_dump(),
timeout=timeout,
)
return response_to_dict(response)
def runs(self) -> RunCollectionClientAsync:
"""Retrieve a client for the runs of this task."""
return self._client_registry.run_collection_client(
resource_path='runs',
**self._base_client_kwargs,
)
def last_run(self, *, status: ActorJobStatus | None = None, origin: RunOrigin | None = None) -> RunClientAsync:
"""Retrieve the client for the last run of this task.
Last run is retrieved based on the start time of the runs.
Args:
status: Consider only runs with this status.
origin: Consider only runs started with this origin.
Returns:
The resource client for the last run of this task.
"""
return self._client_registry.run_client(
resource_id='last',
resource_path='runs',
params=self._build_params(status=status, origin=origin),
**self._base_client_kwargs,
)
def webhooks(self) -> WebhookCollectionClientAsync:
"""Retrieve a client for webhooks associated with this task."""
return self._client_registry.webhook_collection_client(**self._base_client_kwargs)