cryptascreen 0.2.0__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.
- cryptascreen/__init__.py +61 -0
- cryptascreen/_util.py +111 -0
- cryptascreen/_version.py +3 -0
- cryptascreen/client.py +231 -0
- cryptascreen/config.py +48 -0
- cryptascreen/errors.py +217 -0
- cryptascreen/helpers.py +47 -0
- cryptascreen/operations.py +131 -0
- cryptascreen/resources/__init__.py +1 -0
- cryptascreen/resources/alerts.py +51 -0
- cryptascreen/resources/auth.py +36 -0
- cryptascreen/resources/capabilities.py +36 -0
- cryptascreen/resources/cases.py +198 -0
- cryptascreen/resources/compliance.py +116 -0
- cryptascreen/resources/graph.py +70 -0
- cryptascreen/resources/intelligence.py +69 -0
- cryptascreen/resources/monitoring.py +142 -0
- cryptascreen/resources/names.py +97 -0
- cryptascreen/resources/sanctions.py +50 -0
- cryptascreen/resources/screening.py +379 -0
- cryptascreen/resources/settings.py +115 -0
- cryptascreen/resources/webhooks.py +55 -0
- cryptascreen/retry.py +176 -0
- cryptascreen/signature.py +118 -0
- cryptascreen/types/__init__.py +313 -0
- cryptascreen/types/_account.py +199 -0
- cryptascreen/types/_models.py +1620 -0
- cryptascreen/types/cases.py +31 -0
- cryptascreen/types/common.py +17 -0
- cryptascreen/types/compliance.py +27 -0
- cryptascreen/types/graph.py +25 -0
- cryptascreen/types/intelligence.py +11 -0
- cryptascreen/types/names.py +39 -0
- cryptascreen/types/sanctions.py +13 -0
- cryptascreen/types/screening.py +73 -0
- cryptascreen/types/wallet.py +85 -0
- cryptascreen/types/webhooks.py +13 -0
- cryptascreen-0.2.0.dist-info/METADATA +305 -0
- cryptascreen-0.2.0.dist-info/RECORD +41 -0
- cryptascreen-0.2.0.dist-info/WHEEL +4 -0
- cryptascreen-0.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"""Screening resource (mirrors @cryptascreen/sdk screening endpoints)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import time
|
|
7
|
+
from typing import TYPE_CHECKING, Any
|
|
8
|
+
|
|
9
|
+
from cryptascreen._util import (
|
|
10
|
+
_body,
|
|
11
|
+
_enc,
|
|
12
|
+
_normalise_job_results,
|
|
13
|
+
_query,
|
|
14
|
+
_require_chain,
|
|
15
|
+
_require_chains,
|
|
16
|
+
generate_idempotency_key,
|
|
17
|
+
is_terminal_job_status,
|
|
18
|
+
)
|
|
19
|
+
from cryptascreen.types._models import (
|
|
20
|
+
BulkScreeningRequest,
|
|
21
|
+
ScreenAddressRequest,
|
|
22
|
+
ScreeningEvaluation,
|
|
23
|
+
ScreeningEvaluationPage,
|
|
24
|
+
ScreeningJob,
|
|
25
|
+
ScreeningJobResultsPage,
|
|
26
|
+
ScreeningResponse,
|
|
27
|
+
WalletCounterpartyPage,
|
|
28
|
+
WalletExposurePaths,
|
|
29
|
+
WalletTransactionPage,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from cryptascreen.client import AsyncHttpClient, HttpClient
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class ScreeningResource:
|
|
37
|
+
"""Synchronous screening operations. Access via ``client.screening``."""
|
|
38
|
+
|
|
39
|
+
def __init__(self, http: HttpClient) -> None:
|
|
40
|
+
self._http = http
|
|
41
|
+
|
|
42
|
+
def screen_address(self, request: ScreenAddressRequest | dict[str, Any]) -> ScreeningResponse:
|
|
43
|
+
"""POST /screen/address"""
|
|
44
|
+
data = self._http.request(
|
|
45
|
+
"POST", "/api/v1/screen/address", json=_require_chain(_body(request))
|
|
46
|
+
)
|
|
47
|
+
return ScreeningResponse.model_validate(data)
|
|
48
|
+
|
|
49
|
+
def screen_bulk(
|
|
50
|
+
self, request: BulkScreeningRequest | dict[str, Any]
|
|
51
|
+
) -> list[ScreeningResponse]:
|
|
52
|
+
"""Screen multiple addresses synchronously (max 1000). ``async`` is forced to False."""
|
|
53
|
+
data = self._http.request(
|
|
54
|
+
"POST", "/api/v1/screen/bulk", json={**_require_chains(_body(request)), "async": False}
|
|
55
|
+
)
|
|
56
|
+
return [ScreeningResponse.model_validate(x) for x in data]
|
|
57
|
+
|
|
58
|
+
def screen_bulk_async(
|
|
59
|
+
self, request: BulkScreeningRequest | dict[str, Any], *, idempotency_key: str | None = None
|
|
60
|
+
) -> ScreeningJob:
|
|
61
|
+
"""Submit a bulk screening job (max 10000). ``async`` is forced to True; an Idempotency-Key header is always sent."""
|
|
62
|
+
headers = {"Idempotency-Key": idempotency_key or generate_idempotency_key()}
|
|
63
|
+
data = self._http.request(
|
|
64
|
+
"POST",
|
|
65
|
+
"/api/v1/screen/bulk",
|
|
66
|
+
json={**_require_chains(_body(request)), "async": True},
|
|
67
|
+
headers=headers,
|
|
68
|
+
)
|
|
69
|
+
return ScreeningJob.model_validate(data)
|
|
70
|
+
|
|
71
|
+
def poll_job(self, job_id: str) -> ScreeningJob:
|
|
72
|
+
"""GET /screen/jobs/{jobId}"""
|
|
73
|
+
data = self._http.request("GET", f"/api/v1/screen/jobs/{_enc(job_id)}")
|
|
74
|
+
return ScreeningJob.model_validate(data)
|
|
75
|
+
|
|
76
|
+
def list_jobs(self) -> list[ScreeningJob]:
|
|
77
|
+
"""GET /screen/jobs"""
|
|
78
|
+
data = self._http.request("GET", "/api/v1/screen/jobs")
|
|
79
|
+
return [ScreeningJob.model_validate(x) for x in data]
|
|
80
|
+
|
|
81
|
+
def get_job_results(
|
|
82
|
+
self, job_id: str, *, page: int = 0, size: int = 100
|
|
83
|
+
) -> ScreeningJobResultsPage:
|
|
84
|
+
"""One page (0-based, size 1..1000) of a job's stored per-address items."""
|
|
85
|
+
data = self._http.request(
|
|
86
|
+
"GET",
|
|
87
|
+
f"/api/v1/screen/jobs/{_enc(job_id)}/results",
|
|
88
|
+
params={"page": page, "size": size},
|
|
89
|
+
)
|
|
90
|
+
return _normalise_job_results(data, job_id, page, size)
|
|
91
|
+
|
|
92
|
+
def cancel_job(self, job_id: str) -> ScreeningJob:
|
|
93
|
+
"""POST /screen/jobs/{jobId}/cancel"""
|
|
94
|
+
data = self._http.request("POST", f"/api/v1/screen/jobs/{_enc(job_id)}/cancel")
|
|
95
|
+
return ScreeningJob.model_validate(data)
|
|
96
|
+
|
|
97
|
+
def get_history(self, chain: str, address: str) -> ScreeningResponse:
|
|
98
|
+
"""GET /screen/address/{chain}/{address}/history"""
|
|
99
|
+
data = self._http.request(
|
|
100
|
+
"GET", f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/history"
|
|
101
|
+
)
|
|
102
|
+
return ScreeningResponse.model_validate(data)
|
|
103
|
+
|
|
104
|
+
def list_evaluations(
|
|
105
|
+
self, chain: str, address: str, *, page: int = 0, size: int = 20
|
|
106
|
+
) -> ScreeningEvaluationPage:
|
|
107
|
+
"""GET /screen/address/{chain}/{address}/evaluations"""
|
|
108
|
+
data = self._http.request(
|
|
109
|
+
"GET",
|
|
110
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/evaluations",
|
|
111
|
+
params=_query(page=page, size=size),
|
|
112
|
+
)
|
|
113
|
+
return ScreeningEvaluationPage.model_validate(data)
|
|
114
|
+
|
|
115
|
+
def get_counterparties(
|
|
116
|
+
self,
|
|
117
|
+
chain: str,
|
|
118
|
+
address: str,
|
|
119
|
+
*,
|
|
120
|
+
page: int | None = None,
|
|
121
|
+
size: int | None = None,
|
|
122
|
+
sort: str | None = None,
|
|
123
|
+
order: str | None = None,
|
|
124
|
+
days: int | None = None,
|
|
125
|
+
direction: str | None = None,
|
|
126
|
+
listed_only: bool | None = None,
|
|
127
|
+
) -> WalletCounterpartyPage:
|
|
128
|
+
"""GET /screen/address/{chain}/{address}/counterparties"""
|
|
129
|
+
data = self._http.request(
|
|
130
|
+
"GET",
|
|
131
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/counterparties",
|
|
132
|
+
params=_query(
|
|
133
|
+
page=page,
|
|
134
|
+
size=size,
|
|
135
|
+
sort=sort,
|
|
136
|
+
order=order,
|
|
137
|
+
days=days,
|
|
138
|
+
direction=direction,
|
|
139
|
+
listedOnly=listed_only,
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
return WalletCounterpartyPage.model_validate(data)
|
|
143
|
+
|
|
144
|
+
def get_transactions(
|
|
145
|
+
self,
|
|
146
|
+
chain: str,
|
|
147
|
+
address: str,
|
|
148
|
+
*,
|
|
149
|
+
page: int | None = None,
|
|
150
|
+
size: int | None = None,
|
|
151
|
+
sort: str | None = None,
|
|
152
|
+
order: str | None = None,
|
|
153
|
+
days: int | None = None,
|
|
154
|
+
direction: str | None = None,
|
|
155
|
+
counterparty: str | None = None,
|
|
156
|
+
) -> WalletTransactionPage:
|
|
157
|
+
"""GET /screen/address/{chain}/{address}/transactions"""
|
|
158
|
+
data = self._http.request(
|
|
159
|
+
"GET",
|
|
160
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/transactions",
|
|
161
|
+
params=_query(
|
|
162
|
+
page=page,
|
|
163
|
+
size=size,
|
|
164
|
+
sort=sort,
|
|
165
|
+
order=order,
|
|
166
|
+
days=days,
|
|
167
|
+
direction=direction,
|
|
168
|
+
counterparty=counterparty,
|
|
169
|
+
),
|
|
170
|
+
)
|
|
171
|
+
return WalletTransactionPage.model_validate(data)
|
|
172
|
+
|
|
173
|
+
def get_exposure_paths(
|
|
174
|
+
self, chain: str, address: str, *, days: int | None = None
|
|
175
|
+
) -> WalletExposurePaths:
|
|
176
|
+
"""GET /screen/address/{chain}/{address}/exposure-paths"""
|
|
177
|
+
data = self._http.request(
|
|
178
|
+
"GET",
|
|
179
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/exposure-paths",
|
|
180
|
+
params=_query(days=days),
|
|
181
|
+
)
|
|
182
|
+
return WalletExposurePaths.model_validate(data)
|
|
183
|
+
|
|
184
|
+
def get_evaluation(self, evaluation_id: str) -> ScreeningEvaluation:
|
|
185
|
+
"""GET /screen/evaluations/{evaluationId}"""
|
|
186
|
+
data = self._http.request("GET", f"/api/v1/screen/evaluations/{_enc(evaluation_id)}")
|
|
187
|
+
return ScreeningEvaluation.model_validate(data)
|
|
188
|
+
|
|
189
|
+
def screen_bulk_and_wait(
|
|
190
|
+
self,
|
|
191
|
+
request: BulkScreeningRequest | dict[str, Any],
|
|
192
|
+
poll_interval: float = 2.0,
|
|
193
|
+
timeout: float = 300.0,
|
|
194
|
+
*,
|
|
195
|
+
idempotency_key: str | None = None,
|
|
196
|
+
) -> ScreeningJob:
|
|
197
|
+
"""Submit a bulk job and poll until a terminal status (COMPLETED | PARTIAL | FAILED | CANCELLED)."""
|
|
198
|
+
job = self.screen_bulk_async(request, idempotency_key=idempotency_key)
|
|
199
|
+
deadline = time.monotonic() + timeout
|
|
200
|
+
while time.monotonic() < deadline:
|
|
201
|
+
status = self.poll_job(job.job_id or "")
|
|
202
|
+
if is_terminal_job_status(status.status):
|
|
203
|
+
return status
|
|
204
|
+
time.sleep(poll_interval)
|
|
205
|
+
raise TimeoutError(f"Screening job {job.job_id} did not complete within {timeout}s")
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class AsyncScreeningResource:
|
|
209
|
+
"""Asynchronous screening operations. Access via ``client.screening``."""
|
|
210
|
+
|
|
211
|
+
def __init__(self, http: AsyncHttpClient) -> None:
|
|
212
|
+
self._http = http
|
|
213
|
+
|
|
214
|
+
async def screen_address(
|
|
215
|
+
self, request: ScreenAddressRequest | dict[str, Any]
|
|
216
|
+
) -> ScreeningResponse:
|
|
217
|
+
"""POST /screen/address"""
|
|
218
|
+
data = await self._http.request(
|
|
219
|
+
"POST", "/api/v1/screen/address", json=_require_chain(_body(request))
|
|
220
|
+
)
|
|
221
|
+
return ScreeningResponse.model_validate(data)
|
|
222
|
+
|
|
223
|
+
async def screen_bulk(
|
|
224
|
+
self, request: BulkScreeningRequest | dict[str, Any]
|
|
225
|
+
) -> list[ScreeningResponse]:
|
|
226
|
+
"""Screen multiple addresses synchronously (max 1000). ``async`` is forced to False."""
|
|
227
|
+
data = await self._http.request(
|
|
228
|
+
"POST", "/api/v1/screen/bulk", json={**_require_chains(_body(request)), "async": False}
|
|
229
|
+
)
|
|
230
|
+
return [ScreeningResponse.model_validate(x) for x in data]
|
|
231
|
+
|
|
232
|
+
async def screen_bulk_async(
|
|
233
|
+
self, request: BulkScreeningRequest | dict[str, Any], *, idempotency_key: str | None = None
|
|
234
|
+
) -> ScreeningJob:
|
|
235
|
+
"""Submit a bulk screening job (max 10000). ``async`` is forced to True; an Idempotency-Key header is always sent."""
|
|
236
|
+
headers = {"Idempotency-Key": idempotency_key or generate_idempotency_key()}
|
|
237
|
+
data = await self._http.request(
|
|
238
|
+
"POST",
|
|
239
|
+
"/api/v1/screen/bulk",
|
|
240
|
+
json={**_require_chains(_body(request)), "async": True},
|
|
241
|
+
headers=headers,
|
|
242
|
+
)
|
|
243
|
+
return ScreeningJob.model_validate(data)
|
|
244
|
+
|
|
245
|
+
async def poll_job(self, job_id: str) -> ScreeningJob:
|
|
246
|
+
"""GET /screen/jobs/{jobId}"""
|
|
247
|
+
data = await self._http.request("GET", f"/api/v1/screen/jobs/{_enc(job_id)}")
|
|
248
|
+
return ScreeningJob.model_validate(data)
|
|
249
|
+
|
|
250
|
+
async def list_jobs(self) -> list[ScreeningJob]:
|
|
251
|
+
"""GET /screen/jobs"""
|
|
252
|
+
data = await self._http.request("GET", "/api/v1/screen/jobs")
|
|
253
|
+
return [ScreeningJob.model_validate(x) for x in data]
|
|
254
|
+
|
|
255
|
+
async def get_job_results(
|
|
256
|
+
self, job_id: str, *, page: int = 0, size: int = 100
|
|
257
|
+
) -> ScreeningJobResultsPage:
|
|
258
|
+
"""One page (0-based, size 1..1000) of a job's stored per-address items."""
|
|
259
|
+
data = await self._http.request(
|
|
260
|
+
"GET",
|
|
261
|
+
f"/api/v1/screen/jobs/{_enc(job_id)}/results",
|
|
262
|
+
params={"page": page, "size": size},
|
|
263
|
+
)
|
|
264
|
+
return _normalise_job_results(data, job_id, page, size)
|
|
265
|
+
|
|
266
|
+
async def cancel_job(self, job_id: str) -> ScreeningJob:
|
|
267
|
+
"""POST /screen/jobs/{jobId}/cancel"""
|
|
268
|
+
data = await self._http.request("POST", f"/api/v1/screen/jobs/{_enc(job_id)}/cancel")
|
|
269
|
+
return ScreeningJob.model_validate(data)
|
|
270
|
+
|
|
271
|
+
async def get_history(self, chain: str, address: str) -> ScreeningResponse:
|
|
272
|
+
"""GET /screen/address/{chain}/{address}/history"""
|
|
273
|
+
data = await self._http.request(
|
|
274
|
+
"GET", f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/history"
|
|
275
|
+
)
|
|
276
|
+
return ScreeningResponse.model_validate(data)
|
|
277
|
+
|
|
278
|
+
async def list_evaluations(
|
|
279
|
+
self, chain: str, address: str, *, page: int = 0, size: int = 20
|
|
280
|
+
) -> ScreeningEvaluationPage:
|
|
281
|
+
"""GET /screen/address/{chain}/{address}/evaluations"""
|
|
282
|
+
data = await self._http.request(
|
|
283
|
+
"GET",
|
|
284
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/evaluations",
|
|
285
|
+
params=_query(page=page, size=size),
|
|
286
|
+
)
|
|
287
|
+
return ScreeningEvaluationPage.model_validate(data)
|
|
288
|
+
|
|
289
|
+
async def get_counterparties(
|
|
290
|
+
self,
|
|
291
|
+
chain: str,
|
|
292
|
+
address: str,
|
|
293
|
+
*,
|
|
294
|
+
page: int | None = None,
|
|
295
|
+
size: int | None = None,
|
|
296
|
+
sort: str | None = None,
|
|
297
|
+
order: str | None = None,
|
|
298
|
+
days: int | None = None,
|
|
299
|
+
direction: str | None = None,
|
|
300
|
+
listed_only: bool | None = None,
|
|
301
|
+
) -> WalletCounterpartyPage:
|
|
302
|
+
"""GET /screen/address/{chain}/{address}/counterparties"""
|
|
303
|
+
data = await self._http.request(
|
|
304
|
+
"GET",
|
|
305
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/counterparties",
|
|
306
|
+
params=_query(
|
|
307
|
+
page=page,
|
|
308
|
+
size=size,
|
|
309
|
+
sort=sort,
|
|
310
|
+
order=order,
|
|
311
|
+
days=days,
|
|
312
|
+
direction=direction,
|
|
313
|
+
listedOnly=listed_only,
|
|
314
|
+
),
|
|
315
|
+
)
|
|
316
|
+
return WalletCounterpartyPage.model_validate(data)
|
|
317
|
+
|
|
318
|
+
async def get_transactions(
|
|
319
|
+
self,
|
|
320
|
+
chain: str,
|
|
321
|
+
address: str,
|
|
322
|
+
*,
|
|
323
|
+
page: int | None = None,
|
|
324
|
+
size: int | None = None,
|
|
325
|
+
sort: str | None = None,
|
|
326
|
+
order: str | None = None,
|
|
327
|
+
days: int | None = None,
|
|
328
|
+
direction: str | None = None,
|
|
329
|
+
counterparty: str | None = None,
|
|
330
|
+
) -> WalletTransactionPage:
|
|
331
|
+
"""GET /screen/address/{chain}/{address}/transactions"""
|
|
332
|
+
data = await self._http.request(
|
|
333
|
+
"GET",
|
|
334
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/transactions",
|
|
335
|
+
params=_query(
|
|
336
|
+
page=page,
|
|
337
|
+
size=size,
|
|
338
|
+
sort=sort,
|
|
339
|
+
order=order,
|
|
340
|
+
days=days,
|
|
341
|
+
direction=direction,
|
|
342
|
+
counterparty=counterparty,
|
|
343
|
+
),
|
|
344
|
+
)
|
|
345
|
+
return WalletTransactionPage.model_validate(data)
|
|
346
|
+
|
|
347
|
+
async def get_exposure_paths(
|
|
348
|
+
self, chain: str, address: str, *, days: int | None = None
|
|
349
|
+
) -> WalletExposurePaths:
|
|
350
|
+
"""GET /screen/address/{chain}/{address}/exposure-paths"""
|
|
351
|
+
data = await self._http.request(
|
|
352
|
+
"GET",
|
|
353
|
+
f"/api/v1/screen/address/{_enc(chain)}/{_enc(address)}/exposure-paths",
|
|
354
|
+
params=_query(days=days),
|
|
355
|
+
)
|
|
356
|
+
return WalletExposurePaths.model_validate(data)
|
|
357
|
+
|
|
358
|
+
async def get_evaluation(self, evaluation_id: str) -> ScreeningEvaluation:
|
|
359
|
+
"""GET /screen/evaluations/{evaluationId}"""
|
|
360
|
+
data = await self._http.request("GET", f"/api/v1/screen/evaluations/{_enc(evaluation_id)}")
|
|
361
|
+
return ScreeningEvaluation.model_validate(data)
|
|
362
|
+
|
|
363
|
+
async def screen_bulk_and_wait(
|
|
364
|
+
self,
|
|
365
|
+
request: BulkScreeningRequest | dict[str, Any],
|
|
366
|
+
poll_interval: float = 2.0,
|
|
367
|
+
timeout: float = 300.0,
|
|
368
|
+
*,
|
|
369
|
+
idempotency_key: str | None = None,
|
|
370
|
+
) -> ScreeningJob:
|
|
371
|
+
"""Submit a bulk job and poll until a terminal status (COMPLETED | PARTIAL | FAILED | CANCELLED)."""
|
|
372
|
+
job = await self.screen_bulk_async(request, idempotency_key=idempotency_key)
|
|
373
|
+
deadline = time.monotonic() + timeout
|
|
374
|
+
while time.monotonic() < deadline:
|
|
375
|
+
status = await self.poll_job(job.job_id or "")
|
|
376
|
+
if is_terminal_job_status(status.status):
|
|
377
|
+
return status
|
|
378
|
+
await asyncio.sleep(poll_interval)
|
|
379
|
+
raise TimeoutError(f"Screening job {job.job_id} did not complete within {timeout}s")
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Read access to the tenant settings (resource ``client.settings``)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from cryptascreen._util import _query
|
|
8
|
+
from cryptascreen.types._account import (
|
|
9
|
+
ItemsResponse,
|
|
10
|
+
NameMatchingStrength,
|
|
11
|
+
ScoreThresholdAuditPage,
|
|
12
|
+
ScoreThresholdSettings,
|
|
13
|
+
VendorKeyView,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from cryptascreen.client import AsyncHttpClient, HttpClient
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SettingsResource:
|
|
21
|
+
"""Synchronous read access to the tenant settings. Access via ``client.settings``."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, http: HttpClient) -> None:
|
|
24
|
+
self._http = http
|
|
25
|
+
|
|
26
|
+
def get_score_thresholds(self) -> ScoreThresholdSettings:
|
|
27
|
+
"""Review / block thresholds of the calling tenant (defaults 40 / 70 until changed; paid plans)."""
|
|
28
|
+
data = self._http.request("GET", "/api/v1/settings/score-thresholds")
|
|
29
|
+
return ScoreThresholdSettings.model_validate(data)
|
|
30
|
+
|
|
31
|
+
def get_score_threshold_audit(self, *, limit: int | None = None) -> ScoreThresholdAuditPage:
|
|
32
|
+
"""Change history of the thresholds, newest first."""
|
|
33
|
+
data = self._http.request(
|
|
34
|
+
"GET", "/api/v1/settings/score-thresholds/audit", params=_query(limit=limit)
|
|
35
|
+
)
|
|
36
|
+
return ScoreThresholdAuditPage.model_validate(data)
|
|
37
|
+
|
|
38
|
+
def get_name_matching(self) -> NameMatchingStrength:
|
|
39
|
+
"""Name-matching strength of the calling tenant (default CONSERVATIVE; paid plans)."""
|
|
40
|
+
data = self._http.request("GET", "/api/v1/settings/name-matching")
|
|
41
|
+
return NameMatchingStrength.model_validate(data)
|
|
42
|
+
|
|
43
|
+
def get_name_matching_audit(self, *, limit: int | None = None) -> ItemsResponse:
|
|
44
|
+
"""Change history of the matching strength, newest first."""
|
|
45
|
+
data = self._http.request(
|
|
46
|
+
"GET", "/api/v1/settings/name-matching/audit", params=_query(limit=limit)
|
|
47
|
+
)
|
|
48
|
+
return ItemsResponse.model_validate(data)
|
|
49
|
+
|
|
50
|
+
def get_name_lists(self) -> ItemsResponse:
|
|
51
|
+
"""Allow / block list entries of the calling tenant (exact identifiers, applied before fuzzy matching)."""
|
|
52
|
+
data = self._http.request("GET", "/api/v1/settings/name-lists")
|
|
53
|
+
return ItemsResponse.model_validate(data)
|
|
54
|
+
|
|
55
|
+
def get_name_list_audit(self, *, limit: int | None = None) -> ItemsResponse:
|
|
56
|
+
"""Audit of allow / block entries (added, removed, applied), newest first."""
|
|
57
|
+
data = self._http.request(
|
|
58
|
+
"GET", "/api/v1/settings/name-lists/audit", params=_query(limit=limit)
|
|
59
|
+
)
|
|
60
|
+
return ItemsResponse.model_validate(data)
|
|
61
|
+
|
|
62
|
+
def list_vendor_keys(self) -> list[VendorKeyView]:
|
|
63
|
+
"""The vendors with their configured state (last4 and fingerprint only; never the key)."""
|
|
64
|
+
data = self._http.request("GET", "/api/v1/settings/vendor-keys")
|
|
65
|
+
return [VendorKeyView.model_validate(x) for x in data]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class AsyncSettingsResource:
|
|
69
|
+
"""Asynchronous read access to the tenant settings. Access via ``client.settings``."""
|
|
70
|
+
|
|
71
|
+
def __init__(self, http: AsyncHttpClient) -> None:
|
|
72
|
+
self._http = http
|
|
73
|
+
|
|
74
|
+
async def get_score_thresholds(self) -> ScoreThresholdSettings:
|
|
75
|
+
"""Review / block thresholds of the calling tenant (defaults 40 / 70 until changed; paid plans)."""
|
|
76
|
+
data = await self._http.request("GET", "/api/v1/settings/score-thresholds")
|
|
77
|
+
return ScoreThresholdSettings.model_validate(data)
|
|
78
|
+
|
|
79
|
+
async def get_score_threshold_audit(
|
|
80
|
+
self, *, limit: int | None = None
|
|
81
|
+
) -> ScoreThresholdAuditPage:
|
|
82
|
+
"""Change history of the thresholds, newest first."""
|
|
83
|
+
data = await self._http.request(
|
|
84
|
+
"GET", "/api/v1/settings/score-thresholds/audit", params=_query(limit=limit)
|
|
85
|
+
)
|
|
86
|
+
return ScoreThresholdAuditPage.model_validate(data)
|
|
87
|
+
|
|
88
|
+
async def get_name_matching(self) -> NameMatchingStrength:
|
|
89
|
+
"""Name-matching strength of the calling tenant (default CONSERVATIVE; paid plans)."""
|
|
90
|
+
data = await self._http.request("GET", "/api/v1/settings/name-matching")
|
|
91
|
+
return NameMatchingStrength.model_validate(data)
|
|
92
|
+
|
|
93
|
+
async def get_name_matching_audit(self, *, limit: int | None = None) -> ItemsResponse:
|
|
94
|
+
"""Change history of the matching strength, newest first."""
|
|
95
|
+
data = await self._http.request(
|
|
96
|
+
"GET", "/api/v1/settings/name-matching/audit", params=_query(limit=limit)
|
|
97
|
+
)
|
|
98
|
+
return ItemsResponse.model_validate(data)
|
|
99
|
+
|
|
100
|
+
async def get_name_lists(self) -> ItemsResponse:
|
|
101
|
+
"""Allow / block list entries of the calling tenant (exact identifiers, applied before fuzzy matching)."""
|
|
102
|
+
data = await self._http.request("GET", "/api/v1/settings/name-lists")
|
|
103
|
+
return ItemsResponse.model_validate(data)
|
|
104
|
+
|
|
105
|
+
async def get_name_list_audit(self, *, limit: int | None = None) -> ItemsResponse:
|
|
106
|
+
"""Audit of allow / block entries (added, removed, applied), newest first."""
|
|
107
|
+
data = await self._http.request(
|
|
108
|
+
"GET", "/api/v1/settings/name-lists/audit", params=_query(limit=limit)
|
|
109
|
+
)
|
|
110
|
+
return ItemsResponse.model_validate(data)
|
|
111
|
+
|
|
112
|
+
async def list_vendor_keys(self) -> list[VendorKeyView]:
|
|
113
|
+
"""The vendors with their configured state (last4 and fingerprint only; never the key)."""
|
|
114
|
+
data = await self._http.request("GET", "/api/v1/settings/vendor-keys")
|
|
115
|
+
return [VendorKeyView.model_validate(x) for x in data]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Webhooks resource: reading webhook endpoints and their deliveries with an API key.
|
|
2
|
+
|
|
3
|
+
Registering, deleting and test-sending a webhook endpoint require a signed-in user in the CryptaScreen app; an API key
|
|
4
|
+
is refused (403), so this SDK does not offer them.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import builtins
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
|
|
12
|
+
from cryptascreen._util import _enc
|
|
13
|
+
from cryptascreen.types._models import (
|
|
14
|
+
WebhookConfig,
|
|
15
|
+
WebhookDelivery,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from cryptascreen.client import AsyncHttpClient, HttpClient
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class WebhooksResource:
|
|
23
|
+
"""Synchronous webhooks operations. Access via ``client.webhooks``."""
|
|
24
|
+
|
|
25
|
+
def __init__(self, http: HttpClient) -> None:
|
|
26
|
+
self._http = http
|
|
27
|
+
|
|
28
|
+
def list(self) -> list[WebhookConfig]:
|
|
29
|
+
"""GET /webhooks"""
|
|
30
|
+
data = self._http.request("GET", "/api/v1/webhooks")
|
|
31
|
+
return [WebhookConfig.model_validate(x) for x in data]
|
|
32
|
+
|
|
33
|
+
def get_deliveries(self, webhook_id: int | str) -> builtins.list[WebhookDelivery]:
|
|
34
|
+
"""The last 50 deliveries of an endpoint, newest first (404 for another tenant's endpoint)."""
|
|
35
|
+
data = self._http.request("GET", f"/api/v1/webhooks/{_enc(str(webhook_id))}/deliveries")
|
|
36
|
+
return [WebhookDelivery.model_validate(x) for x in data]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class AsyncWebhooksResource:
|
|
40
|
+
"""Asynchronous webhooks operations. Access via ``client.webhooks``."""
|
|
41
|
+
|
|
42
|
+
def __init__(self, http: AsyncHttpClient) -> None:
|
|
43
|
+
self._http = http
|
|
44
|
+
|
|
45
|
+
async def list(self) -> list[WebhookConfig]:
|
|
46
|
+
"""GET /webhooks"""
|
|
47
|
+
data = await self._http.request("GET", "/api/v1/webhooks")
|
|
48
|
+
return [WebhookConfig.model_validate(x) for x in data]
|
|
49
|
+
|
|
50
|
+
async def get_deliveries(self, webhook_id: int | str) -> builtins.list[WebhookDelivery]:
|
|
51
|
+
"""The last 50 deliveries of an endpoint, newest first (404 for another tenant's endpoint)."""
|
|
52
|
+
data = await self._http.request(
|
|
53
|
+
"GET", f"/api/v1/webhooks/{_enc(str(webhook_id))}/deliveries"
|
|
54
|
+
)
|
|
55
|
+
return [WebhookDelivery.model_validate(x) for x in data]
|