Interface ApiClient
- All Known Implementing Classes:
DefaultApiClient
@Generated("de.xima.openapi.codegen.java_jaxrs.XimaJavaJaxrsGenerator")
public interface ApiClient
Defines the interface for the API client. Can be used e.g. for mocking or abstraction.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ApiClientBuilderbuilder(JaxRsAdapter jaxRsAdapter) config()Accesses the configuration that was used to create this client.javax.ws.rs.client.ClientAccesses the HTTP client that is used for sending HTTP requests.<T> Future<ApiResponse<T>> invokeApiAsync(ApiCall<?> call) Invoke an API endpoint by sending an HTTP request with the given options.<T> Future<ApiResponse<T>> invokeApiAsync(ApiCall<?> call, javax.ws.rs.client.InvocationCallback<ApiResponse<T>> invocationCallback) Invoke an API endpoint by sending an HTTP request with the given options.<T> CompletionStage<ApiResponse<T>> invokeApiRx(ApiCall<?> call) Invoke an API endpoint by sending an HTTP request with the given options.<T> ApiResponse<T> invokeApiSync(ApiCall<?> call) Invoke an API endpoint by sending an HTTP request with the given options.
-
Method Details
-
createBundle
ApiBundle createBundle()- Returns:
- A bundle with convenience methods to access the individual APIs.
-
httpClient
javax.ws.rs.client.Client httpClient()Accesses the HTTP client that is used for sending HTTP requests. You can use this if you ever need to send requests manually.- Returns:
- The HTTP client used by this client.
-
config
ApiClientConfig config()Accesses the configuration that was used to create this client.- Returns:
- The configuration used by this client.
-
formatter
Formatter formatter()- Returns:
- The formatter instance used by this client.
-
invokeApiAsync
Invoke an API endpoint by sending an HTTP request with the given options. This method always returns an asynchronousFuture. That future may throw an execution exception, but this method never throws an exception directly.- Type Parameters:
T- The expected return type of the request.- Parameters:
call- API call to send with the data of the requests.- Returns:
- A future encapsulating the eventual response with the meta data and the body of the response.
-
invokeApiAsync
<T> Future<ApiResponse<T>> invokeApiAsync(ApiCall<?> call, javax.ws.rs.client.InvocationCallback<ApiResponse<T>> invocationCallback) Invoke an API endpoint by sending an HTTP request with the given options. This method always returns an asynchronousFuture. That future may throw an execution exception, but this method never throws an exception directly. You should not read the result of the future, use the callback instead.- Type Parameters:
T- The expected return type of the request.- Parameters:
call- API call to send with the data of the requests.invocationCallback- Callback which is invoked when the request finishes.- Returns:
- A future encapsulating the eventual response with the meta data and the body of the response.
-
invokeApiRx
Invoke an API endpoint by sending an HTTP request with the given options. This method always returns an asynchronousCompletionStage. That stage may be completed exceptionally, but this method never throws an exception directly.- Type Parameters:
T- The expected return type of the request.- Parameters:
call- API call to send with the data of the requests.- Returns:
- A completion stage that resolves with the meta data and the body of the response.
-
invokeApiSync
Invoke an API endpoint by sending an HTTP request with the given options. This method always returns the result synchronously.- Type Parameters:
T- The expected return type of the request.- Parameters:
call- API call to send with the data of the requests.- Returns:
- The response with the meta data and the body of the response.
- Throws:
ApiException- When the request could not be executed. No exception is thrown if the server simply sends a 4xx or 5xx status code and that status code was defined in the API specification.
-
builder
- Parameters:
jaxRsAdapter- The adapter to use for integrating Jax RS.- Returns:
- A new builder for configuring an API client.
-