mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
sdk: ship the generated cloud client — /v1/admin/plugins is reachable
pkg/hanzoai/cloud/ (2163 files) has existed on disk untracked and never shipped.
This commits it, so the operator surface cloud already serves is finally callable:
AdminApi.plugin_admin_plugins / _enable_plugin / _disable_plugin / _reload_plugin
Generated by hanzoai/openapi `generate.py python` from hanzo.yaml (1885 paths,
69 merged per-service specs). Consumed: cloud 8143fc0e, openapi f581a0e.
One driver, so delete the second one. scripts/generate.sh fetched the spec itself
and then did `rm -rf pkg/hanzoai` + copied generator output over it — which would
have deleted the hand-written config/mcp/protocols/session/zap/api_response
modules AND the new cloud/ tree. Nothing referenced it. hanzoai/openapi's
generate.py + sdks.yaml is the only way now; LLM.md records the pipeline.
`import hanzoai.cloud` raised ImportError as generated. hanzo.yaml has 23 tag
groups differing only by case; openapi-generator maps both spellings to one
module, and for AI/ai, API Keys/api-keys and MCP/mcp it then emits imports for
classes it never wrote (AiApi vs AIApi). Stripped those 9 dead lines. The same
collision silently drops 127 of the 411 operations in those groups — that one is
upstream and only a single tag spelling per service fixes it; noted in LLM.md.
Version: 3.1.1 -> 3.1.2, patch only. pkg/hanzoai/__init__.py said 1.0.0 (the
generator default) — now resolved from the installed distribution, same pattern
as hanzo_cli/hanzo_iam in f453dae8. uv.lock refreshed to match committed pkg
versions. test_smoke.py locks the cloud import, the four plugin ops, and that
__version__ equals the distribution: 6 passed.
Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate the Hanzo Python client (`hanzoai`) from the unified OpenAPI spec.
|
||||
#
|
||||
# The ONE way: hanzoai/openapi `hanzo.yaml` is the single source of truth. The
|
||||
# `hanzoai` package under pkg/ is generated from it with openapi-generator — no
|
||||
# Stainless. Other pkg/hanzo-* packages are hand-written and untouched here.
|
||||
#
|
||||
# ./scripts/generate.sh # pulls spec from hanzoai/openapi@main
|
||||
# SPEC=/path/to/hanzo.yaml ./scripts/generate.sh # local spec override
|
||||
#
|
||||
# Requires: java 17+, curl.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
GENERATOR_VERSION="${GENERATOR_VERSION:-7.14.0}"
|
||||
# hanzoai/openapi is private — fetch hanzo.yaml through the GitHub API with a
|
||||
# token (SPEC_TOKEN). raw.githubusercontent.com only serves public repos (it
|
||||
# 404s on a private repo). Local override still honored: SPEC=/path/to/hanzo.yaml.
|
||||
SPEC_REPO="${SPEC_REPO:-hanzoai/openapi}"
|
||||
SPEC_REF="${SPEC_REF:-main}"
|
||||
SPEC="${SPEC:-}"
|
||||
JAR="${JAR:-/tmp/openapi-generator-cli-${GENERATOR_VERSION}.jar}"
|
||||
|
||||
if [ -z "$SPEC" ]; then
|
||||
: "${SPEC_TOKEN:?SPEC_TOKEN required to read private $SPEC_REPO}"
|
||||
SPEC="$(mktemp)"
|
||||
curl -fsSL -H "Authorization: Bearer $SPEC_TOKEN" -H "Accept: application/vnd.github.raw" \
|
||||
"https://api.github.com/repos/$SPEC_REPO/contents/hanzo.yaml?ref=$SPEC_REF" -o "$SPEC"
|
||||
fi
|
||||
if [ ! -f "$JAR" ]; then
|
||||
curl -fsSL -o "$JAR" \
|
||||
"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${GENERATOR_VERSION}/openapi-generator-cli-${GENERATOR_VERSION}.jar"
|
||||
fi
|
||||
|
||||
OUT="$(mktemp -d)"
|
||||
java -jar "$JAR" generate \
|
||||
-i "$SPEC" -g python \
|
||||
--additional-properties=packageName=hanzoai,projectName=hanzoai,library=urllib3 \
|
||||
--global-property=apiTests=false,modelTests=false,apiDocs=false,modelDocs=false \
|
||||
--git-user-id=hanzoai --git-repo-id=python-sdk \
|
||||
-o "$OUT"
|
||||
|
||||
# Only the package itself lives in this monorepo (pkg/hanzoai). The generated
|
||||
# pyproject/setup/README/etc. are discarded — the repo root owns build config.
|
||||
rm -rf pkg/hanzoai
|
||||
cp -r "$OUT/hanzoai" pkg/hanzoai
|
||||
echo "generated $(find pkg/hanzoai -name '*.py' | wc -l) python files into pkg/hanzoai"
|
||||
Reference in New Issue
Block a user