scrapely-client-python 3.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of scrapely-client-python might be problematic. Click here for more details.

Files changed (65) hide show
  1. scrapely_client/__init__.py +30 -0
  2. scrapely_client/_charging.py +186 -0
  3. scrapely_client/_client_registry.py +136 -0
  4. scrapely_client/_consts.py +96 -0
  5. scrapely_client/_docs.py +37 -0
  6. scrapely_client/_literals.py +539 -0
  7. scrapely_client/_logging.py +180 -0
  8. scrapely_client/_models.py +4172 -0
  9. scrapely_client/_pagination.py +220 -0
  10. scrapely_client/_resource_clients/__init__.py +84 -0
  11. scrapely_client/_resource_clients/_resource_client.py +567 -0
  12. scrapely_client/_resource_clients/actor.py +1042 -0
  13. scrapely_client/_resource_clients/actor_collection.py +377 -0
  14. scrapely_client/_resource_clients/actor_env_var.py +154 -0
  15. scrapely_client/_resource_clients/actor_env_var_collection.py +165 -0
  16. scrapely_client/_resource_clients/actor_version.py +254 -0
  17. scrapely_client/_resource_clients/actor_version_collection.py +232 -0
  18. scrapely_client/_resource_clients/build.py +244 -0
  19. scrapely_client/_resource_clients/build_collection.py +164 -0
  20. scrapely_client/_resource_clients/dataset.py +1151 -0
  21. scrapely_client/_resource_clients/dataset_collection.py +244 -0
  22. scrapely_client/_resource_clients/key_value_store.py +906 -0
  23. scrapely_client/_resource_clients/key_value_store_collection.py +243 -0
  24. scrapely_client/_resource_clients/log.py +225 -0
  25. scrapely_client/_resource_clients/request_queue.py +1167 -0
  26. scrapely_client/_resource_clients/request_queue_collection.py +240 -0
  27. scrapely_client/_resource_clients/run.py +875 -0
  28. scrapely_client/_resource_clients/run_collection.py +226 -0
  29. scrapely_client/_resource_clients/schedule.py +243 -0
  30. scrapely_client/_resource_clients/schedule_collection.py +260 -0
  31. scrapely_client/_resource_clients/store_collection.py +242 -0
  32. scrapely_client/_resource_clients/task.py +793 -0
  33. scrapely_client/_resource_clients/task_collection.py +322 -0
  34. scrapely_client/_resource_clients/user.py +262 -0
  35. scrapely_client/_resource_clients/webhook.py +292 -0
  36. scrapely_client/_resource_clients/webhook_collection.py +281 -0
  37. scrapely_client/_resource_clients/webhook_dispatch.py +84 -0
  38. scrapely_client/_resource_clients/webhook_dispatch_collection.py +158 -0
  39. scrapely_client/_scrapely_client.py +837 -0
  40. scrapely_client/_statistics.py +29 -0
  41. scrapely_client/_status_message_watcher.py +197 -0
  42. scrapely_client/_streamed_log.py +250 -0
  43. scrapely_client/_typeddicts.py +408 -0
  44. scrapely_client/_utils/__init__.py +0 -0
  45. scrapely_client/_utils/crypto.py +87 -0
  46. scrapely_client/_utils/encoding.py +133 -0
  47. scrapely_client/_utils/errors.py +33 -0
  48. scrapely_client/_utils/http.py +137 -0
  49. scrapely_client/_utils/time.py +32 -0
  50. scrapely_client/_utils/try_import.py +61 -0
  51. scrapely_client/errors.py +190 -0
  52. scrapely_client/http_clients/__init__.py +10 -0
  53. scrapely_client/http_clients/_base.py +430 -0
  54. scrapely_client/http_clients/_impit.py +598 -0
  55. scrapely_client/http_compressors/__init__.py +18 -0
  56. scrapely_client/http_compressors/_base.py +25 -0
  57. scrapely_client/http_compressors/_brotli.py +38 -0
  58. scrapely_client/http_compressors/_gzip.py +38 -0
  59. scrapely_client/http_compressors/_resolve.py +38 -0
  60. scrapely_client/py.typed +0 -0
  61. scrapely_client/types.py +52 -0
  62. scrapely_client_python-3.1.3.dist-info/METADATA +269 -0
  63. scrapely_client_python-3.1.3.dist-info/RECORD +65 -0
  64. scrapely_client_python-3.1.3.dist-info/WHEEL +4 -0
  65. scrapely_client_python-3.1.3.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,260 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any
