public abstract class GenericAPIClientBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
analyticsHost |
protected String |
apiKey |
protected String |
applicationId |
protected List<String> |
buildHosts |
protected int |
connectTimeout |
protected String |
customAgent |
protected String |
customAgentVersion |
protected Map<String,String> |
customHeaders |
protected int |
hostDownTimeout |
protected int |
maxConnPerRoute |
protected int |
maxConnTotal |
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
protected List<String> |
queryHosts |
protected Random |
random |
protected int |
readTimeout |
| Constructor and Description |
|---|
GenericAPIClientBuilder(String applicationId,
String apiKey)
Initialize this builder with the applicationId and apiKey
|
| Modifier and Type | Method and Description |
|---|---|
GenericAPIClientBuilder |
addExtraHeader(String key,
String value)
Add extra headers to the requests
|
protected List<String> |
generateBuildHosts() |
protected Map<String,String> |
generateHeaders() |
protected List<String> |
generateQueryHosts() |
GenericAPIClientBuilder |
setAnalyticsHost(String analyticsHost)
Set the analytics host
|
GenericAPIClientBuilder |
setBuildHosts(List<String> buildHosts)
Set the hosts for indexing & building
|
GenericAPIClientBuilder |
setConnectTimeout(int connectTimeout)
Set the connect timeout of the HTTP client
|
GenericAPIClientBuilder |
setExtraHeader(String key,
String value)
Deprecated.
|
GenericAPIClientBuilder |
setHostDownTimeout(int hostDownTimeout)
Set the retry timeout to detect if a host is down
|
GenericAPIClientBuilder |
setMaxConnPerRoute(int maxConnPerRoute)
Set the maximum of connection per route, only available for
ApacheAPIClientBuilder and
AsyncAPIClientBuilder |
GenericAPIClientBuilder |
setMaxConnTotal(int maxConnTotal)
Set the maximum of connection, only available for
ApacheAPIClientBuilder and AsyncAPIClientBuilder |
GenericAPIClientBuilder |
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Set the Jackson ObjectMapper, it overrides the default one and add 2 features: * Enables:
AUTO_CLOSE_JSON_CONTENT * Disables: FAIL_ON_UNKNOWN_PROPERTIES
|
GenericAPIClientBuilder |
setQueryHosts(List<String> queryHosts)
Set the hosts for search & queries
|
GenericAPIClientBuilder |
setReadTimeout(int readTimeout)
Set the read timeout of the HTTP client
|
GenericAPIClientBuilder |
setUserAgent(String customAgent,
String customAgentVersion)
Customize the user agent
|
protected final Random random
protected final String applicationId
protected final String apiKey
protected String customAgent
protected String customAgentVersion
protected String analyticsHost
protected int connectTimeout
protected int readTimeout
protected int hostDownTimeout
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected int maxConnTotal
protected int maxConnPerRoute
public GenericAPIClientBuilder(@Nonnull String applicationId, @Nonnull String apiKey)
applicationId - APP_ID can be found on https://www.algolia.com/api-keysapiKey - Algolia API_KEY can also be found on https://www.algolia.com/api-keyspublic GenericAPIClientBuilder setUserAgent(@Nonnull String customAgent, @Nonnull String customAgentVersion)
customAgent - key to add to the user agentcustomAgentVersion - value of this key to add to the user agent@Deprecated public GenericAPIClientBuilder setExtraHeader(@Nonnull String key, String value)
addExtraHeader(String, String)public GenericAPIClientBuilder addExtraHeader(@Nonnull String key, String value)
key - name of the headervalue - value of the headerpublic GenericAPIClientBuilder setConnectTimeout(int connectTimeout)
connectTimeout - the value in mspublic GenericAPIClientBuilder setReadTimeout(int readTimeout)
readTimeout - the value in mspublic GenericAPIClientBuilder setHostDownTimeout(int hostDownTimeout)
hostDownTimeout - the value in mspublic GenericAPIClientBuilder setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper - the mapperpublic GenericAPIClientBuilder setAnalyticsHost(@Nonnull String analyticsHost)
analyticsHost - the analytics host to usepublic GenericAPIClientBuilder setQueryHosts(List<String> queryHosts)
queryHosts - the list of hosts for searchpublic GenericAPIClientBuilder setBuildHosts(List<String> buildHosts)
buildHosts - the list of hosts for indexing/buildingpublic GenericAPIClientBuilder setMaxConnTotal(int maxConnTotal)
ApacheAPIClientBuilder and AsyncAPIClientBuildermaxConnTotal - the max number of connectionspublic GenericAPIClientBuilder setMaxConnPerRoute(int maxConnPerRoute)
ApacheAPIClientBuilder and
AsyncAPIClientBuildermaxConnPerRoute - the max number of connections per routeCopyright © 2018. All rights reserved.