Files
zeekay 7098a20d92 client: the document is the one cloud emits, named by commit
This client read hanzoai/openapi's hanzo.yaml at branch `main` and carried no
lock, so it named its document by something that moves and could not say which
bytes it was a projection of. It now reads what hanzoai/cloud emits, at the
commit .spec-lock names, digest-checked on every fetch — the same document and
the same four-line receipt every other Hanzo client carries. This repo's own
hanzo.yml had already declared that move; the script had not made it, so the
lane and the script named two different documents.

Nothing is lost, measured route by route: cloud's document is a strict SUPERSET
of the projection — 2479 operations against 2456, with 0 routes only in
hanzo.yaml and 23 only in cloud. The projection's one addition for this
language, a `default` response injected into every operation that declares
none, buys nothing here: a `default` with no content produces the same void
return that no `responses` does, so both documents yield the identical 834
void-returning methods. Generated, that is 2502 methods against 2455 committed.

The 7.24.0 generator floor is gone, and it was not wrong when written — both
defects it named lived in schemas the document no longer carries
(vector_NamedVectors under additionalProperties, framework_Document.docstatus).
Re-measured at the locked commit, 7.14.0 and 7.24.0 emit the same library apart
from the version string in each file's header and one doc comment on
ConsoleSettings::getOidcConfig. So this repo is on the fleet's 7.14.0 pin and is
no longer an exception on version. It stays out of sdks.yaml for one reason
only, and that one is measured too: without templates/cpp-restsdk the library
fails with 8 errors in ModelBase.h, and a template is a file that has to sit
beside the invocation.

One flag joins the invocation, and it is the fleet's own. o11y.GettableAgentCheckIn
publishes integration_config beside integrationConfig and removed_at beside
removedAt so older agents keep working; C++ camel-cases a property into its
accessor, so each pair declared one method twice and the library did not
compile. Renaming the accessor keeps both wire keys — all four are present in
the emitted model, each under its own name — which is what the python, go,
java, kotlin, ruby and php rows already do for the same two schemas.

Four flows changed route, none of them because of this move: their old
operations are untyped or absent in hanzo.yaml too, measured by regenerating
from it, so the committed tree simply predated the change. hello, chat, money
and tools move to the typed route for the same job; agent keeps its route and
reads the run from the typed list, because the run POST declares no body and no
response. Each says so in its own header, and the rule they follow is that an
example has to demonstrate a call the document types.

packageVersion leaves the invocation as inert: measured with a sentinel it
reaches the generator's own README and no file under include/ or src/, so the
library version in CMakeLists.txt is this repo's to choose and is coupled to
nothing.

Measured on aarch64 Ubuntu 24.04, g++ 13.3, generator 7.14.0, document
49389cf9: 2663 sources, library 0 errors, six examples 0 errors.
2026-08-14 20:28:34 -07:00

52 lines
2.1 KiB
C++

// money — what is left, then the usage that spent it.
//
// Operations: get_finance_credits (GET /v1/finance/credits), on FinanceApi
// get_finance_usage (GET /v1/finance/usage)
//
// Neither takes an org: both derive the tenant server-side from the JWT `owner`
// claim, so a key can only ever read its own money.
//
// NOT /v1/billing/balance and /v1/billing/usage. Those routes exist and this
// client carries them, but the document declares them with no parameters and no
// response schema, so the generated methods take nothing and return nothing.
// The /v1/finance pair is the typed one — a credit list with cents remaining,
// and a usage view whose window is a real parameter. An SDK reads a typed body
// here; it does not decode by hand.
//
// HANZO_API_KEY=hk-... ./build/examples/money
#include "hanzo.h"
#include "hanzo/api/FinanceApi.h"
int main() {
using namespace hanzo;
try {
api::FinanceApi finance(examples::client());
const auto credits = finance.getFinanceCredits().get();
int64_t remaining = 0;
for (const auto& credit : credits) {
remaining += credit->getRemainingCents();
}
examples::print(U("credits "), static_cast<int64_t>(credits.size()));
examples::print(U("remaining"), remaining);
// The window: 24h, 7d, 30d or 90d. Anything else, absent included, is
// 30d — so it is stated rather than left to the default.
std::shared_ptr<model::FinanceUsageView> usage =
finance.getFinanceUsage(boost::optional<utility::string_t>(U("7d"))).get();
examples::print(U("from "), usage->getStart());
examples::print(U("to "), usage->getEnd());
examples::print(U("spent "), static_cast<int64_t>(usage->getTotalCents()));
const auto lines = usage->getLines();
for (std::size_t i = 0; i < lines.size() && i < 5; ++i) {
examples::print(U(" ") + lines[i]->getLabel(),
static_cast<int64_t>(lines[i]->getCents()));
}
} catch (const std::exception& e) {
return examples::fail(U("finance"), e);
}
return 0;
}