public class RestClient
extends java.lang.Object
implements java.io.Closeable
RestSpec
used to translate api calls into REST callsModifier and Type | Field and Description |
---|---|
static java.lang.String |
PROTOCOL |
static java.lang.String |
TRUSTSTORE_PASSWORD |
static java.lang.String |
TRUSTSTORE_PATH |
Constructor and Description |
---|
RestClient(RestSpec restSpec,
org.elasticsearch.common.settings.Settings settings,
java.net.URL[] urls) |
Modifier and Type | Method and Description |
---|---|
RestResponse |
callApi(java.lang.String apiName,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.String body,
java.util.Map<java.lang.String,java.lang.String> headers)
Calls an api with the provided parameters and body
|
void |
close()
Closes the REST client and the underlying http client
|
protected org.apache.http.impl.client.CloseableHttpClient |
createHttpClient(org.elasticsearch.common.settings.Settings settings) |
org.elasticsearch.Version |
getEsVersion() |
protected HttpRequestBuilder |
httpRequestBuilder() |
protected HttpRequestBuilder |
httpRequestBuilder(java.net.URL url) |
public static final java.lang.String PROTOCOL
public static final java.lang.String TRUSTSTORE_PATH
public static final java.lang.String TRUSTSTORE_PASSWORD
public RestClient(RestSpec restSpec, org.elasticsearch.common.settings.Settings settings, java.net.URL[] urls) throws java.io.IOException, RestException
java.io.IOException
RestException
public org.elasticsearch.Version getEsVersion()
public RestResponse callApi(java.lang.String apiName, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String body, java.util.Map<java.lang.String,java.lang.String> headers) throws java.io.IOException, RestException
RestException
- if the obtained status code is non ok, unless the specific error code needs to be ignored
according to the ignore parameter received as input (which won't get sent to elasticsearch)java.io.IOException
protected HttpRequestBuilder httpRequestBuilder(java.net.URL url)
protected HttpRequestBuilder httpRequestBuilder()
protected org.apache.http.impl.client.CloseableHttpClient createHttpClient(org.elasticsearch.common.settings.Settings settings) throws java.io.IOException
java.io.IOException
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable