mirror of
https://github.com/hanzoai/java-sdk.git
synced 2026-10-30 15:07:36 +00:00
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]>
63 lines
2.5 KiB
Java
63 lines
2.5 KiB
Java
package ai.hanzo.cloud.examples;
|
|
|
|
import ai.hanzo.Hanzo;
|
|
import ai.hanzo.cloud.ApiException;
|
|
import ai.hanzo.cloud.api.ProvisioningApi;
|
|
import ai.hanzo.cloud.model.ProvisioningProvisionRequest;
|
|
import ai.hanzo.cloud.model.ProvisioningProvisionResult;
|
|
import ai.hanzo.cloud.model.ProvisioningProvisionedResource;
|
|
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* store — provision a KV store, read it back, drop it.
|
|
*
|
|
* <p>Operations: {@code post_kv} — POST /v1/kv,
|
|
* {@code get_kv_by_name} — GET /v1/kv/{name},
|
|
* {@code delete_kv_by_name} — DELETE /v1/kv/{name}.
|
|
*
|
|
* <p>This is the provisioning plane — make a store, read it, drop it — and it
|
|
* is all there is: the document declares {@code /v1/kv} and {@code /v1/kv/{name}}
|
|
* and nothing else, because that is what apps/provisioning registers. The value
|
|
* plane (/v1/kv/keys/{key}) was authored in a hand-written spec that is gone,
|
|
* and the addresses went with it.
|
|
*
|
|
* <p>KV is org-scoped — without {@code X-Org-Id} every call here is
|
|
* 403 {@code "X-Org-Id required"}. The delete is in a {@code finally} so a
|
|
* failed read still cleans up instead of leaving a store behind for the next
|
|
* run to collide with.
|
|
*
|
|
* <pre>
|
|
* HANZO_API_KEY=hk-... HANZO_ORG_ID=my-org ./gradlew :examples:store
|
|
* </pre>
|
|
*/
|
|
public final class Store {
|
|
|
|
public static void main(String[] args) {
|
|
ProvisioningApi kv = new ProvisioningApi(Hanzo.client());
|
|
|
|
// Names are org-unique, so the example makes a fresh one rather than
|
|
// colliding with whatever the last run left.
|
|
String name = "sdk-example-" + UUID.randomUUID().toString().substring(0, 8);
|
|
|
|
try {
|
|
ProvisioningProvisionResult created = kv.postProvisioningKv(new ProvisioningProvisionRequest().name(name));
|
|
System.out.printf("created %s (%s)%n", created.getName(), created.getStatus());
|
|
|
|
ProvisioningProvisionedResource read = kv.getProvisioningKvByName(name);
|
|
System.out.printf("read %s host=%s port=%s status=%s%n",
|
|
read.getName(), read.getHost(), read.getPort(), read.getStatus());
|
|
} catch (ApiException e) {
|
|
System.err.printf("kv failed: HTTP %d %s%n", e.getCode(), e.getResponseBody());
|
|
System.exit(1);
|
|
} finally {
|
|
try {
|
|
kv.deleteProvisioningKvByName(name);
|
|
System.out.printf("deleted %s%n", name);
|
|
} catch (ApiException e) {
|
|
System.err.printf("delete %s failed: HTTP %d %s%n", name, e.getCode(), e.getResponseBody());
|
|
}
|
|
}
|
|
}
|
|
}
|