Package com.algolia

Class ApiClient

java.lang.Object
com.algolia.ApiClient
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
AbtestingClient, AnalyticsClient, IngestionClient, InsightsClient, MonitoringClient, PersonalizationClient, QuerySuggestionsClient, RecommendClient, SearchClient

public abstract class ApiClient extends Object implements Closeable
Represents a base client for making API requests. The client uses a Requester for executing requests and an ExecutorService for asynchronous operations. It is designed to be extended by concrete API client implementations.
  • Constructor Details

  • Method Details

    • setClientApiKey

      public void setClientApiKey(@Nonnull String apiKey)
      Helper method to switch the API key used to authenticate the requests.
      Parameters:
      apiKey - The new API key to be used from now on.
    • executeAsync

      protected <T> CompletableFuture<T> executeAsync(HttpRequest httpRequest, RequestOptions requestOptions, com.fasterxml.jackson.core.type.TypeReference<T> returnType)
      Executes an HTTP request asynchronously and returns a CompletableFuture of the response deserialized into a specified type.
    • executeAsync

      protected <T> CompletableFuture<T> executeAsync(HttpRequest httpRequest, RequestOptions requestOptions, Class<?> returnType, Class<?> innerType)
      Executes an HTTP request asynchronously and returns a CompletableFuture of the response deserialized into a specified type.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException