Typed, auto-generated admin client for the OpenSwarm product-analytics private (read/ops) API.
Project description
swarm_analytics_private
A typed, auto-generated Python client for the OpenSwarm product-analytics
private API — the internal read/ops surface under /private (the admin
"Tables" explorer and the classify jobs/runs + manual triggers).
This is the sibling of swarm_analytics (the public ingest SDK), but a
different kind of client: where the public SDK is fire-and-forget ingest, this
one is blocking request/response — every method issues one HTTP call and
returns a validated pydantic model.
Internal tooling only. Authentication is a static admin key sent in the
X-Admin-Keyheader, not an install bearer token. Don't distribute this to end users alongside the public SDK.
Why it's hard to call wrong
- One credential, sent everywhere. The client only ever sends the admin key;
generation fails unless every
/privateroute is gated byrequire_admin. - Responses are vendored verbatim from the service, so the client validates
with the exact pydantic schema the server returns.
status/triggerstayLiterals. - Params are typed. Path and query params become typed keyword arguments;
Nonequery params are dropped so an omitted optional means "server default".
Install
pip install ./sdk-private # from the repo root
Usage
from swarm_analytics_private import AdminClient
with AdminClient(base_url="https://analytics.openswarm.ai", admin_key=ADMIN_KEY) as client:
# Reader — generic DB introspection
tables = client.reader.tables() # -> TablesResponse
rows = client.reader.table(name="agent", limit=50, # -> TableRowsResponse
sort="created_at", dir="desc",
filters={"dashboard_id": "dash_1"})
shape = client.reader.json_shape(name="session_message") # -> JsonShapeResponse
# Classify — jobs/runs + manual triggers
jobs = client.classify.list_jobs() # -> JobsResponse
runs = client.classify.list_runs(job_id="classify_agents", limit=20) # -> RunsResponse
result = client.classify.run_clio() # -> ClassifyAgentsRecord (POST)
cluster = client.classify.run_cluster() # -> ClassificationClusterRecord (POST)
The filters keyword on reader.table is the typed surface over the endpoint's
arbitrary equality-filter feature (any column name → column = value).
Regenerating (auto-generated — do not hand-edit _generated/)
The models and namespaces under src/swarm_analytics_private/_generated/ are
produced from the live service. Regenerate whenever the backend's private routes
or response models change:
PYTHONPATH=<repo_root> python sdk-private/generate.py
ROUTE_SPECS in generate.py (namespace + method name per endpoint) is the only
human input; it is cross-checked against the live app, and every route must be
admin-gated and declare a pydantic response_model, so a new/removed endpoint —
or a route that returns an untyped dict — fails generation rather than drifting
silently.
Drift check (CI)
PYTHONPATH=<repo_root> python sdk-private/generate.py --check
Exits non-zero if the committed _generated/ output is stale. The same guard runs
as tests/test_drift.py.
Tests
cd sdk-private && PYTHONPATH=<repo_root> python -m pytest tests -q
Covers the admin-key header, None-param dropping, path interpolation, response
validation, and the drift check.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarm_analytics_private-0.1.0.tar.gz.
File metadata
- Download URL: swarm_analytics_private-0.1.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99d6e71d93627a9cd245d05bd09d3d76191f4b56c72e7f5a75b4422c94715d0c
|
|
| MD5 |
4d319165a7c36fae7ea1a2a67d1d386d
|
|
| BLAKE2b-256 |
a3bc8a7af894f5250c3212bb8c6088d64817c9da645397e1dd6b22bda48290ce
|
File details
Details for the file swarm_analytics_private-0.1.0-py3-none-any.whl.
File metadata
- Download URL: swarm_analytics_private-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6f1b9edd970cf39bbbcc1c5a19763a5f893f02a55df539e2970a9b0f779ce9b
|
|
| MD5 |
d03ae7cafc7c020a617a525498f22e6a
|
|
| BLAKE2b-256 |
f0de983a4b5d1d0560b5db261d07e1af9ef40cff9468b40e2f4931e316f23962
|