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.
- scrapely_client/__init__.py +30 -0
- scrapely_client/_charging.py +186 -0
- scrapely_client/_client_registry.py +136 -0
- scrapely_client/_consts.py +96 -0
- scrapely_client/_docs.py +37 -0
- scrapely_client/_literals.py +539 -0
- scrapely_client/_logging.py +180 -0
- scrapely_client/_models.py +4172 -0
- scrapely_client/_pagination.py +220 -0
- scrapely_client/_resource_clients/__init__.py +84 -0
- scrapely_client/_resource_clients/_resource_client.py +567 -0
- scrapely_client/_resource_clients/actor.py +1042 -0
- scrapely_client/_resource_clients/actor_collection.py +377 -0
- scrapely_client/_resource_clients/actor_env_var.py +154 -0
- scrapely_client/_resource_clients/actor_env_var_collection.py +165 -0
- scrapely_client/_resource_clients/actor_version.py +254 -0
- scrapely_client/_resource_clients/actor_version_collection.py +232 -0
- scrapely_client/_resource_clients/build.py +244 -0
- scrapely_client/_resource_clients/build_collection.py +164 -0
- scrapely_client/_resource_clients/dataset.py +1151 -0
- scrapely_client/_resource_clients/dataset_collection.py +244 -0
- scrapely_client/_resource_clients/key_value_store.py +906 -0
- scrapely_client/_resource_clients/key_value_store_collection.py +243 -0
- scrapely_client/_resource_clients/log.py +225 -0
- scrapely_client/_resource_clients/request_queue.py +1167 -0
- scrapely_client/_resource_clients/request_queue_collection.py +240 -0
- scrapely_client/_resource_clients/run.py +875 -0
- scrapely_client/_resource_clients/run_collection.py +226 -0
- scrapely_client/_resource_clients/schedule.py +243 -0
- scrapely_client/_resource_clients/schedule_collection.py +260 -0
- scrapely_client/_resource_clients/store_collection.py +242 -0
- scrapely_client/_resource_clients/task.py +793 -0
- scrapely_client/_resource_clients/task_collection.py +322 -0
- scrapely_client/_resource_clients/user.py +262 -0
- scrapely_client/_resource_clients/webhook.py +292 -0
- scrapely_client/_resource_clients/webhook_collection.py +281 -0
- scrapely_client/_resource_clients/webhook_dispatch.py +84 -0
- scrapely_client/_resource_clients/webhook_dispatch_collection.py +158 -0
- scrapely_client/_scrapely_client.py +837 -0
- scrapely_client/_statistics.py +29 -0
- scrapely_client/_status_message_watcher.py +197 -0
- scrapely_client/_streamed_log.py +250 -0
- scrapely_client/_typeddicts.py +408 -0
- scrapely_client/_utils/__init__.py +0 -0
- scrapely_client/_utils/crypto.py +87 -0
- scrapely_client/_utils/encoding.py +133 -0
- scrapely_client/_utils/errors.py +33 -0
- scrapely_client/_utils/http.py +137 -0
- scrapely_client/_utils/time.py +32 -0
- scrapely_client/_utils/try_import.py +61 -0
- scrapely_client/errors.py +190 -0
- scrapely_client/http_clients/__init__.py +10 -0
- scrapely_client/http_clients/_base.py +430 -0
- scrapely_client/http_clients/_impit.py +598 -0
- scrapely_client/http_compressors/__init__.py +18 -0
- scrapely_client/http_compressors/_base.py +25 -0
- scrapely_client/http_compressors/_brotli.py +38 -0
- scrapely_client/http_compressors/_gzip.py +38 -0
- scrapely_client/http_compressors/_resolve.py +38 -0
- scrapely_client/py.typed +0 -0
- scrapely_client/types.py +52 -0
- scrapely_client_python-3.1.3.dist-info/METADATA +269 -0
- scrapely_client_python-3.1.3.dist-info/RECORD +65 -0
- scrapely_client_python-3.1.3.dist-info/WHEEL +4 -0
- scrapely_client_python-3.1.3.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,244 @@
|
|
|
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
|
+
Dataset,
|
|
8
|
+
DatasetResponse,
|
|
9
|
+
ListOfDatasets,
|
|
10
|
+
ListOfDatasetsResponse,
|
|
11
|
+
)
|
|
12
|
+
from scrapely_client._pagination import get_items_iterator, get_items_iterator_async
|
|
13
|
+
from scrapely_client._resource_clients._resource_client import ResourceClient, ResourceClientAsync
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from collections.abc import AsyncIterator, Iterator
|
|
17
|
+
|
|
18
|
+
from scrapely_client._literals import StorageOwnership
|
|
19
|
+
from scrapely_client._models import DatasetListItem
|
|
20
|
+
from scrapely_client.types import Timeout
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@docs_group('Resource clients')
|
|
24
|
+
class DatasetCollectionClient(ResourceClient):
|
|
25
|
+
"""Sub-client for the dataset collection.
|
|
26
|
+
|
|
27
|
+
Provides methods to manage the dataset collection, e.g. list or create datasets. Obtain an instance via an
|
|
28
|
+
appropriate method on the `ApifyClient` class.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
*,
|
|
34
|
+
resource_path: str = 'datasets',
|
|
35
|
+
**kwargs: Any,
|
|
36
|
+
) -> None:
|
|
37
|
+
super().__init__(
|
|
38
|
+
resource_path=resource_path,
|
|
39
|
+
**kwargs,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def list(
|
|
43
|
+
self,
|
|
44
|
+
*,
|
|
45
|
+
unnamed: bool | None = None,
|
|
46
|
+
limit: int | None = None,
|
|
47
|
+
offset: int | None = None,
|
|
48
|
+
desc: bool | None = None,
|
|
49
|
+
ownership: StorageOwnership | None = None,
|
|
50
|
+
timeout: Timeout = 'medium',
|
|
51
|
+
) -> ListOfDatasets:
|
|
52
|
+
"""List the available datasets.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
unnamed: Whether to include unnamed datasets in the list.
|
|
57
|
+
limit: How many datasets to retrieve.
|
|
58
|
+
offset: What dataset to include as first when retrieving the list.
|
|
59
|
+
desc: Whether to sort the datasets in descending order based on their modification date.
|
|
60
|
+
ownership: Filter by ownership. `'ownedByMe'` returns only user's own datasets,
|
|
61
|
+
`'sharedWithMe'` returns only datasets shared with the user.
|
|
62
|
+
timeout: Timeout for the API HTTP request.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
The list of available datasets matching the specified filters.
|
|
66
|
+
"""
|
|
67
|
+
result = self._list(
|
|
68
|
+
timeout=timeout,
|
|
69
|
+
unnamed=unnamed,
|
|
70
|
+
limit=limit,
|
|
71
|
+
offset=offset,
|
|
72
|
+
desc=desc,
|
|
73
|
+
ownership=ownership,
|
|
74
|
+
)
|
|
75
|
+
return ListOfDatasetsResponse.model_validate(result).data
|
|
76
|
+
|
|
77
|
+
def iterate(
|
|
78
|
+
self,
|
|
79
|
+
*,
|
|
80
|
+
unnamed: bool | None = None,
|
|
81
|
+
limit: int | None = None,
|
|
82
|
+
offset: int | None = None,
|
|
83
|
+
desc: bool | None = None,
|
|
84
|
+
ownership: StorageOwnership | None = None,
|
|
85
|
+
timeout: Timeout = 'medium',
|
|
86
|
+
) -> Iterator[DatasetListItem]:
|
|
87
|
+
"""Iterate over the available datasets.
|
|
88
|
+
|
|
89
|
+
Simple `list` does only one API call, possibly not listing all items matching the criteria. This method
|
|
90
|
+
returns an iterator that is capable of making multiple API calls to retrieve all items matching the criteria.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
unnamed: Whether to include unnamed datasets in the list.
|
|
95
|
+
limit: How many datasets to retrieve.
|
|
96
|
+
offset: What dataset to include as first when retrieving the list.
|
|
97
|
+
desc: Whether to sort the datasets in descending order based on their modification date.
|
|
98
|
+
ownership: Filter by ownership. 'ownedByMe' returns only user's own datasets,
|
|
99
|
+
'sharedWithMe' returns only datasets shared with the user.
|
|
100
|
+
timeout: Timeout for the API HTTP request.
|
|
101
|
+
|
|
102
|
+
Yields:
|
|
103
|
+
The available datasets matching the specified filters.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
def _callback(*, limit: int | None = None, offset: int | None = None) -> ListOfDatasets:
|
|
107
|
+
return self.list(
|
|
108
|
+
unnamed=unnamed, limit=limit, offset=offset, desc=desc, ownership=ownership, timeout=timeout
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
return get_items_iterator(_callback, limit=limit, offset=offset)
|
|
112
|
+
|
|
113
|
+
def get_or_create(
|
|
114
|
+
self,
|
|
115
|
+
*,
|
|
116
|
+
name: str | None = None,
|
|
117
|
+
schema: dict | None = None,
|
|
118
|
+
timeout: Timeout = 'short',
|
|
119
|
+
) -> Dataset:
|
|
120
|
+
"""Retrieve a named dataset, or create a new one when it doesn't exist.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
name: The name of the dataset to retrieve or create.
|
|
125
|
+
schema: The schema of the dataset.
|
|
126
|
+
timeout: Timeout for the API HTTP request.
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
The retrieved or newly-created dataset.
|
|
130
|
+
"""
|
|
131
|
+
result = self._get_or_create(timeout=timeout, name=name, resource_fields={'schema': schema})
|
|
132
|
+
return DatasetResponse.model_validate(result).data
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@docs_group('Resource clients')
|
|
136
|
+
class DatasetCollectionClientAsync(ResourceClientAsync):
|
|
137
|
+
"""Sub-client for the dataset collection.
|
|
138
|
+
|
|
139
|
+
Provides methods to manage the dataset collection, e.g. list or create datasets. Obtain an instance via an
|
|
140
|
+
appropriate method on the `ApifyClientAsync` class.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
def __init__(
|
|
144
|
+
self,
|
|
145
|
+
*,
|
|
146
|
+
resource_path: str = 'datasets',
|
|
147
|
+
**kwargs: Any,
|
|
148
|
+
) -> None:
|
|
149
|
+
super().__init__(
|
|
150
|
+
resource_path=resource_path,
|
|
151
|
+
**kwargs,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
async def list(
|
|
155
|
+
self,
|
|
156
|
+
*,
|
|
157
|
+
unnamed: bool | None = None,
|
|
158
|
+
limit: int | None = None,
|
|
159
|
+
offset: int | None = None,
|
|
160
|
+
desc: bool | None = None,
|
|
161
|
+
ownership: StorageOwnership | None = None,
|
|
162
|
+
timeout: Timeout = 'medium',
|
|
163
|
+
) -> ListOfDatasets:
|
|
164
|
+
"""List the available datasets.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
unnamed: Whether to include unnamed datasets in the list.
|
|
169
|
+
limit: How many datasets to retrieve.
|
|
170
|
+
offset: What dataset to include as first when retrieving the list.
|
|
171
|
+
desc: Whether to sort the datasets in descending order based on their modification date.
|
|
172
|
+
ownership: Filter by ownership. `'ownedByMe'` returns only user's own datasets,
|
|
173
|
+
`'sharedWithMe'` returns only datasets shared with the user.
|
|
174
|
+
timeout: Timeout for the API HTTP request.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
The list of available datasets matching the specified filters.
|
|
178
|
+
"""
|
|
179
|
+
result = await self._list(
|
|
180
|
+
timeout=timeout,
|
|
181
|
+
unnamed=unnamed,
|
|
182
|
+
limit=limit,
|
|
183
|
+
offset=offset,
|
|
184
|
+
desc=desc,
|
|
185
|
+
ownership=ownership,
|
|
186
|
+
)
|
|
187
|
+
return ListOfDatasetsResponse.model_validate(result).data
|
|
188
|
+
|
|
189
|
+
def iterate(
|
|
190
|
+
self,
|
|
191
|
+
*,
|
|
192
|
+
unnamed: bool | None = None,
|
|
193
|
+
limit: int | None = None,
|
|
194
|
+
offset: int | None = None,
|
|
195
|
+
desc: bool | None = None,
|
|
196
|
+
ownership: StorageOwnership | None = None,
|
|
197
|
+
timeout: Timeout = 'medium',
|
|
198
|
+
) -> AsyncIterator[DatasetListItem]:
|
|
199
|
+
"""Iterate over the available datasets.
|
|
200
|
+
|
|
201
|
+
Simple `list` does only one API call, possibly not listing all items matching the criteria. This method
|
|
202
|
+
returns an iterator that is capable of making multiple API calls to retrieve all items matching the criteria.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
unnamed: Whether to include unnamed datasets in the list.
|
|
207
|
+
limit: How many datasets to retrieve.
|
|
208
|
+
offset: What dataset to include as first when retrieving the list.
|
|
209
|
+
desc: Whether to sort the datasets in descending order based on their modification date.
|
|
210
|
+
ownership: Filter by ownership. 'ownedByMe' returns only user's own datasets,
|
|
211
|
+
'sharedWithMe' returns only datasets shared with the user.
|
|
212
|
+
timeout: Timeout for the API HTTP request.
|
|
213
|
+
|
|
214
|
+
Yields:
|
|
215
|
+
The available datasets matching the specified filters.
|
|
216
|
+
"""
|
|
217
|
+
|
|
218
|
+
async def _callback(*, limit: int | None = None, offset: int | None = None) -> ListOfDatasets:
|
|
219
|
+
return await self.list(
|
|
220
|
+
unnamed=unnamed, limit=limit, offset=offset, desc=desc, ownership=ownership, timeout=timeout
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
return get_items_iterator_async(_callback, limit=limit, offset=offset)
|
|
224
|
+
|
|
225
|
+
async def get_or_create(
|
|
226
|
+
self,
|
|
227
|
+
*,
|
|
228
|
+
name: str | None = None,
|
|
229
|
+
schema: dict | None = None,
|
|
230
|
+
timeout: Timeout = 'short',
|
|
231
|
+
) -> Dataset:
|
|
232
|
+
"""Retrieve a named dataset, or create a new one when it doesn't exist.
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
name: The name of the dataset to retrieve or create.
|
|
237
|
+
schema: The schema of the dataset.
|
|
238
|
+
timeout: Timeout for the API HTTP request.
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
The retrieved or newly-created dataset.
|
|
242
|
+
"""
|
|
243
|
+
result = await self._get_or_create(timeout=timeout, name=name, resource_fields={'schema': schema})
|
|
244
|
+
return DatasetResponse.model_validate(result).data
|