quantumapi 0.25.0__tar.gz → 0.27.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.25.0/quantumapi.egg-info → quantumapi-0.27.0}/PKG-INFO +228 -50
- {quantumapi-0.25.0 → quantumapi-0.27.0}/README.md +227 -49
- {quantumapi-0.25.0 → quantumapi-0.27.0}/pyproject.toml +1 -1
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/__init__.py +3 -1
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/__init__.py +12 -0
- quantumapi-0.27.0/quantumapi/client/api_keys.py +73 -0
- quantumapi-0.27.0/quantumapi/client/applications.py +368 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/async_client.py +12 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/base.py +11 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/compliance.py +6 -4
- quantumapi-0.27.0/quantumapi/client/dynamic_secrets.py +113 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/encryption.py +12 -5
- quantumapi-0.27.0/quantumapi/client/external_key_stores.py +163 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/keys.py +130 -74
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/log_streams.py +14 -7
- quantumapi-0.27.0/quantumapi/client/pki.py +132 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/secrets.py +35 -24
- quantumapi-0.27.0/quantumapi/client/ssh.py +108 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/sync_client.py +6 -0
- quantumapi-0.27.0/quantumapi/client/team.py +85 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/usage.py +13 -1
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/errors/__init__.py +4 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/errors/exceptions.py +20 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/__init__.py +150 -0
- quantumapi-0.27.0/quantumapi/models/api_keys.py +134 -0
- quantumapi-0.27.0/quantumapi/models/applications.py +256 -0
- quantumapi-0.27.0/quantumapi/models/dynamic_secrets.py +135 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/encryption.py +27 -3
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/end_users.py +5 -0
- quantumapi-0.27.0/quantumapi/models/external_key_stores.py +216 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/keys.py +95 -8
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/log_streams.py +24 -4
- quantumapi-0.27.0/quantumapi/models/pki.py +171 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/secrets.py +63 -12
- quantumapi-0.27.0/quantumapi/models/ssh.py +164 -0
- quantumapi-0.27.0/quantumapi/models/team.py +76 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/usage.py +29 -1
- {quantumapi-0.25.0 → quantumapi-0.27.0/quantumapi.egg-info}/PKG-INFO +228 -50
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi.egg-info/SOURCES.txt +18 -0
- quantumapi-0.27.0/tests/test_applications.py +238 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_compliance_logstreams_usage.py +89 -8
- quantumapi-0.27.0/tests/test_dynamic_secrets.py +232 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_end_users.py +22 -1
- quantumapi-0.27.0/tests/test_external_key_stores.py +315 -0
- quantumapi-0.27.0/tests/test_keys_encryption_secrets_contract.py +601 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_parity.py +2 -2
- quantumapi-0.27.0/tests/test_pki_ssh_api_keys.py +500 -0
- quantumapi-0.27.0/tests/test_team.py +143 -0
- quantumapi-0.25.0/quantumapi/client/applications.py +0 -180
- quantumapi-0.25.0/quantumapi/models/applications.py +0 -120
- {quantumapi-0.25.0 → quantumapi-0.27.0}/LICENSE +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/audit.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/end_users.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/health.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/qrng.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/resource_groups.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/roles.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/client/transit.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/audit.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/compliance.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/health.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/qrng.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/resource_groups.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/roles.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/models/transit.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi/py.typed +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi.egg-info/dependency_links.txt +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi.egg-info/requires.txt +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/quantumapi.egg-info/top_level.txt +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/setup.cfg +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_audit.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_data_keys.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_exceptions.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_models.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_qrng.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_secret_history_share.py +0 -0
- {quantumapi-0.25.0 → quantumapi-0.27.0}/tests/test_transit.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantumapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.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
|
|
@@ -55,7 +55,9 @@ Official Python SDK for [QuantumAPI](https://quantumapi.eu) - The European quant
|
|
|
55
55
|
- 🗄️ **Secret Vault** - Securely store and manage secrets with versioning
|
|
56
56
|
- 👤 **User Management** - Create and manage end-users with roles
|
|
57
57
|
- 🔍 **Audit Logs** - Query comprehensive audit trails
|
|
58
|
-
-
|
|
58
|
+
- 📈 **Usage** - Read the tenant's storage usage (`client.usage`)
|
|
59
|
+
- 📜 **PKI and SSH CA** - Run X.509 and SSH certificate authorities (`client.pki`, `client.ssh`)
|
|
60
|
+
- 🗝️ **API Keys** - Create, restrict and revoke the tenant's API keys (`client.api_keys`)
|
|
59
61
|
- 🚀 **Async/Await Support** - Full async support with httpx
|
|
60
62
|
- ⚡ **Automatic Retries** - Exponential backoff for transient failures
|
|
61
63
|
- 📊 **Rate Limiting** - Client-side rate limit tracking
|
|
@@ -157,18 +159,21 @@ plaintext = await client.encryption.decrypt(
|
|
|
157
159
|
encrypted_payload=result.encrypted_payload
|
|
158
160
|
)
|
|
159
161
|
|
|
160
|
-
# Sign data
|
|
162
|
+
# Sign data (data is base64)
|
|
163
|
+
import base64
|
|
164
|
+
data = base64.b64encode(b"message to sign").decode()
|
|
161
165
|
signature = await client.encryption.sign(
|
|
162
|
-
data=
|
|
166
|
+
data=data,
|
|
163
167
|
key_id="signing-key-id"
|
|
164
168
|
)
|
|
165
169
|
|
|
166
170
|
# Verify signature
|
|
167
|
-
|
|
168
|
-
data=
|
|
171
|
+
result = await client.encryption.verify(
|
|
172
|
+
data=data,
|
|
169
173
|
signature=signature.signature,
|
|
170
174
|
key_id="signing-key-id"
|
|
171
175
|
)
|
|
176
|
+
print(result.is_valid)
|
|
172
177
|
```
|
|
173
178
|
|
|
174
179
|
### Audit Client
|
|
@@ -203,30 +208,40 @@ key = await client.keys.generate(
|
|
|
203
208
|
set_as_default=True
|
|
204
209
|
)
|
|
205
210
|
|
|
206
|
-
# List keys
|
|
211
|
+
# List keys (sent as ?type=encryption&page=1&pageSize=50)
|
|
207
212
|
keys = await client.keys.list(
|
|
208
213
|
key_type="encryption",
|
|
209
214
|
page=1,
|
|
210
|
-
page_size=50
|
|
215
|
+
page_size=50,
|
|
216
|
+
include_inactive=False,
|
|
211
217
|
)
|
|
218
|
+
print(keys.total_count, keys.has_more)
|
|
212
219
|
|
|
213
220
|
# Get key details
|
|
214
221
|
key = await client.keys.get(key_id="key-id")
|
|
215
222
|
|
|
216
|
-
# Rotate key
|
|
217
|
-
|
|
223
|
+
# Rotate key: new version, same key id
|
|
224
|
+
rotation = await client.keys.rotate(key_id="key-id")
|
|
225
|
+
print(rotation.previous_version, "->", rotation.new_version, rotation.rotated_at)
|
|
218
226
|
|
|
219
|
-
#
|
|
220
|
-
await client.keys.
|
|
227
|
+
# Update metadata (only the arguments you pass are sent)
|
|
228
|
+
await client.keys.update("key-id", description="Orders KEK", labels=["prod"], is_favorite=True)
|
|
229
|
+
|
|
230
|
+
# Export the public key (PEM by default)
|
|
231
|
+
pem = await client.keys.export_public_key("key-id")
|
|
232
|
+
|
|
233
|
+
# Schedule deletion after a 7-90 day grace period (default 30)
|
|
234
|
+
scheduled = await client.keys.delete(key_id="key-id", schedule_days=30)
|
|
235
|
+
print(scheduled.scheduled_deletion_date)
|
|
221
236
|
|
|
222
237
|
# Set default key
|
|
223
|
-
await client.keys.set_default(key_id="key-id"
|
|
238
|
+
await client.keys.set_default(key_id="key-id")
|
|
224
239
|
```
|
|
225
240
|
|
|
226
241
|
### Secrets Client
|
|
227
242
|
|
|
228
243
|
```python
|
|
229
|
-
# Create secret
|
|
244
|
+
# Create secret: returns the metadata (SecretResponse); the value is not echoed back
|
|
230
245
|
secret = await client.secrets.create(
|
|
231
246
|
name="api-key",
|
|
232
247
|
value="secret_value",
|
|
@@ -301,28 +316,21 @@ await client.secrets.revoke_shared_link(links.links[0].id)
|
|
|
301
316
|
opened = await client.secrets.open_shared_link(link.token, password="optional-password")
|
|
302
317
|
```
|
|
303
318
|
|
|
304
|
-
###
|
|
319
|
+
### Team Client
|
|
320
|
+
|
|
321
|
+
The people who work in your tenant.
|
|
305
322
|
|
|
306
323
|
```python
|
|
307
|
-
|
|
308
|
-
user = await client.users.create(
|
|
309
|
-
email="user@example.com",
|
|
310
|
-
name="John Doe",
|
|
311
|
-
role="developer"
|
|
312
|
-
)
|
|
324
|
+
from quantumapi.models.team import TeamRole
|
|
313
325
|
|
|
314
|
-
|
|
315
|
-
|
|
326
|
+
team = await client.team.list_members()
|
|
327
|
+
print(team.total_count, team.mfa_enabled_count)
|
|
316
328
|
|
|
317
|
-
|
|
318
|
-
await client.users.update(
|
|
319
|
-
user_id="user-id",
|
|
320
|
-
name="Jane Doe",
|
|
321
|
-
role="admin"
|
|
322
|
-
)
|
|
329
|
+
invitation = await client.team.invite("developer@example.com", TeamRole.DEVELOPER)
|
|
323
330
|
|
|
324
|
-
|
|
325
|
-
await client.
|
|
331
|
+
await client.team.update_member_role(member_id, TeamRole.ADMIN)
|
|
332
|
+
await client.team.disable_member(member_id)
|
|
333
|
+
await client.team.revoke_invitation(invitation.id)
|
|
326
334
|
```
|
|
327
335
|
|
|
328
336
|
### End-Users Client
|
|
@@ -382,22 +390,6 @@ csv_data = await client.audit.export(
|
|
|
382
390
|
)
|
|
383
391
|
```
|
|
384
392
|
|
|
385
|
-
### Billing Client
|
|
386
|
-
|
|
387
|
-
```python
|
|
388
|
-
# Get subscription details
|
|
389
|
-
subscription = await client.billing.get_subscription()
|
|
390
|
-
|
|
391
|
-
# Get usage metrics
|
|
392
|
-
usage = await client.billing.get_usage(
|
|
393
|
-
start_date="2024-01-01",
|
|
394
|
-
end_date="2024-01-31"
|
|
395
|
-
)
|
|
396
|
-
|
|
397
|
-
# List invoices
|
|
398
|
-
invoices = await client.billing.list_invoices()
|
|
399
|
-
```
|
|
400
|
-
|
|
401
393
|
### Health Client
|
|
402
394
|
|
|
403
395
|
```python
|
|
@@ -471,8 +463,8 @@ acceptance = await client.compliance.accept_risk(
|
|
|
471
463
|
review_date=datetime(2027, 1, 31, tzinfo=timezone.utc),
|
|
472
464
|
)
|
|
473
465
|
|
|
474
|
-
# Revoke it (
|
|
475
|
-
|
|
466
|
+
# Revoke it (204 No Content: returns None; NotFoundError if none is open)
|
|
467
|
+
await client.compliance.revoke_risk_acceptance("dora", "operational-monitoring")
|
|
476
468
|
|
|
477
469
|
# Full history, newest first, including revoked and expired acceptances
|
|
478
470
|
history = await client.compliance.list_risk_acceptances()
|
|
@@ -510,6 +502,7 @@ for d in files.days:
|
|
|
510
502
|
|
|
511
503
|
# Download one day as raw gzip bytes (not decompressed; may hold several gzip members,
|
|
512
504
|
# which gzip.decompress handles). day is a datetime.date or "YYYY-MM-DD".
|
|
505
|
+
# Each call sends a new Idempotency-Key (UUID), reused on the SDK's retries, so a retried download is audited once.
|
|
513
506
|
data = await client.log_streams.download_file(stream.id, date(2026, 10, 24))
|
|
514
507
|
|
|
515
508
|
# Or write it to disk. A directory gets the default name auth-logs-<day>.ndjson.gz.
|
|
@@ -518,6 +511,191 @@ path = await client.log_streams.download_file_to(stream.id, "2026-10-24", "./arc
|
|
|
518
511
|
await client.log_streams.delete(stream.id)
|
|
519
512
|
```
|
|
520
513
|
|
|
514
|
+
### Dynamic Secrets Client
|
|
515
|
+
|
|
516
|
+
Short-lived PostgreSQL or MySQL credentials: each request creates a user on your database and the lease drops it
|
|
517
|
+
when it expires or is revoked. A failure on the target database raises `DynamicSecretBackendError`
|
|
518
|
+
(`error_code`: `backend_unreachable`, `backend_authentication_failed`, `backend_statement_failed`,
|
|
519
|
+
`backend_invalid_configuration`, `backend_not_supported`; `message` is the API message). It is never retried.
|
|
520
|
+
|
|
521
|
+
```python
|
|
522
|
+
from quantumapi import DynamicSecretBackendError
|
|
523
|
+
from quantumapi.models import CreateDynamicSecretConfigRequest, UpdateDynamicSecretConfigRequest
|
|
524
|
+
|
|
525
|
+
config = await client.dynamic_secrets.create(
|
|
526
|
+
CreateDynamicSecretConfigRequest(
|
|
527
|
+
name="orders-db",
|
|
528
|
+
backend_type="PostgreSql", # or "MySql"
|
|
529
|
+
connection_string="Host=db.internal;Database=orders;Username=admin;Password=...",
|
|
530
|
+
creation_statement="CREATE ROLE {{name}} LOGIN PASSWORD '{{password}}'",
|
|
531
|
+
revocation_statement="DROP ROLE {{name}}",
|
|
532
|
+
max_leases=10,
|
|
533
|
+
)
|
|
534
|
+
)
|
|
535
|
+
|
|
536
|
+
try:
|
|
537
|
+
creds = await client.dynamic_secrets.create_credentials(config.id, ttl_seconds=600)
|
|
538
|
+
print(creds.username, creds.password, creds.expires_at) # the password is shown once
|
|
539
|
+
except DynamicSecretBackendError as e:
|
|
540
|
+
print(e.error_code, e.message)
|
|
541
|
+
|
|
542
|
+
leases = await client.dynamic_secrets.list_leases(config.id, status="Active")
|
|
543
|
+
await client.dynamic_secrets.renew(config.id, leases.leases[0].id, ttl_seconds=300)
|
|
544
|
+
await client.dynamic_secrets.revoke(config.id, leases.leases[0].id)
|
|
545
|
+
result = await client.dynamic_secrets.revoke_all(config.id) # result.failed: leases still active on the target
|
|
546
|
+
|
|
547
|
+
await client.dynamic_secrets.update(config.id, UpdateDynamicSecretConfigRequest(max_ttl_seconds=7200))
|
|
548
|
+
await client.dynamic_secrets.disable(config.id) # and enable(config.id)
|
|
549
|
+
await client.dynamic_secrets.delete(config.id)
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### External Key Stores Client
|
|
553
|
+
|
|
554
|
+
Let AWS (XKS) or Azure (Managed HSM) use QuantumAPI as their external key store. Reads need scope
|
|
555
|
+
`keys:read`; writes need `keys:write` and a tenant owner or admin.
|
|
556
|
+
|
|
557
|
+
```python
|
|
558
|
+
from quantumapi.models import ExternalKeyStoreType, azure_configuration
|
|
559
|
+
|
|
560
|
+
# AWS: the first access key comes with the connection.
|
|
561
|
+
created = await client.external_key_stores.create(ExternalKeyStoreType.AWS, "prod-aws")
|
|
562
|
+
cred = created.credential
|
|
563
|
+
# The secret access key is shown ONLY ONCE, here. Save it now: it cannot be read again.
|
|
564
|
+
print(cred.access_key_id, cred.secret_access_key)
|
|
565
|
+
open("xks-proxy-config.json", "w").write(cred.aws_proxy_configuration.to_json()) # file AWS expects
|
|
566
|
+
|
|
567
|
+
# Azure: build the configuration string with the helper.
|
|
568
|
+
store = (
|
|
569
|
+
await client.external_key_stores.create(
|
|
570
|
+
"Azure",
|
|
571
|
+
"prod-azure",
|
|
572
|
+
configuration=azure_configuration("hsm-client.example.eu", ["<root CA PEM>"], ["pool-1"]),
|
|
573
|
+
)
|
|
574
|
+
).connection
|
|
575
|
+
|
|
576
|
+
key = await client.external_key_stores.create_key(store.id, "orders-key", key_type="Rsa3072")
|
|
577
|
+
await client.external_key_stores.disable_key(store.id, key.id) # and enable_key(...)
|
|
578
|
+
rows = await client.external_key_stores.activity(store.id, key_id=key.id, limit=20)
|
|
579
|
+
|
|
580
|
+
new = await client.external_key_stores.create_access_key(created.connection.id) # rotation; secret shown once
|
|
581
|
+
await client.external_key_stores.revoke_access_key(created.connection.id, cred.id)
|
|
582
|
+
await client.external_key_stores.disconnect(store.id) # kill switch; reconnect(store.id) undoes it
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
A 409 `credential_limit` (too many access keys) raises `ConflictError`; a 400
|
|
586
|
+
`invalid_configuration` raises `ValidationError` with the reason in `message`.
|
|
587
|
+
|
|
588
|
+
### PKI Client (X.509)
|
|
589
|
+
|
|
590
|
+
Certificate authorities and certificates under `/api/v1/pki`. Keys are RSA (CA 4096 bits, certificates
|
|
591
|
+
2048 bits by default). The CA private key is encrypted at rest and never returned; a certificate's private
|
|
592
|
+
key is returned once, by `issue_certificate`.
|
|
593
|
+
|
|
594
|
+
```python
|
|
595
|
+
from quantumapi.models import CreateCertificateAuthorityRequest, IssueCertificateRequest
|
|
596
|
+
|
|
597
|
+
# Root CA (10 years by default). Set parent_ca_id for an intermediate CA (5 years by default).
|
|
598
|
+
ca = await client.pki.create_ca(
|
|
599
|
+
CreateCertificateAuthorityRequest(name="acme-root", organization="Acme", country="ES")
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
cert = await client.pki.issue_certificate(
|
|
603
|
+
IssueCertificateRequest(
|
|
604
|
+
ca_id=ca.id,
|
|
605
|
+
common_name="api.acme.eu",
|
|
606
|
+
dns_names=["api.acme.eu"],
|
|
607
|
+
ip_addresses=["10.0.0.5"],
|
|
608
|
+
validity_days=90, # default 365, capped at the CA's expiry
|
|
609
|
+
)
|
|
610
|
+
)
|
|
611
|
+
# The private key is shown ONLY ONCE, here.
|
|
612
|
+
open("api.crt", "w").write(cert.certificate_pem)
|
|
613
|
+
open("api.key", "w").write(cert.private_key_pem)
|
|
614
|
+
|
|
615
|
+
certs = await client.pki.list_certificates(ca_id=ca.id, status="Active") # both filters optional
|
|
616
|
+
for c in certs.certificates:
|
|
617
|
+
print(c.serial_number, c.common_name, c.status, c.not_after)
|
|
618
|
+
|
|
619
|
+
detail = await client.pki.get_certificate(cert.id) # PEM, SANs, revocation data
|
|
620
|
+
result = await client.pki.revoke_certificate(cert.id, reason="keyCompromise") # rebuilds the CA's CRL
|
|
621
|
+
print(result.revoked, result.serial_number)
|
|
622
|
+
|
|
623
|
+
ca_pem = await client.pki.get_ca_certificate(ca.id) # PEM text
|
|
624
|
+
crl_pem = await client.pki.get_crl(ca.id) # PEM text, or None before the first revocation
|
|
625
|
+
cas = await client.pki.list_cas() # cas.authorities
|
|
626
|
+
await client.pki.disable_ca(ca.id) # and enable_ca(ca.id); a disabled CA cannot issue
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
A duplicate CA name raises `ConflictError`; an unknown or disabled CA `NotFoundError`; an expired CA or
|
|
630
|
+
revoking twice raises `ValidationError` (`ca_expired`, `already_revoked`).
|
|
631
|
+
|
|
632
|
+
### SSH Client
|
|
633
|
+
|
|
634
|
+
SSH certificate authorities and user certificates under `/api/v1/ssh`. Servers trust the CA public key
|
|
635
|
+
(`TrustedUserCAKeys`); users get short-lived certificates for their own public keys.
|
|
636
|
+
|
|
637
|
+
```python
|
|
638
|
+
from quantumapi.models import CreateSshCaRequest, SignSshKeyRequest, UpdateSshCaRequest
|
|
639
|
+
|
|
640
|
+
# key_type: ed25519 (default), ecdsa-p256, ecdsa-p384 or rsa-4096 (SSH_CA_KEY_TYPES).
|
|
641
|
+
# TTLs default to 28800 s (8 h) and 86400 s (24 h).
|
|
642
|
+
ca = await client.ssh.create_ca(CreateSshCaRequest(name="prod-ssh", key_type="ed25519"))
|
|
643
|
+
open("trusted_user_ca_keys.pub", "w").write(await client.ssh.get_ca_public_key(ca.id))
|
|
644
|
+
|
|
645
|
+
cert = await client.ssh.sign(
|
|
646
|
+
SignSshKeyRequest(
|
|
647
|
+
ca_id=ca.id,
|
|
648
|
+
public_key=open("id_ed25519.pub").read(),
|
|
649
|
+
principals=["deploy"], # at least one username
|
|
650
|
+
ttl_seconds=3600, # default: the CA's default TTL, capped at its max TTL
|
|
651
|
+
)
|
|
652
|
+
)
|
|
653
|
+
open("id_ed25519-cert.pub", "w").write(cert.signed_certificate)
|
|
654
|
+
|
|
655
|
+
certs = await client.ssh.list_certificates(ca_id=ca.id) # ca_id optional
|
|
656
|
+
for c in certs.certificates:
|
|
657
|
+
print(c.serial_number, c.principal_list, c.valid_before, c.is_revoked, c.is_expired)
|
|
658
|
+
|
|
659
|
+
await client.ssh.revoke_certificate(cert.id)
|
|
660
|
+
await client.ssh.update_ca(ca.id, UpdateSshCaRequest(max_ttl_seconds=43200))
|
|
661
|
+
await client.ssh.disable_ca(ca.id) # and enable_ca(ca.id); also list_cas(), get_ca(ca.id)
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
In the list, `principals` is a comma-separated string (`principal_list` splits it); in the result of
|
|
665
|
+
`sign` it is a list.
|
|
666
|
+
|
|
667
|
+
### API Keys Client
|
|
668
|
+
|
|
669
|
+
The tenant's API keys under `/api/v1/api-keys`. The full key value is returned once, by `create`.
|
|
670
|
+
|
|
671
|
+
```python
|
|
672
|
+
from datetime import datetime, timezone
|
|
673
|
+
from quantumapi.models import ApiKeyLabelsItem, CreateApiKeyRequest, UpdateApiKeyRequest
|
|
674
|
+
|
|
675
|
+
created = await client.api_keys.create(
|
|
676
|
+
CreateApiKeyRequest(
|
|
677
|
+
name="ci-deploy",
|
|
678
|
+
scopes=["secrets:read"],
|
|
679
|
+
environment="production", # development, staging or production; None = no restriction
|
|
680
|
+
allowed_ips=["203.0.113.5/32"],
|
|
681
|
+
expires_at=datetime(2027, 6, 30, tzinfo=timezone.utc),
|
|
682
|
+
# no_vault=True skips the copy the platform stores as a vault secret (created.vault_secret_id)
|
|
683
|
+
)
|
|
684
|
+
)
|
|
685
|
+
print(created.api_key) # shown ONLY ONCE
|
|
686
|
+
|
|
687
|
+
keys = await client.api_keys.list()
|
|
688
|
+
for k in keys.api_keys:
|
|
689
|
+
print(k.prefix, k.name, k.is_active, k.last_used_at, k.request_count)
|
|
690
|
+
|
|
691
|
+
# Only the fields you set change. [] or "" removes a restriction.
|
|
692
|
+
await client.api_keys.update(created.id, UpdateApiKeyRequest(allowed_ips=[], labels=["ci"]))
|
|
693
|
+
await client.api_keys.bulk_update_labels([ApiKeyLabelsItem(api_key_id=created.id, labels=["prod"])])
|
|
694
|
+
tags = await client.api_keys.list_tags()
|
|
695
|
+
|
|
696
|
+
await client.api_keys.revoke(created.id) # cannot be undone; returns None
|
|
697
|
+
```
|
|
698
|
+
|
|
521
699
|
### Usage Client
|
|
522
700
|
|
|
523
701
|
Storage occupied by the tenant this month, in total and per category (`secrets`, `keys`,
|
|
@@ -752,7 +930,7 @@ See [CHANGELOG.md](CHANGELOG.md) for a history of changes to this SDK.
|
|
|
752
930
|
|
|
753
931
|
## Security
|
|
754
932
|
|
|
755
|
-
For security concerns, please email
|
|
933
|
+
For security concerns, please email yo@victorz.cloud. Do not create public issues for security vulnerabilities.
|
|
756
934
|
|
|
757
935
|
## Links
|
|
758
936
|
|