|
3 | 3 | from datetime import timedelta |
4 | 4 | from typing import Literal |
5 | 5 |
|
| 6 | +from apify_client._models import WebhookCreate, WebhookRepresentation |
| 7 | +from apify_client._typeddicts import ( |
| 8 | + WebhookCreateCamelDict, |
| 9 | + WebhookCreateDict, |
| 10 | + WebhookRepresentationCamelDict, |
| 11 | + WebhookRepresentationDict, |
| 12 | +) |
| 13 | + |
6 | 14 | Timeout = timedelta | Literal['no_timeout', 'short', 'medium', 'long'] |
7 | 15 | """Type for the `timeout` parameter on resource client methods. |
8 | 16 |
|
9 | 17 | `'short'`, `'medium'`, and `'long'` are tier literals resolved by the HTTP client to configured values. |
10 | 18 | A `timedelta` overrides the timeout for this call, and `'no_timeout'` disables the timeout entirely. |
11 | 19 | """ |
12 | 20 |
|
| 21 | +WebhooksList = ( |
| 22 | + list[WebhookCreate] |
| 23 | + | list[WebhookCreateDict] |
| 24 | + | list[WebhookCreateCamelDict] |
| 25 | + | list[WebhookRepresentation] |
| 26 | + | list[WebhookRepresentationDict] |
| 27 | + | list[WebhookRepresentationCamelDict] |
| 28 | +) |
| 29 | +"""Type for the `webhooks` parameter on resource-client `start`/`call` methods and `from_webhooks`. |
| 30 | +
|
| 31 | +`WebhookRepresentation` / `WebhookRepresentationDict` / `WebhookRepresentationCamelDict` are the minimal ad-hoc |
| 32 | +webhook shape (only `event_types` and `request_url` required). `WebhookCreate` / `WebhookCreateDict` / |
| 33 | +`WebhookCreateCamelDict` are accepted so a persistent-webhook definition can be reused; their fields not relevant |
| 34 | +to ad-hoc webhooks (e.g. `condition`) are ignored at runtime. The `*CamelDict` variants accept camelCase keys |
| 35 | +matching the Apify API spelling. |
| 36 | +""" |
| 37 | + |
| 38 | +JsonSerializable = dict[str, 'JsonSerializable'] | list['JsonSerializable'] | str | int | float | bool | None |
| 39 | +"""Recursive type for JSON-serializable values - primitives plus objects and arrays with JSON-serializable contents. |
| 40 | +
|
| 41 | +Based on the definition discussed in https://github.com/python/typing/issues/182. |
| 42 | +""" |
| 43 | + |
13 | 44 | __all__ = [ |
| 45 | + 'JsonSerializable', |
14 | 46 | 'Timeout', |
| 47 | + 'WebhooksList', |
15 | 48 | ] |
0 commit comments