4
+
5
+ from scrapely_client._docs import docs_group
6
+ from scrapely_client._models import (
7
+ ListOfSchedules,
8
+ ListOfSchedulesResponse,
9
+ Schedule,
10
+ ScheduleCreate,
11
+ ScheduleResponse,
12
+ )
13
+ from scrapely_client._pagination import get_items_iterator, get_items_iterator_async
14
+ from scrapely_client._resource_clients._resource_client import ResourceClient, ResourceClientAsync
15
+
16
+ if TYPE_CHECKING:
17
+ from collections.abc import AsyncIterator, Iterator
18
+
19
+ from scrapely_client._models import ScheduleShort
20
+ from scrapely_client.types import Timeout
21
+
22
+
23
+ @docs_group('Resource clients')
24
+ class ScheduleCollectionClient(ResourceClient):
25
+ """Sub-client for the schedule collection.
26
+
27
+ Provides methods to manage the schedule collection, e.g. list or create schedules. Obtain an instance via an
28
+ appropriate method on the `ApifyClient` class.
29
+ """
30
+
31
+ def __init__(
32
+ self,
33
+ *,
34
+ resource_path: str = 'schedules',
35
+ **kwargs: Any,
36
+ ) -> None:
37
+ super().__init__(
38
+ resource_path=resource_path,
39
+ **kwargs,
40
+ )
41
+
42
+ def list(
43
+ self,
44
+ *,
45
+ limit: int | None = None,
46
+ offset: int | None = None,
47
+ desc: bool | None = None,
48
+ timeout: Timeout = 'medium',
49
+ ) -> ListOfSchedules:
50
+ """List the available schedules.
51
+
52
+
53
+ Args:
54
+ limit: How many schedules to retrieve.
55
+ offset: What schedules to include as first when retrieving the list.
56
+ desc: Whether to sort the schedules in descending order based on their modification date.
57
+ timeout: Timeout for the API HTTP request.
58
+
59
+ Returns:
60
+ The list of available schedules matching the specified filters.
61
+ """
62
+ result = self._list(timeout=timeout, limit=limit, offset=offset, desc=desc)
63
+ return ListOfSchedulesResponse.model_validate(result).data
64
+
65
+ def iterate(
66
+ self,
67
+ *,
68
+ limit: int | None = None,
69
+ offset: int | None = None,
70
+ desc: bool | None = None,
71
+ timeout: Timeout = 'medium',
72
+ ) -> Iterator[ScheduleShort]:
73
+ """Iterate over the available schedules.
74
+
75
+ Simple `list` does only one API call, possibly not listing all items matching the criteria. This method
76
+ returns an iterator that is capable of making multiple API calls to retrieve all items matching the criteria.
77
+
78
+
79
+ Args:
80
+ limit: How many schedules to retrieve.
81
+ offset: What schedules to include as first when retrieving the list.
82
+ desc: Whether to sort the schedules in descending order based on their modification date.
83
+ timeout: Timeout for the API HTTP request.
84
+
85
+ Yields:
86
+ The available schedules matching the specified filters.
87
+ """
88
+
89
+ def _callback(*, limit: int | None = None, offset: int | None = None) -> ListOfSchedules:
90
+ return self.list(limit=limit, offset=offset, desc=desc, timeout=timeout)
91
+
92
+ return get_items_iterator(_callback, limit=limit, offset=offset)
93
+
94
+ def create(
95
+ self,
96
+ *,
97
+ cron_expression: str,
98
+ is_enabled: bool,
99
+ is_exclusive: bool,
100
+ name: str | None = None,
101
+ actions: list[dict[str, Any]] | None = None, # ty: ignore[invalid-type-form]
102
+ description: str | None = None,
103
+ timezone: str | None = None,
104
+ title: str | None = None,
105
+ timeout: Timeout = 'short',
106
+ ) -> Schedule:
107
+ """Create a new schedule.
108
+
109
+
110
+ Args:
111
+ cron_expression: The cron expression used by this schedule.
112
+ is_enabled: True if the schedule should be enabled.
113
+ is_exclusive: When set to true, don't start Actor or Actor task if it's still running from the previous
114
+ schedule.
115
+ name: The name of the schedule to create.
116
+ actions: Actors or tasks that should be run on this schedule. See the API documentation for exact structure.
117
+ description: Description of this schedule.
118
+ timezone: Timezone in which your cron expression runs (TZ database name from
119
+ https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
120
+ title: Title of this schedule.
121
+ timeout: Timeout for the API HTTP request.
122
+
123
+ Returns:
124
+ The created schedule.
125
+ """
126
+ if not actions:
127
+ actions = []
128
+
129
+ schedule_fields = ScheduleCreate(
130
+ cron_expression=cron_expression,
131
+ is_enabled=is_enabled,
132
+ is_exclusive=is_exclusive,
133
+ name=name,
134
+ actions=actions or None,
135
+ description=description,
136
+ timezone=timezone,
137
+ title=title,
138
+ )
139
+ result = self._create(timeout=timeout, **schedule_fields.model_dump(by_alias=True, exclude_none=True))
140
+ return ScheduleResponse.model_validate(result).data
141
+
142
+
143
+ @docs_group('Resource clients')
144
+ class ScheduleCollectionClientAsync(ResourceClientAsync):
145
+ """Sub-client for the schedule collection.
146
+
147
+ Provides methods to manage the schedule collection, e.g. list or create schedules. Obtain an instance via an
148
+ appropriate method on the `ApifyClientAsync` class.
149
+ """
150
+
151
+ def __init__(
152
+ self,
153
+ *,
154
+ resource_path: str = 'schedules',
155
+ **kwargs: Any,
156
+ ) -> None:
157
+ super().__init__(
158
+ resource_path=resource_path,
159
+ **kwargs,
160
+ )
161
+
162
+ async def list(
163
+ self,
164
+ *,
165
+ limit: int | None = None,
166
+ offset: int | None = None,
167
+ desc: bool | None = None,
168
+ timeout: Timeout = 'medium',
169
+ ) -> ListOfSchedules:
170
+ """List the available schedules.
171
+
172
+
173
+ Args:
174
+ limit: How many schedules to retrieve.
175
+ offset: What schedules to include as first when retrieving the list.
176
+ desc: Whether to sort the schedules in descending order based on their modification date.
177
+ timeout: Timeout for the API HTTP request.
178
+
179
+ Returns:
180
+ The list of available schedules matching the specified filters.
181
+ """
182
+ result = await self._list(timeout=timeout, limit=limit, offset=offset, desc=desc)
183
+ return ListOfSchedulesResponse.model_validate(result).data
184
+
185
+ def iterate(
186
+ self,
187
+ *,
188
+ limit: int | None = None,
189
+ offset: int | None = None,
190
+ desc: bool | None = None,
191
+ timeout: Timeout = 'medium',
192
+ ) -> AsyncIterator[ScheduleShort]:
193
+ """Iterate over the available schedules.
194
+
195
+ Simple `list` does only one API call, possibly not listing all items matching the criteria. This method
196
+ returns an iterator that is capable of making multiple API calls to retrieve all items matching the criteria.
197
+
198
+
199
+ Args:
200
+ limit: How many schedules to retrieve.
201
+ offset: What schedules to include as first when retrieving the list.
202
+ desc: Whether to sort the schedules in descending order based on their modification date.
203
+ timeout: Timeout for the API HTTP request.
204
+
205
+ Yields:
206
+ The available schedules matching the specified filters.
207
+ """
208
+
209
+ async def _callback(*, limit: int | None = None, offset: int | None = None) -> ListOfSchedules:
210
+ return await self.list(limit=limit, offset=offset, desc=desc, timeout=timeout)
211
+
212
+ return get_items_iterator_async(_callback, limit=limit, offset=offset)
213
+
214
+ async def create(
215
+ self,
216
+ *,
217
+ cron_expression: str,
218
+ is_enabled: bool,
219
+ is_exclusive: bool,
220
+ name: str | None = None,
221
+ actions: list[dict[str, Any]] | None = None, # ty: ignore[invalid-type-form]
222
+ description: str | None = None,
223
+ timezone: str | None = None,
224
+ title: str | None = None,
225
+ timeout: Timeout = 'short',
226
+ ) -> Schedule:
227
+ """Create a new schedule.
228
+
229
+
230
+ Args:
231
+ cron_expression: The cron expression used by this schedule.
232
+ is_enabled: True if the schedule should be enabled.
233
+ is_exclusive: When set to true, don't start Actor or Actor task if it's still running from the previous
234
+ schedule.
235
+ name: The name of the schedule to create.
236
+ actions: Actors or tasks that should be run on this schedule. See the API documentation for exact structure.
237
+ description: Description of this schedule.
238
+ timezone: Timezone in which your cron expression runs (TZ database name from
239
+ https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
240
+ title: Title of this schedule.
241
+ timeout: Timeout for the API HTTP request.
242
+
243
+ Returns:
244
+ The created schedule.
245
+ """
246
+ if not actions:
247
+ actions = []
248
+
249
+ schedule_fields = ScheduleCreate(
250
+ cron_expression=cron_expression,
251
+ is_enabled=is_enabled,
252
+ is_exclusive=is_exclusive,
253
+ name=name,
254
+ actions=actions or None,
255
+ description=description,
256
+ timezone=timezone,
257
+ title=title,
258
+ )
259
+ result = await self._create(timeout=timeout, **schedule_fields.model_dump(by_alias=True, exclude_none=True))
260
+ return ScheduleResponse.model_validate(result).data
@@ -0,0 +1,242 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any
4
+
5
+ from scrapely_client._docs import docs_group
6
+ from scrapely_client._models import ListOfActorsInStoreResponse, ListOfStoreActors
7
+ from scrapely_client._pagination import get_items_iterator, get_items_iterator_async
8
+ from scrapely_client._resource_clients._resource_client import ResourceClient, ResourceClientAsync
9
+
10
+ if TYPE_CHECKING:
11
+ from collections.abc import AsyncIterator, Iterator
12
+
13
+ from scrapely_client._models import StoreListActor
14
+ from scrapely_client.types import Timeout
15
+
16
+
17
+ @docs_group('Resource clients')
18
+ class StoreCollectionClient(ResourceClient):
19
+ """Sub-client for the Scrapely store collection.
20
+
21
+ Provides methods to browse the Scrapely store, e.g. list available Actors. Obtain an instance via an appropriate
22
+ method on the `ApifyClient` class.
23
+ """
24
+
25
+ def __init__(
26
+ self,
27
+ *,
28
+ resource_path: str = 'store/actors', # Scrapely mounts the store listing at /v2/store/actors
29
+ **kwargs: Any,
30
+ ) -> None:
31
+ super().__init__(
32
+ resource_path=resource_path,
33
+ **kwargs,
34
+ )
35
+
36
+ def list(
37
+ self,
38
+ *,
39
+ limit: int | None = None,
40
+ offset: int | None = None,
41
+ search: str | None = None,
42
+ sort_by: str | None = None,
43
+ category: str | None = None,
44
+ username: str | None = None,
45
+ pricing_model: str | None = None,
46
+ include_unrunnable_actors: bool | None = None,
47
+ timeout: Timeout = 'medium',
48
+ ) -> ListOfStoreActors:
49
+ """List Actors in Scrapely store.
50
+
51
+
52
+ Args:
53
+ limit: How many Actors to list.
54
+ offset: What Actor to include as first when retrieving the list.
55
+ search: String to search by. The search runs on the following fields: title, name, description, username,
56
+ readme.
57
+ sort_by: Specifies the field by which to sort the results.
58
+ category: Filter by this category.
59
+ username: Filter by this username.
60
+ pricing_model: Filter by this pricing model.
61
+ include_unrunnable_actors: If True, the response will include Actors that cannot be run.
62
+ timeout: Timeout for the API HTTP request.
63
+
64
+ Returns:
65
+ The list of available Actors matching the specified filters.
66
+ """
67
+ result = self._list(
68
+ timeout=timeout,
69
+ limit=limit,
70
+ offset=offset,
71
+ search=search,
72
+ sortBy=sort_by,
73
+ category=category,
74
+ username=username,
75
+ pricingModel=pricing_model,
76
+ includeUnrunnableActors=include_unrunnable_actors,
77
+ )
78
+ return ListOfActorsInStoreResponse.model_validate(result).data
79
+
80
+ def iterate(
81
+ self,
82
+ *,
83
+ limit: int | None = None,
84
+ offset: int | None = None,
85
+ search: str | None = None,
86
+ sort_by: str | None = None,
87
+ category: str | None = None,
88
+ username: str | None = None,
89
+ pricing_model: str | None = None,
90
+ include_unrunnable_actors: bool | None = None,
91
+ timeout: Timeout = 'medium',
92
+ ) -> Iterator[StoreListActor]:
93
+ """Iterate over Actors in Scrapely store.
94
+
95
+ Simple `list` does only one API call, possibly not listing all items matching the criteria. This method
96
+ returns an iterator that is capable of making multiple API calls to retrieve all items matching the criteria.
97
+
98
+
99
+ Args:
100
+ limit: How many Actors to list.
101
+ offset: What Actor to include as first when retrieving the list.
102
+ search: String to search by. The search runs on the following fields: title, name, description, username,
103
+ readme.
104
+ sort_by: Specifies the field by which to sort the results.
105
+ category: Filter by this category.
106
+ username: Filter by this username.
107
+ pricing_model: Filter by this pricing model.
108
+ include_unrunnable_actors: If True, the response will include Actors that cannot be run.
109
+ timeout: Timeout for the API HTTP request.
110
+
111
+ Yields:
112
+ The Actors in the store matching the specified filters.
113
+ """
114
+
115
+ def _callback(*, limit: int | None = None, offset: int | None = None) -> ListOfStoreActors:
116
+ return self.list(
117
+ limit=limit,
118
+ offset=offset,
119
+ search=search,
120
+ sort_by=sort_by,
121
+ category=category,
122
+ username=username,
123
+ pricing_model=pricing_model,
124
+ include_unrunnable_actors=include_unrunnable_actors,
125
+ timeout=timeout,
126
+ )
127
+
128
+ return get_items_iterator(_callback, limit=limit, offset=offset)
129
+
130
+
131
+ @docs_group('Resource clients')
132
+ class StoreCollectionClientAsync(ResourceClientAsync):
133
+ """Sub-client for the Scrapely store collection.
134
+
135
+ Provides methods to browse the Scrapely store, e.g. list available Actors. Obtain an instance via an appropriate
136
+ method on the `ApifyClientAsync` class.
137
+ """
138
+
139
+ def __init__(
140
+ self,
141
+ *,
142
+ resource_path: str = 'store/actors', # Scrapely mounts the store listing at /v2/store/actors
143
+ **kwargs: Any,
144
+ ) -> None:
145
+ super().__init__(
146
+ resource_path=resource_path,
147
+ **kwargs,
148
+ )
149
+
150
+ async def list(
151
+ self,
152
+ *,
153
+ limit: int | None = None,
154
+ offset: int | None = None,
155
+ search: str | None = None,
156
+ sort_by: str | None = None,
157
+ category: str | None = None,
158
+ username: str | None = None,
159
+ pricing_model: str | None = None,
160
+ include_unrunnable_actors: bool | None = None,
161
+ timeout: Timeout = 'medium',
162
+ ) -> ListOfStoreActors:
163
+ """List Actors in Scrapely store.
164
+
165
+
166
+ Args:
167
+ limit: How many Actors to list.
168
+ offset: What Actor to include as first when retrieving the list.
169
+ search: String to search by. The search runs on the following fields: title, name, description, username,
170
+ readme.
171
+ sort_by: Specifies the field by which to sort the results.
172
+ category: Filter by this category.
173
+ username: Filter by this username.
174
+ pricing_model: Filter by this pricing model.
175
+ include_unrunnable_actors: If True, the response will include Actors that cannot be run.
176
+ timeout: Timeout for the API HTTP request.
177
+
178
+ Returns:
179
+ The list of available Actors matching the specified filters.
180
+ """
181
+ result = await self._list(
182
+ timeout=timeout,
183
+ limit=limit,
184
+ offset=offset,
185
+ search=search,
186
+ sortBy=sort_by,
187
+ category=category,
188
+ username=username,
189
+ pricingModel=pricing_model,
190
+ includeUnrunnableActors=include_unrunnable_actors,
191
+ )
192
+ return ListOfActorsInStoreResponse.model_validate(result).data
193
+
194
+ def iterate(
195
+ self,
196
+ *,
197
+ limit: int | None = None,
198
+ offset: int | None = None,
199
+ search: str | None = None,
200
+ sort_by: str | None = None,
201
+ category: str | None = None,
202
+ username: str | None = None,
203
+ pricing_model: str | None = None,
204
+ include_unrunnable_actors: bool | None = None,
205
+ timeout: Timeout = 'medium',
206
+ ) -> AsyncIterator[StoreListActor]:
207
+ """Iterate over Actors in Scrapely store.
208
+
209
+ Simple `list` does only one API call, possibly not listing all items matching the criteria. This method
210
+ returns an iterator that is capable of making multiple API calls to retrieve all items matching the criteria.
211
+
212
+
213
+ Args:
214
+ limit: How many Actors to list.
215
+ offset: What Actor to include as first when retrieving the list.
216
+ search: String to search by. The search runs on the following fields: title, name, description, username,
217
+ readme.
218
+ sort_by: Specifies the field by which to sort the results.
219
+ category: Filter by this category.
220
+ username: Filter by this username.
221
+ pricing_model: Filter by this pricing model.
222
+ include_unrunnable_actors: If True, the response will include Actors that cannot be run.
223
+ timeout: Timeout for the API HTTP request.
224
+
225
+ Yields:
226
+ The Actors in the store matching the specified filters.
227
+ """
228
+
229
+ async def _callback(*, limit: int | None = None, offset: int | None = None) -> ListOfStoreActors:
230
+ return await self.list(
231
+ limit=limit,
232
+ offset=offset,
233
+ search=search,
234
+ sort_by=sort_by,
235
+ category=category,
236
+ username=username,
237
+ pricing_model=pricing_model,
238
+ include_unrunnable_actors=include_unrunnable_actors,
239
+ timeout=timeout,
240
+ )
241
+
242
+ return get_items_iterator_async(_callback, limit=limit, offset=offset)