Package com.algolia.search
Class InsightsClient
- java.lang.Object
-
- com.algolia.search.InsightsClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class InsightsClient extends Object implements Closeable
Algolia's REST insights client that wraps an instance of the transporterHttpTransportwhich wraps the HTTP Client This client allows to build typed requests and read typed responses. Requests are made under the Algolia's retry-strategy. This client is intended to be reused and it's thread-safe.- See Also:
- Algolia.com
-
-
Constructor Summary
Constructors Constructor Description InsightsClient(InsightsConfig config, HttpRequester httpRequester)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the underlying Http ClientConfigBasegetConfig()Get Client's configurationHttpTransportgetTransport()Transport object responsible for the serialization/deserialization and the retry strategy.InsightsResultsendEvent(InsightsEvent event)This command pushes an event to the Insights API.InsightsResultsendEvent(InsightsEvent event, RequestOptions requestOptions)This command pushes an event to the Insights API.CompletableFuture<InsightsResult>sendEventAsync(InsightsEvent event)This command pushes an event to the Insights API.CompletableFuture<InsightsResult>sendEventAsync(InsightsEvent event, RequestOptions requestOptions)This command pushes an event to the Insights API.InsightsResultsendEvents(List<InsightsEvent> events)This command pushes an array of events to the Insights API.InsightsResultsendEvents(List<InsightsEvent> events, RequestOptions requestOptions)This command pushes an array of events to the Insights API.CompletableFuture<InsightsResult>sendEventsAsync(List<InsightsEvent> events)This command pushes an array of events to the Insights API.CompletableFuture<InsightsResult>sendEventsAsync(List<InsightsEvent> events, RequestOptions requestOptions)This command pushes an array of events to the Insights API.UserInsightsClientuser(String userToken)
-
-
-
Constructor Detail
-
InsightsClient
public InsightsClient(@Nonnull InsightsConfig config, @Nonnull HttpRequester httpRequester)
- Parameters:
config- The configuration allows you to advanced configuration of the clients such as batch size or custom hosts and timeout.httpRequester- Another HTTP Client than the default one. Must be an implementation ofHttpRequester.- Throws:
NullPointerException- If one of the following ApplicationID/ApiKey/Configuration/Requester is nullIllegalArgumentException- If the ApplicationID or the APIKey are empty
-
-
Method Detail
-
close
public void close() throws IOExceptionClose the underlying Http Client- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
getConfig
public ConfigBase getConfig()
Get Client's configuration
-
getTransport
public HttpTransport getTransport()
Transport object responsible for the serialization/deserialization and the retry strategy.
-
user
public UserInsightsClient user(@Nonnull String userToken)
- Parameters:
userToken- the user config
-
sendEvent
public InsightsResult sendEvent(@Nonnull InsightsEvent event)
This command pushes an event to the Insights API.- Parameters:
event- An event- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
sendEvent
public InsightsResult sendEvent(@Nonnull InsightsEvent event, RequestOptions requestOptions)
This command pushes an event to the Insights API.- Parameters:
event- An eventrequestOptions- RequestOptions- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
sendEventAsync
public CompletableFuture<InsightsResult> sendEventAsync(@Nonnull InsightsEvent event)
This command pushes an event to the Insights API.- Parameters:
event- An event- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
sendEventAsync
public CompletableFuture<InsightsResult> sendEventAsync(@Nonnull InsightsEvent event, RequestOptions requestOptions)
This command pushes an event to the Insights API.- Parameters:
event- An eventrequestOptions- RequestOptions- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
sendEvents
public InsightsResult sendEvents(@Nonnull List<InsightsEvent> events)
This command pushes an array of events to the Insights API.- Parameters:
events- List of events- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
sendEvents
public InsightsResult sendEvents(@Nonnull List<InsightsEvent> events, RequestOptions requestOptions)
This command pushes an array of events to the Insights API.- Parameters:
events- List of eventsrequestOptions- RequestOptions- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
sendEventsAsync
public CompletableFuture<InsightsResult> sendEventsAsync(@Nonnull List<InsightsEvent> events)
This command pushes an array of events to the Insights API.- Parameters:
events- List of events- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
sendEventsAsync
public CompletableFuture<InsightsResult> sendEventsAsync(@Nonnull List<InsightsEvent> events, RequestOptions requestOptions)
This command pushes an array of events to the Insights API.- Parameters:
events- List of eventsrequestOptions- RequestOptions- Throws:
AlgoliaRetryException- When the retry has failed on all hostsAlgoliaApiException- When the API sends an http error codeAlgoliaRuntimeException- When an error occurred during the serialization
-
-