Class ControlPlaneHttpClient
java.lang.Object
io.agentscope.extensions.aistio.transport.ControlPlaneHttpClient
Shared JDK
HttpClient wrapper for aistio control-plane REST calls.
Sends X-Builder-Internal-Token on every request and enforces a 10s timeout.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordHTTP response with a raw byte body (e.g. snapshot octet-streams).static final recordHTTP response with a decoded string body. -
Constructor Summary
ConstructorsConstructorDescriptionControlPlaneHttpClient(String baseUrl, String internalToken) Creates a client against the given control-plane base URL. -
Method Summary
Modifier and TypeMethodDescriptionbaseUrl()Returns the trimmed base URL.static com.fasterxml.jackson.databind.ObjectMappermapper()Returns the Jackson mapper shared by control-plane clients.Sends a JSON request and returns the string body.Sends a JSON request with extra headers.Sends a raw-bytes request (e.g. snapshot upload) and returns the string body.sendBytes(String method, String path, String contentType, byte[] body, Map<String, String> extraHeaders) Sends raw bytes with additional request headers.sendForBytes(String method, String path, String contentType, byte[] body) Sends a request and returns the raw response bytes (used for snapshot download).sendForBytes(String method, String path, String contentType, byte[] body, Map<String, String> extraHeaders) Receives raw bytes with additional request headers.
-
Constructor Details
-
ControlPlaneHttpClient
Creates a client against the given control-plane base URL.- Parameters:
baseUrl- control-plane HTTP base (trailing slash trimmed)internalToken- value forX-Builder-Internal-Token
-
-
Method Details
-
baseUrl
Returns the trimmed base URL. -
mapper
public static com.fasterxml.jackson.databind.ObjectMapper mapper()Returns the Jackson mapper shared by control-plane clients. -
send
public ControlPlaneHttpClient.Response send(String method, String path, Object jsonBody) throws IOException, InterruptedException Sends a JSON request and returns the string body.- Parameters:
method- HTTP methodpath- absolute path beginning with/, may include a query stringjsonBody- request body object (serialized with Jackson), ornullfor no body- Throws:
IOExceptionInterruptedException
-
send
public ControlPlaneHttpClient.Response send(String method, String path, Object jsonBody, Map<String, String> extraHeaders) throws IOException, InterruptedExceptionSends a JSON request with extra headers.- Parameters:
method- HTTP methodpath- absolute path beginning with/jsonBody- request body object, ornullextraHeaders- additional request headers- Throws:
IOExceptionInterruptedException
-
sendBytes
public ControlPlaneHttpClient.Response sendBytes(String method, String path, String contentType, byte[] body) throws IOException, InterruptedException Sends a raw-bytes request (e.g. snapshot upload) and returns the string body.- Parameters:
method- HTTP methodpath- absolute path beginning with/contentType-Content-Typeheader, ornullto omitbody- request body bytes, ornull/emptyfor no body- Throws:
IOExceptionInterruptedException
-
sendBytes
public ControlPlaneHttpClient.Response sendBytes(String method, String path, String contentType, byte[] body, Map<String, String> extraHeaders) throws IOException, InterruptedExceptionSends raw bytes with additional request headers.- Throws:
IOExceptionInterruptedException
-
sendForBytes
public ControlPlaneHttpClient.BytesResponse sendForBytes(String method, String path, String contentType, byte[] body) throws IOException, InterruptedException Sends a request and returns the raw response bytes (used for snapshot download).- Parameters:
method- HTTP methodpath- absolute path beginning with/contentType- optional content type for a request bodybody- optional request body- Throws:
IOExceptionInterruptedException
-
sendForBytes
public ControlPlaneHttpClient.BytesResponse sendForBytes(String method, String path, String contentType, byte[] body, Map<String, String> extraHeaders) throws IOException, InterruptedExceptionReceives raw bytes with additional request headers.- Throws:
IOExceptionInterruptedException
-