Package com.algolia.search
Class AnalyticsClient
- java.lang.Object
-
- com.algolia.search.AnalyticsClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class AnalyticsClient extends Object implements Closeable
Algolia's REST analytics 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 AnalyticsClient(AnalyticsConfig config, HttpRequester httpRequester)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AddABTestResponseaddABTest(ABTest abTest)Creates a new AB Test with provided configurationAddABTestResponseaddABTest(ABTest abTest, RequestOptions requestOptions)Creates a new AB Test with provided configurationCompletableFuture<AddABTestResponse>addABTestAsync(ABTest abTest)Creates a new AB Test with provided configurationCompletableFuture<AddABTestResponse>addABTestAsync(ABTest abTest, RequestOptions requestOptions)Creates a new AB Test with provided configurationvoidclose()Close the underlying Http ClientDeleteAbTestResponsedeleteABTest(long id)Deletes the A/B Test and removes all associated metadata and metrics.DeleteAbTestResponsedeleteABTest(long id, RequestOptions requestOptions)Deletes the A/B Test and removes all associated metadata and metrics.CompletableFuture<DeleteAbTestResponse>deleteABTestAsync(long id)Deletes the A/B Test and removes all associated metadata and metrics.CompletableFuture<DeleteAbTestResponse>deleteABTestAsync(long id, RequestOptions requestOptions)Deletes the A/B Test and removes all associated metadata and metrics.ABTestResponsegetABTest(long id)Get an A/B test information and results.ABTestResponsegetABTest(long id, RequestOptions requestOptions)Get an A/B test information and results.CompletableFuture<ABTestResponse>getABTestAsync(long id)Get an A/B test information and results.CompletableFuture<ABTestResponse>getABTestAsync(long id, RequestOptions requestOptions)Get an A/B test information and results.ABTestsgetABTests()Get an A/B test information and results.ABTestsgetABTests(int offset, int limit)Get an A/B test information and results.ABTestsgetABTests(int offset, int limit, RequestOptions requestOptions)Get an A/B test information and results.ABTestsgetABTests(RequestOptions requestOptions)Get an A/B test information and results.CompletableFuture<ABTests>getABTestsAsync()Get an A/B test information and results.CompletableFuture<ABTests>getABTestsAsync(int offset, int limit)Get an A/B test information and results.CompletableFuture<ABTests>getABTestsAsync(int offset, int limit, RequestOptions requestOptions)Get an A/B test information and results.CompletableFuture<ABTests>getABTestsAsync(RequestOptions requestOptions)Get an A/B test information and results.ConfigBasegetConfig()Get Client's configurationHttpTransportgetTransport()Transport object responsible for the serialization/deserialization and the retry strategy.StopAbTestResponsestopABTest(long id)Marks the A/B Test as stopped.StopAbTestResponsestopABTest(long id, RequestOptions requestOptions)Marks the A/B Test as stopped.CompletableFuture<StopAbTestResponse>stopABTestAsync(long id)Marks the A/B Test as stopped.CompletableFuture<StopAbTestResponse>stopABTestAsync(long id, RequestOptions requestOptions)Marks the A/B Test as stopped.
-
-
-
Constructor Detail
-
AnalyticsClient
public AnalyticsClient(@Nonnull AnalyticsConfig 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.
-
getABTests
public ABTests getABTests()
Get an A/B test information and results.
-
getABTests
public ABTests getABTests(RequestOptions requestOptions)
Get an A/B test information and results.- Parameters:
requestOptions- Options to pass to this request- 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
-
getABTests
public ABTests getABTests(int offset, int limit)
Get an A/B test information and results.- Parameters:
offset- Position of the starting record. Used for paging. 0 is the first record.limit- Number of records to return. +used for paging. Limit is the size of the page.- 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
-
getABTests
public ABTests getABTests(int offset, int limit, RequestOptions requestOptions)
Get an A/B test information and results.- Parameters:
offset- Position of the starting record. Used for paging. 0 is the first record.limit- Number of records to return. +used for paging. Limit is the size of the page.requestOptions- Options to pass to this request- 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
-
getABTestsAsync
public CompletableFuture<ABTests> getABTestsAsync()
Get an A/B test information and results.- 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
-
getABTestsAsync
public CompletableFuture<ABTests> getABTestsAsync(RequestOptions requestOptions)
Get an A/B test information and results.- Parameters:
requestOptions- Options to pass to this request- 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
-
getABTestsAsync
public CompletableFuture<ABTests> getABTestsAsync(int offset, int limit)
Get an A/B test information and results.- Parameters:
offset- Position of the starting record. Used for paging. 0 is the first record.limit- Number of records to return. +used for paging. Limit is the size of the page.- 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
-
getABTestsAsync
public CompletableFuture<ABTests> getABTestsAsync(int offset, int limit, RequestOptions requestOptions)
Get an A/B test information and results.- Parameters:
offset- Position of the starting record. Used for paging. 0 is the first record.limit- Number of records to return. +used for paging. Limit is the size of the page.requestOptions- Options to pass to this request- 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
-
getABTest
public ABTestResponse getABTest(long id)
Get an A/B test information and results.- Parameters:
id- The ABTest ID- 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
-
getABTest
public ABTestResponse getABTest(long id, RequestOptions requestOptions)
Get an A/B test information and results.- Parameters:
id- The ABTest IDrequestOptions- Options to pass to this request- 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
-
getABTestAsync
public CompletableFuture<ABTestResponse> getABTestAsync(long id)
Get an A/B test information and results.- Parameters:
id- The ABTest ID- 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
-
getABTestAsync
public CompletableFuture<ABTestResponse> getABTestAsync(long id, RequestOptions requestOptions)
Get an A/B test information and results.- Parameters:
id- The ABTest IDrequestOptions- Options to pass to this request- 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
-
stopABTest
public StopAbTestResponse stopABTest(long id)
Marks the A/B Test as stopped. At this point, the test is over and cannot be restarted. As a result, your application is back to normal: index A will perform as usual, receiving 100% of all search requests. Associated metadata and metrics are still stored- Parameters:
id- The ABTest ID- 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
-
stopABTest
public StopAbTestResponse stopABTest(long id, RequestOptions requestOptions)
Marks the A/B Test as stopped. At this point, the test is over and cannot be restarted. As a result, your application is back to normal: index A will perform as usual, receiving 100% of all search requests. Associated metadata and metrics are still stored- Parameters:
id- The ABTest IDrequestOptions- Options to pass to this request- 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
-
stopABTestAsync
public CompletableFuture<StopAbTestResponse> stopABTestAsync(long id)
Marks the A/B Test as stopped. At this point, the test is over and cannot be restarted. As a result, your application is back to normal: index A will perform as usual, receiving 100% of all search requests. Associated metadata and metrics are still stored- Parameters:
id- The ABTest ID- 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
-
stopABTestAsync
public CompletableFuture<StopAbTestResponse> stopABTestAsync(long id, RequestOptions requestOptions)
Marks the A/B Test as stopped. At this point, the test is over and cannot be restarted. As a result, your application is back to normal: index A will perform as usual, receiving 100% of all search requests. Associated metadata and metrics are still stored- Parameters:
id- The ABTest IDrequestOptions- Options to pass to this request- 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
-
deleteABTest
public DeleteAbTestResponse deleteABTest(long id)
Deletes the A/B Test and removes all associated metadata and metrics.- Parameters:
id- The ABTest ID- 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
-
deleteABTest
public DeleteAbTestResponse deleteABTest(long id, RequestOptions requestOptions)
Deletes the A/B Test and removes all associated metadata and metrics.- Parameters:
id- The ABTest IDrequestOptions- Options to pass to this request- 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
-
deleteABTestAsync
public CompletableFuture<DeleteAbTestResponse> deleteABTestAsync(long id)
Deletes the A/B Test and removes all associated metadata and metrics.- Parameters:
id- The ABTest ID- 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
-
deleteABTestAsync
public CompletableFuture<DeleteAbTestResponse> deleteABTestAsync(long id, RequestOptions requestOptions)
Deletes the A/B Test and removes all associated metadata and metrics.- Parameters:
id- The ABTest IDrequestOptions- Options to pass to this request- 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
-
addABTest
public AddABTestResponse addABTest(@Nonnull ABTest abTest)
Creates a new AB Test with provided configuration- Parameters:
abTest- The definition of the A/B test- 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
-
addABTest
public AddABTestResponse addABTest(@Nonnull ABTest abTest, RequestOptions requestOptions)
Creates a new AB Test with provided configuration- Parameters:
abTest- The definition of the A/B testrequestOptions- Options to pass to this request- 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
-
addABTestAsync
public CompletableFuture<AddABTestResponse> addABTestAsync(@Nonnull ABTest abTest)
Creates a new AB Test with provided configuration- Parameters:
abTest- The definition of the A/B test- 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
-
addABTestAsync
public CompletableFuture<AddABTestResponse> addABTestAsync(@Nonnull ABTest abTest, RequestOptions requestOptions)
Creates a new AB Test with provided configuration- Parameters:
abTest- The definition of the A/B testrequestOptions- Options to pass to this request- 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
-
-