java.lang.Object
ai.docling.serve.client.operations.HttpOperations
- Direct Known Subclasses:
DoclingServeClient
Abstract base class for HTTP operations. Provides methods for executing HTTP requests such as GET and POST
and deserializing responses into specified types. This class is intended to be extended by subclasses that
implement these operations for specific use cases.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract <I,O> O executeGet(RequestContext<I, O> requestContext) Executes an HTTP GET request using the details specified in the providedRequestContext.protected abstract <I> StreamResponseexecuteGetWithStreamResponse(RequestContext<I, StreamResponse> requestContext) Executes an HTTP GET request using the details specified in the providedRequestContext.protected abstract <I,O> O executePost(RequestContext<I, O> requestContext) Executes an HTTP POST request using the details provided in theRequestContext.protected abstract <I> StreamResponseexecutePostWithStreamResponse(RequestContext<I, StreamResponse> requestContext) Executes an HTTP POST request using the details provided in theRequestContext.protected abstract <T> TReads and deserializes the given JSON string into an instance of the specified type.
-
Field Details
-
CONTENT_TYPE_HEADER
Content-Type header key- See Also:
-
CONTENT_TYPE_JSON
Content-Type header value for JSON body- See Also:
-
CONTENT_TYPE_ZIP
Content-Type header value for ZIP binary body- See Also:
-
API_KEY_HEADER_NAME
The header name used to specify the API key in HTTP requests. This constant is commonly utilized in authentication mechanisms to include the API key in request headers.- See Also:
-
-
Constructor Details
-
HttpOperations
public HttpOperations()
-
-
Method Details
-
executeGet
Executes an HTTP GET request using the details specified in the providedRequestContext.- Type Parameters:
I- the type of the request payloadO- the type of the response object- Parameters:
requestContext- the context containing details such as the URI, request payload, and expected response type of the GET operation- Returns:
- an instance of the response type
O, which represents the deserialized response data
-
executeGetWithStreamResponse
protected abstract <I> StreamResponse executeGetWithStreamResponse(RequestContext<I, StreamResponse> requestContext) Executes an HTTP GET request using the details specified in the providedRequestContext.- Type Parameters:
I- the type of the request payload- Parameters:
requestContext- the context containing details such as the URI, request payload, and expected response type of the GET operation- Returns:
- an instance of the
StreamResponse, which represents the response.
-
executePost
Executes an HTTP POST request using the details provided in theRequestContext. This method is designed to be implemented by subclasses and facilitates sending POST requests with a specified request payload and receiving a deserialized response.- Type Parameters:
I- the type of the request payloadO- the type of the response object- Parameters:
requestContext- the context containing details such as the URI, request payload, and expected response type of the POST operation- Returns:
- an instance of the response type
O, which represents the deserialized response data
-
executePostWithStreamResponse
protected abstract <I> StreamResponse executePostWithStreamResponse(RequestContext<I, StreamResponse> requestContext) Executes an HTTP POST request using the details provided in theRequestContext. This method is designed to be implemented by subclasses and facilitates sending POST requests with a specified request payload and receiving a stream response.- Type Parameters:
I- the type of the request payload- Parameters:
requestContext- the context containing details such as the URI, request payload, and expected response type of the POST operation- Returns:
- an instance of the
StreamResponse, which represents the response.
-
readValue
Reads and deserializes the given JSON string into an instance of the specified type.- Type Parameters:
T- the type of the object to be deserialized- Parameters:
json- the JSON string to deserialize; must not benullvalueType- theClassof the target type; must not benull- Returns:
- an instance of
Tdeserialized from the provided JSON - Throws:
RuntimeException- if the JSON parsing fails
-