mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-26 11:49:36 +00:00
The README offered the two key shapes as a permission split — pk- to read, sk- to write. cloud's own identity boundary says otherwise: middleware_identity returns nil for any pk- before it consults the key store, because a key meant for a browser bundle must not read. A pk- resolves to an org so a beacon can be attributed to a tenant, and that is all it does. Following the old sentence, a reader exports a pk- and every one of the five flows answers 403 — /v1/tools spells out why, "a validated principal is required" — and that refusal reads like a revoked key rather than the wrong shape of key. examples/client.py now refuses a pk- before the request goes out, the same argument that already rejects an unsendable access_token. Also: three status codes in example docstrings had drifted from what the API answers now (/v1/kv/keys/* 404s on every verb, /v1/automations/mcp 404s), and two dead files went with them — examples/.keep, whose directory has held real flows for a while, and scripts/mock, which reads a .stats.yml this repo does not have and which scripts/test already says is unnecessary.
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""store — a KV round-trip: provision a store, read it back, delete it.
|
|
|
|
POST /v1/kv post_kv provision
|
|
GET /v1/kv/{name} get_kv_by_name read back
|
|
DELETE /v1/kv/{name} delete_kv_by_name tear down
|
|
|
|
This is the PROVISIONING plane. The per-key data plane the spec also describes
|
|
(``/v1/kv/keys/{key}``) is not mounted anywhere — every verb 404s at
|
|
api.hanzo.ai, and kv.hanzo.ai 404s the whole prefix — so a set/get/delete
|
|
round-trip on keys would be an example that cannot run. These three answer 403
|
|
"a validated principal is required" unauthenticated, i.e. routed and gated.
|
|
|
|
The delete runs in ``finally``, so a failed read still tears the store down
|
|
rather than leaving it billable for the next run to collide with.
|
|
|
|
python -m examples.store
|
|
"""
|
|
|
|
import time
|
|
|
|
from hanzoai.cloud import ProvisionRequest, KvApi
|
|
|
|
from examples.client import client, run
|
|
|
|
NAME = f"example-store-{time.time_ns()}"
|
|
|
|
|
|
def main() -> None:
|
|
with client() as api:
|
|
kv = KvApi(api)
|
|
|
|
kv.post_kv(ProvisionRequest(name=NAME))
|
|
print(f"provisioned {NAME}")
|
|
|
|
try:
|
|
store = kv.get_kv_by_name(NAME)
|
|
print(f"read back: {store.name} · {store.kind} · status {store.status}")
|
|
print(f" host {store.host}:{store.port}")
|
|
finally:
|
|
kv.delete_kv_by_name(NAME)
|
|
print(f"deleted {NAME}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run(main)
|