-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDurableApiOperations.java
More file actions
40 lines (36 loc) · 1.33 KB
/
DurableApiOperations.java
File metadata and controls
40 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Durable API operations — Java example.
*
* Submit a report generation intent, wait for completion
* without polling or webhooks.
*
* Usage:
* export AXME_API_KEY="your-key"
* mvn compile exec:java -Dexec.mainClass="DurableApiOperations"
*/
import dev.axme.sdk.AxmeClient;
import dev.axme.sdk.AxmeClientConfig;
import dev.axme.sdk.RequestOptions;
import dev.axme.sdk.ObserveOptions;
import java.util.Map;
public class DurableApiOperations {
public static void main(String[] args) throws Exception {
var client = new AxmeClient(
AxmeClientConfig.forCloud(System.getenv("AXME_API_KEY"))
);
// Submit a durable operation — replaces POST /reports/generate → 202 + job_id
String intentId = client.sendIntent(Map.of(
"intent_type", "report.generate.v1",
"to_agent", "agent://myorg/production/report-service",
"payload", Map.of(
"report_type", "quarterly",
"format", "pdf",
"quarter", "Q1-2026"
)
), new RequestOptions());
System.out.println("Intent submitted: " + intentId);
// Wait for completion — no polling, no webhooks
var result = client.waitFor(intentId, new ObserveOptions());
System.out.println("Final status: " + result.get("status"));
}
}