Package org.a2aproject.sdk.client.http
Interface A2AHttpClient.PostBuilder
- All Superinterfaces:
A2AHttpClient.Builder<A2AHttpClient.PostBuilder>
- Enclosing interface:
- A2AHttpClient
public static interface A2AHttpClient.PostBuilder
extends A2AHttpClient.Builder<A2AHttpClient.PostBuilder>
Builder for HTTP POST requests.
Supports both synchronous requests and asynchronous Server-Sent Events (SSE) streaming.
-
Method Summary
Modifier and TypeMethodDescriptionSets the request body content.post()Executes a synchronous POST request.postAsyncSSE(Consumer<ServerSentEvent> messageConsumer, Consumer<Throwable> errorConsumer, Runnable completeRunnable) Executes an asynchronous POST request expecting Server-Sent Events (SSE).Methods inherited from interface org.a2aproject.sdk.client.http.A2AHttpClient.Builder
addHeader, addHeaders, url
-
Method Details
-
body
Sets the request body content.- Parameters:
body- the request body string (typically JSON)- Returns:
- this builder for chaining
-
post
Executes a synchronous POST request.- Returns:
- the HTTP response
- Throws:
IOException- if an I/O error occursInterruptedException- if the operation is interrupted
-
postAsyncSSE
CompletableFuture<Void> postAsyncSSE(Consumer<ServerSentEvent> messageConsumer, Consumer<Throwable> errorConsumer, Runnable completeRunnable) throws IOException, InterruptedException Executes an asynchronous POST request expecting Server-Sent Events (SSE).The request will stream SSE messages asynchronously, invoking the provided consumers for each event, error, or completion.
- Parameters:
messageConsumer- callback for each SSE message receivederrorConsumer- callback for errors during streamingcompleteRunnable- callback when the stream completes normally- Returns:
- a CompletableFuture that completes when streaming ends
- Throws:
IOException- if an I/O error occursInterruptedException- if the operation is interrupted
-