Files
zooqueenandHanzo Dev fb2ed33d11 Regenerate the client and move the examples to the classes it has
The 09-06 regeneration renamed AgentsApi and ToolsApi to AgentApi and ToolApi
and the examples kept the old names, so examples-build failed on main. hanzoai/ci
gates a client-lane move on that same test, so every release dispatch since has
stopped before regenerating and the jar stayed at 8.5.156, a client with no
postDecisions.

The client is regenerated from the document api.hanzo.ai serves
(hanzo-inc/cloud 151878a3c, sha256 00564264), which now namespaces its schemas
(AgentAgentView, ProvisioningProvisionRequest, ToolToolList) and types chat
completions, so the examples are rewritten against it: agent, store and tools
use the new names and paths, and chat sends a prompt and prints the reply
instead of a status. .spec-lock is left to the lane, whose next move records the
ref it was handed.

hanzo.yml now names where the version lives, scripts/version, so the cut
rewrites build.gradle to the release number and the push to main publishes it
through release.yml; without it the cut tagged a build.gradle Central already
served and nothing published. The README names the 8.5 line (8.5.+, [8.5,8.6))
rather than a patch, because each release cuts a patch into build.gradle alone,
and scripts/readme checks the line instead of a number that goes stale.

Co-authored-by: Hanzo Dev <[email protected]>
2026-10-04 13:51:55 -07:00

48 lines
1.7 KiB
Java

package ai.hanzo.cloud.examples;
import ai.hanzo.Hanzo;
import ai.hanzo.cloud.ApiException;
import ai.hanzo.cloud.api.AccountApi;
import ai.hanzo.cloud.model.AccountApiKey;
import ai.hanzo.cloud.model.AccountApiKeyList;
import java.util.List;
/**
* hello — prove the key works, and print what it can reach.
*
* <p>Operation: {@code get_account_keys} — GET /v1/account/keys.
*
* <p>This is the call that says no. With no key, or a bogus one, the route
* answers 403 {@code {"status":403,"code":"forbidden","error":"sign in to
* manage API keys"}} while GET /v1/account/keys-zzq9 answers 404 — so the refusal is
* this route refusing rather than a wildcard door, which is what makes it a
* usable proof that a credential works. The three obvious identity routes were
* disqualified for answering 200 to a caller with no credential at all;
* {@code flows.yaml} records the probe.
*
* <pre>
* HANZO_API_KEY=hk-... ./gradlew :examples:hello
* </pre>
*/
public final class Hello {
public static void main(String[] args) {
AccountApi keys = new AccountApi(Hanzo.client());
try {
AccountApiKeyList mine = keys.getAccountKeys();
List<AccountApiKey> owned = mine.getKeys();
if (owned == null || owned.isEmpty()) {
System.out.println("the key is good, and it owns no keys of its own");
return;
}
for (AccountApiKey key : owned) {
System.out.printf("%-8s %-24s %s%n", key.getType(), key.getPrefix(), key.getCreatedAt());
}
} catch (ApiException e) {
System.err.printf("keys refused: HTTP %d %s%n", e.getCode(), e.getResponseBody());
System.exit(1);
}
}
}