quantumapi 0.22.1__tar.gz → 0.24.0__tar.gz
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.
- {quantumapi-0.22.1/quantumapi.egg-info → quantumapi-0.24.0}/PKG-INFO +67 -1
- {quantumapi-0.22.1 → quantumapi-0.24.0}/README.md +66 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/pyproject.toml +1 -1
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/__init__.py +4 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/async_client.py +2 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/base.py +39 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/keys.py +36 -1
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/secrets.py +219 -37
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/sync_client.py +1 -0
- quantumapi-0.24.0/quantumapi/client/transit.py +192 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/errors/__init__.py +4 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/errors/exceptions.py +21 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/__init__.py +12 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/health.py +6 -2
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/keys.py +23 -11
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/secrets.py +127 -12
- quantumapi-0.24.0/quantumapi/models/transit.py +196 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0/quantumapi.egg-info}/PKG-INFO +67 -1
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi.egg-info/SOURCES.txt +5 -1
- {quantumapi-0.22.1 → quantumapi-0.24.0}/tests/test_parity.py +0 -150
- quantumapi-0.24.0/tests/test_secret_history_share.py +382 -0
- quantumapi-0.24.0/tests/test_transit.py +209 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/LICENSE +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/__init__.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/applications.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/audit.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/encryption.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/end_users.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/health.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/qrng.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/resource_groups.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/client/roles.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/applications.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/audit.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/encryption.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/end_users.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/qrng.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/resource_groups.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/models/roles.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi/py.typed +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi.egg-info/dependency_links.txt +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi.egg-info/requires.txt +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/quantumapi.egg-info/top_level.txt +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/setup.cfg +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/tests/test_audit.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/tests/test_data_keys.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/tests/test_end_users.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/tests/test_exceptions.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/tests/test_models.py +0 -0
- {quantumapi-0.22.1 → quantumapi-0.24.0}/tests/test_qrng.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantumapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.24.0
|
|
4
4
|
Summary: Official Python SDK for QuantumAPI - Quantum-safe encryption and identity platform
|
|
5
5
|
Author-email: QuantumAPI Team <developers@quantumapi.eu>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -260,6 +260,45 @@ await client.secrets.update(
|
|
|
260
260
|
|
|
261
261
|
# Delete secret
|
|
262
262
|
await client.secrets.delete(secret_id="secret-id")
|
|
263
|
+
|
|
264
|
+
# Version history, newest first. Values are included, so this needs reveal
|
|
265
|
+
# permission. max_versions is 1-20 (None = the API default of 5).
|
|
266
|
+
history = await client.secrets.list_versions(secret_id, max_versions=10)
|
|
267
|
+
for v in history.versions:
|
|
268
|
+
print(v.version, v.changed_by, v.created_at)
|
|
269
|
+
|
|
270
|
+
# The secret as it was at version 1
|
|
271
|
+
v1 = await client.secrets.get_version(secret_id, 1)
|
|
272
|
+
|
|
273
|
+
# Roll back to version 1: reads it and writes its value back as a new version,
|
|
274
|
+
# audited as a restore. Two requests (not atomic); only the value is restored.
|
|
275
|
+
await client.secrets.rollback(secret_id, 1)
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### Share links
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
# Encrypted, time-limited link for someone outside the tenant
|
|
282
|
+
link = await client.secrets.create_shared_link(
|
|
283
|
+
secret_id,
|
|
284
|
+
expires_in_hours=48, # 1-720, default 24
|
|
285
|
+
max_access_count=5, # None = unlimited until it expires
|
|
286
|
+
password="optional-password",
|
|
287
|
+
)
|
|
288
|
+
# The token is returned only now: the server does not store it.
|
|
289
|
+
print(client.secrets.share_url(link.token))
|
|
290
|
+
# -> https://portal.quantumapi.eu/share/<token> (derived from base_url, or pass your portal URL)
|
|
291
|
+
|
|
292
|
+
# Links of a secret. status is a string (Active, Revoked, Expired, Exhausted, Retired, ...);
|
|
293
|
+
# token is always "" here.
|
|
294
|
+
links = await client.secrets.list_shared_links(secret_id)
|
|
295
|
+
await client.secrets.revoke_shared_link(links.links[0].id)
|
|
296
|
+
|
|
297
|
+
# Open a link as the recipient (public endpoint: no API key sent, never retried,
|
|
298
|
+
# counts one access). Errors: NotFoundError (unknown or expired), ValidationError with
|
|
299
|
+
# error_code password_required / invalid_password / link_exhausted, QuantumAPIError
|
|
300
|
+
# with error_code link_retired (HTTP 410).
|
|
301
|
+
opened = await client.secrets.open_shared_link(link.token, password="optional-password")
|
|
263
302
|
```
|
|
264
303
|
|
|
265
304
|
### Users Client
|
|
@@ -375,6 +414,33 @@ rate_limit = await client.health.rate_limit()
|
|
|
375
414
|
print(f"Remaining: {rate_limit.remaining}/{rate_limit.limit}")
|
|
376
415
|
```
|
|
377
416
|
|
|
417
|
+
### Transit (encryption as a service)
|
|
418
|
+
|
|
419
|
+
`client.transit` encrypts, decrypts, rewraps, signs and MACs with named keys. Raw `bytes` are
|
|
420
|
+
base64-encoded for you; a `str` is sent as-is (the API wire format is base64).
|
|
421
|
+
|
|
422
|
+
```python
|
|
423
|
+
key = await client.transit.create_key("orders") # POST /api/v1/keys
|
|
424
|
+
enc = await client.transit.encrypt("orders", b"4111 1111 1111") # vault:v1:...
|
|
425
|
+
dec = await client.transit.decrypt("orders", enc.ciphertext)
|
|
426
|
+
assert dec.plaintext_bytes == b"4111 1111 1111"
|
|
427
|
+
|
|
428
|
+
await client.transit.rotate_key(key.id) # new version
|
|
429
|
+
new = await client.transit.rewrap("orders", enc.ciphertext) # moves to the latest version
|
|
430
|
+
|
|
431
|
+
dk = await client.transit.generate_data_key("orders", key_bytes=32) # envelope encryption
|
|
432
|
+
mac = await client.transit.hmac("orders", b"payload", algorithm="sha256")
|
|
433
|
+
sig = await client.transit.sign("signing-key", b"payload")
|
|
434
|
+
await client.transit.set_min_decryption_version("orders", 2) # older versions then raise KeyVersionBelowMinimumError
|
|
435
|
+
history = await client.keys.list_versions(key.id) # versions[] with state and dates
|
|
436
|
+
rows = await client.keys.list(all_versions=True) # per-version rows (default: one row per key)
|
|
437
|
+
ok = (await client.transit.verify("signing-key", b"payload", sig.signature)).valid
|
|
438
|
+
batch = await client.transit.batch_encrypt("orders", [b"a", b"b"]) # up to 100 items
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
Errors: `KeyRevokedError` (403 `key_revoked`) and `InsufficientScopeError` (403 `insufficient_scope`),
|
|
442
|
+
both subclasses of `PermissionError`.
|
|
443
|
+
|
|
378
444
|
## Error Handling
|
|
379
445
|
|
|
380
446
|
The SDK provides typed exceptions for all error scenarios:
|
|
@@ -219,6 +219,45 @@ await client.secrets.update(
|
|
|
219
219
|
|
|
220
220
|
# Delete secret
|
|
221
221
|
await client.secrets.delete(secret_id="secret-id")
|
|
222
|
+
|
|
223
|
+
# Version history, newest first. Values are included, so this needs reveal
|
|
224
|
+
# permission. max_versions is 1-20 (None = the API default of 5).
|
|
225
|
+
history = await client.secrets.list_versions(secret_id, max_versions=10)
|
|
226
|
+
for v in history.versions:
|
|
227
|
+
print(v.version, v.changed_by, v.created_at)
|
|
228
|
+
|
|
229
|
+
# The secret as it was at version 1
|
|
230
|
+
v1 = await client.secrets.get_version(secret_id, 1)
|
|
231
|
+
|
|
232
|
+
# Roll back to version 1: reads it and writes its value back as a new version,
|
|
233
|
+
# audited as a restore. Two requests (not atomic); only the value is restored.
|
|
234
|
+
await client.secrets.rollback(secret_id, 1)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
#### Share links
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
# Encrypted, time-limited link for someone outside the tenant
|
|
241
|
+
link = await client.secrets.create_shared_link(
|
|
242
|
+
secret_id,
|
|
243
|
+
expires_in_hours=48, # 1-720, default 24
|
|
244
|
+
max_access_count=5, # None = unlimited until it expires
|
|
245
|
+
password="optional-password",
|
|
246
|
+
)
|
|
247
|
+
# The token is returned only now: the server does not store it.
|
|
248
|
+
print(client.secrets.share_url(link.token))
|
|
249
|
+
# -> https://portal.quantumapi.eu/share/<token> (derived from base_url, or pass your portal URL)
|
|
250
|
+
|
|
251
|
+
# Links of a secret. status is a string (Active, Revoked, Expired, Exhausted, Retired, ...);
|
|
252
|
+
# token is always "" here.
|
|
253
|
+
links = await client.secrets.list_shared_links(secret_id)
|
|
254
|
+
await client.secrets.revoke_shared_link(links.links[0].id)
|
|
255
|
+
|
|
256
|
+
# Open a link as the recipient (public endpoint: no API key sent, never retried,
|
|
257
|
+
# counts one access). Errors: NotFoundError (unknown or expired), ValidationError with
|
|
258
|
+
# error_code password_required / invalid_password / link_exhausted, QuantumAPIError
|
|
259
|
+
# with error_code link_retired (HTTP 410).
|
|
260
|
+
opened = await client.secrets.open_shared_link(link.token, password="optional-password")
|
|
222
261
|
```
|
|
223
262
|
|
|
224
263
|
### Users Client
|
|
@@ -334,6 +373,33 @@ rate_limit = await client.health.rate_limit()
|
|
|
334
373
|
print(f"Remaining: {rate_limit.remaining}/{rate_limit.limit}")
|
|
335
374
|
```
|
|
336
375
|
|
|
376
|
+
### Transit (encryption as a service)
|
|
377
|
+
|
|
378
|
+
`client.transit` encrypts, decrypts, rewraps, signs and MACs with named keys. Raw `bytes` are
|
|
379
|
+
base64-encoded for you; a `str` is sent as-is (the API wire format is base64).
|
|
380
|
+
|
|
381
|
+
```python
|
|
382
|
+
key = await client.transit.create_key("orders") # POST /api/v1/keys
|
|
383
|
+
enc = await client.transit.encrypt("orders", b"4111 1111 1111") # vault:v1:...
|
|
384
|
+
dec = await client.transit.decrypt("orders", enc.ciphertext)
|
|
385
|
+
assert dec.plaintext_bytes == b"4111 1111 1111"
|
|
386
|
+
|
|
387
|
+
await client.transit.rotate_key(key.id) # new version
|
|
388
|
+
new = await client.transit.rewrap("orders", enc.ciphertext) # moves to the latest version
|
|
389
|
+
|
|
390
|
+
dk = await client.transit.generate_data_key("orders", key_bytes=32) # envelope encryption
|
|
391
|
+
mac = await client.transit.hmac("orders", b"payload", algorithm="sha256")
|
|
392
|
+
sig = await client.transit.sign("signing-key", b"payload")
|
|
393
|
+
await client.transit.set_min_decryption_version("orders", 2) # older versions then raise KeyVersionBelowMinimumError
|
|
394
|
+
history = await client.keys.list_versions(key.id) # versions[] with state and dates
|
|
395
|
+
rows = await client.keys.list(all_versions=True) # per-version rows (default: one row per key)
|
|
396
|
+
ok = (await client.transit.verify("signing-key", b"payload", sig.signature)).valid
|
|
397
|
+
batch = await client.transit.batch_encrypt("orders", [b"a", b"b"]) # up to 100 items
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Errors: `KeyRevokedError` (403 `key_revoked`) and `InsufficientScopeError` (403 `insufficient_scope`),
|
|
401
|
+
both subclasses of `PermissionError`.
|
|
402
|
+
|
|
337
403
|
## Error Handling
|
|
338
404
|
|
|
339
405
|
The SDK provides typed exceptions for all error scenarios:
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quantumapi"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.24.0"
|
|
8
8
|
description = "Official Python SDK for QuantumAPI - Quantum-safe encryption and identity platform"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -18,7 +18,9 @@ from quantumapi.client.sync_client import QuantumAPISyncClient
|
|
|
18
18
|
from quantumapi.errors.exceptions import (
|
|
19
19
|
AuthenticationError,
|
|
20
20
|
ConflictError,
|
|
21
|
+
InsufficientScopeError,
|
|
21
22
|
KeyRevokedError,
|
|
23
|
+
KeyVersionBelowMinimumError,
|
|
22
24
|
NetworkError,
|
|
23
25
|
NotFoundError,
|
|
24
26
|
PermissionError,
|
|
@@ -39,6 +41,8 @@ __all__ = [
|
|
|
39
41
|
"AuthenticationError",
|
|
40
42
|
"PermissionError",
|
|
41
43
|
"KeyRevokedError",
|
|
44
|
+
"KeyVersionBelowMinimumError",
|
|
45
|
+
"InsufficientScopeError",
|
|
42
46
|
"NotFoundError",
|
|
43
47
|
"ConflictError",
|
|
44
48
|
"RateLimitError",
|
|
@@ -14,6 +14,7 @@ from quantumapi.client.qrng import QrngClient
|
|
|
14
14
|
from quantumapi.client.resource_groups import ResourceGroupsClient
|
|
15
15
|
from quantumapi.client.roles import RolesClient
|
|
16
16
|
from quantumapi.client.secrets import SecretsClient
|
|
17
|
+
from quantumapi.client.transit import TransitClient
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
class QuantumAPIClient:
|
|
@@ -91,6 +92,7 @@ class QuantumAPIClient:
|
|
|
91
92
|
self.roles = RolesClient(self._base_client)
|
|
92
93
|
self.health = HealthClient(self._base_client)
|
|
93
94
|
self.qrng = QrngClient(self._base_client)
|
|
95
|
+
self.transit = TransitClient(self._base_client)
|
|
94
96
|
|
|
95
97
|
async def close(self) -> None:
|
|
96
98
|
"""
|
|
@@ -10,6 +10,8 @@ from httpx import Response
|
|
|
10
10
|
from quantumapi.errors import (
|
|
11
11
|
AuthenticationError,
|
|
12
12
|
ConflictError,
|
|
13
|
+
InsufficientScopeError,
|
|
14
|
+
KeyVersionBelowMinimumError,
|
|
13
15
|
KeyRevokedError,
|
|
14
16
|
NetworkError,
|
|
15
17
|
NotFoundError,
|
|
@@ -136,6 +138,18 @@ class BaseClient:
|
|
|
136
138
|
error_code=error_code,
|
|
137
139
|
details=error_details,
|
|
138
140
|
)
|
|
141
|
+
if error_code == "key_version_below_minimum":
|
|
142
|
+
raise KeyVersionBelowMinimumError(
|
|
143
|
+
message=error_message,
|
|
144
|
+
error_code=error_code,
|
|
145
|
+
details=error_details,
|
|
146
|
+
)
|
|
147
|
+
if error_code == "insufficient_scope":
|
|
148
|
+
raise InsufficientScopeError(
|
|
149
|
+
message=error_message,
|
|
150
|
+
error_code=error_code,
|
|
151
|
+
details=error_details,
|
|
152
|
+
)
|
|
139
153
|
raise PermissionError(
|
|
140
154
|
message=error_message,
|
|
141
155
|
error_code=error_code,
|
|
@@ -330,6 +344,31 @@ class BaseClient:
|
|
|
330
344
|
"""Make DELETE request."""
|
|
331
345
|
return await self._request("DELETE", endpoint, params=params, headers=headers)
|
|
332
346
|
|
|
347
|
+
async def post_anonymous(
|
|
348
|
+
self,
|
|
349
|
+
endpoint: str,
|
|
350
|
+
json_data: Optional[Dict[str, Any]] = None,
|
|
351
|
+
) -> Dict[str, Any]:
|
|
352
|
+
"""
|
|
353
|
+
Make a single POST request without the ``X-Api-Key`` header.
|
|
354
|
+
|
|
355
|
+
For public endpoints such as ``POST /api/v1/share/{token}``. It is never
|
|
356
|
+
retried, because each call can have a side effect (opening a share link
|
|
357
|
+
counts one access).
|
|
358
|
+
"""
|
|
359
|
+
url = self._build_url(endpoint)
|
|
360
|
+
if self.enable_logging:
|
|
361
|
+
logger.debug(f"Request (anonymous): POST {url}")
|
|
362
|
+
request = self._client.build_request("POST", url, json=json_data)
|
|
363
|
+
request.headers.pop("X-Api-Key", None)
|
|
364
|
+
try:
|
|
365
|
+
response = await self._client.send(request)
|
|
366
|
+
except httpx.TimeoutException as e:
|
|
367
|
+
raise TimeoutError("Request timed out") from e
|
|
368
|
+
except httpx.NetworkError as e:
|
|
369
|
+
raise NetworkError("Network error occurred", original_error=e) from e
|
|
370
|
+
return await self._handle_response(response)
|
|
371
|
+
|
|
333
372
|
async def close(self) -> None:
|
|
334
373
|
"""Close HTTP client connection."""
|
|
335
374
|
await self._client.aclose()
|
|
@@ -6,6 +6,7 @@ from urllib.parse import quote
|
|
|
6
6
|
from uuid import UUID
|
|
7
7
|
|
|
8
8
|
from quantumapi.client.base import BaseClient
|
|
9
|
+
from quantumapi.models.transit import KeyVersionsResponse, TransitKeyConfigResponse
|
|
9
10
|
from quantumapi.models.keys import (
|
|
10
11
|
GenerateDataKeyResponse,
|
|
11
12
|
GenerateKeyRequest,
|
|
@@ -75,7 +76,21 @@ class KeysClient:
|
|
|
75
76
|
set_as_default=set_as_default,
|
|
76
77
|
labels=labels,
|
|
77
78
|
)
|
|
78
|
-
|
|
79
|
+
# The API names the purpose ``keyType`` (camelCase body); ``purpose`` is kept for older servers.
|
|
80
|
+
body = {
|
|
81
|
+
"name": request.name,
|
|
82
|
+
"keyType": request.key_type.value,
|
|
83
|
+
"purpose": request.key_type.value,
|
|
84
|
+
"algorithm": request.algorithm,
|
|
85
|
+
"setAsDefault": request.set_as_default,
|
|
86
|
+
}
|
|
87
|
+
if description is not None:
|
|
88
|
+
body["description"] = description
|
|
89
|
+
if expires_at is not None:
|
|
90
|
+
body["expiresAt"] = request.expires_at.isoformat()
|
|
91
|
+
if labels is not None:
|
|
92
|
+
body["labels"] = labels
|
|
93
|
+
response = await self._client.post("/api/v1/keys", json_data=body)
|
|
79
94
|
return KeyResponse(**response)
|
|
80
95
|
|
|
81
96
|
async def import_key(
|
|
@@ -139,6 +154,7 @@ class KeysClient:
|
|
|
139
154
|
status: Optional[str] = None,
|
|
140
155
|
page: int = 1,
|
|
141
156
|
page_size: int = 50,
|
|
157
|
+
all_versions: bool = False,
|
|
142
158
|
) -> KeyListResponse:
|
|
143
159
|
"""
|
|
144
160
|
List cryptographic keys.
|
|
@@ -148,6 +164,7 @@ class KeysClient:
|
|
|
148
164
|
status: Filter by status (active, inactive, scheduled_deletion)
|
|
149
165
|
page: Page number
|
|
150
166
|
page_size: Number of items per page
|
|
167
|
+
all_versions: Return one row per key version instead of one row per key
|
|
151
168
|
|
|
152
169
|
Returns:
|
|
153
170
|
List of keys with pagination info
|
|
@@ -162,10 +179,28 @@ class KeysClient:
|
|
|
162
179
|
params["keyType"] = key_type.value
|
|
163
180
|
if status:
|
|
164
181
|
params["status"] = status
|
|
182
|
+
if all_versions:
|
|
183
|
+
params["allVersions"] = "true"
|
|
165
184
|
|
|
166
185
|
response = await self._client.get("/api/v1/keys", params=params)
|
|
167
186
|
return KeyListResponse(**response)
|
|
168
187
|
|
|
188
|
+
async def list_versions(self, key_id: UUID) -> KeyVersionsResponse:
|
|
189
|
+
"""List the version history of a key (``GET /api/v1/keys/{id}/versions``)."""
|
|
190
|
+
return KeyVersionsResponse(**await self._client.get(f"/api/v1/keys/{key_id}/versions"))
|
|
191
|
+
|
|
192
|
+
async def set_min_decryption_version(
|
|
193
|
+
self, key_id: UUID, min_decryption_version: int
|
|
194
|
+
) -> TransitKeyConfigResponse:
|
|
195
|
+
"""Set the minimum decryption version (``PUT /api/v1/keys/{id}/min-decryption-version``).
|
|
196
|
+
|
|
197
|
+
Raises ``ValidationError`` (400 ``invalid_min_decryption_version``) when out of range."""
|
|
198
|
+
response = await self._client.put(
|
|
199
|
+
f"/api/v1/keys/{key_id}/min-decryption-version",
|
|
200
|
+
json_data={"minDecryptionVersion": min_decryption_version},
|
|
201
|
+
)
|
|
202
|
+
return TransitKeyConfigResponse(**response)
|
|
203
|
+
|
|
169
204
|
async def get(self, key_id: UUID) -> KeyResponse:
|
|
170
205
|
"""
|
|
171
206
|
Get key details by ID.
|