Repository navigation
Expand file tree
/
Copy pathA2AHttpClient.java
More file actions
45 lines (35 loc) · 1.44 KB
/
Copy pathA2AHttpClient.java
File metadata and controls
45 lines (35 loc) · 1.44 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
41
42
43
44
45
package io.a2a.client.http;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
public interface A2AHttpClient {
String CONTENT_TYPE= "Content-Type";
String APPLICATION_JSON= "application/json";
GetBuilder createGet();
PostBuilder createPost();
DeleteBuilder createDelete();
interface Builder<T extends Builder<T>> {
T url(String s);
T addHeaders(Map<String, String> headers);
T addHeader(String name, String value);
}
interface GetBuilder extends Builder<GetBuilder> {
A2AHttpResponse get() throws IOException, InterruptedException;
CompletableFuture<Void> getAsyncSSE(
Consumer<String> messageConsumer,
Consumer<Throwable> errorConsumer,
Runnable completeRunnable) throws IOException, InterruptedException;
}
interface PostBuilder extends Builder<PostBuilder> {
PostBuilder body(String body);
A2AHttpResponse post() throws IOException, InterruptedException;
CompletableFuture<Void> postAsyncSSE(
Consumer<String> messageConsumer,
Consumer<Throwable> errorConsumer,
Runnable completeRunnable) throws IOException, InterruptedException;
}
interface DeleteBuilder extends Builder<DeleteBuilder> {
A2AHttpResponse delete() throws IOException, InterruptedException;
}
}