public class RestClient extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
RestClient.HttpMethodCall
An interface used as base for anonymous classes wrapping Http Method
calls.
|
protected static interface |
RestClient.HttpRequestBuilder |
| Modifier and Type | Field and Description |
|---|---|
protected String |
agentId |
protected com.fasterxml.jackson.databind.ObjectMapper |
jsonMapper |
protected Logger |
logger |
protected HttpClient |
restClient |
protected URI |
serverUrl |
| Constructor and Description |
|---|
RestClient(Logger logger,
URI serverUrl,
int timeout) |
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
downloadFile(Response response) |
String |
getAgentId() |
Logger |
getLogger() |
AbstractProxySettings |
getProxy() |
protected String |
getReadResponseError(String errMsg,
int statusCode,
String statusPhrase,
String responseBody)
Builds an error message which includes the response model.
|
protected URI |
getServerUrlBase() |
int |
getTimeout() |
protected void |
initClient() |
protected AsyncRequest |
makeEyesRequest(RestClient.HttpRequestBuilder builder) |
protected <T> T |
parseResponseWithJsonData(Response response,
List<Integer> validHttpStatusCodes,
com.fasterxml.jackson.core.type.TypeReference<T> resultType)
Generic handling of response with model.
|
void |
sendAsyncRequest(AsyncRequestCallback callback,
String url,
String method,
Map<String,String> queryParams,
String... accept) |
void |
sendAsyncRequest(AsyncRequestCallback callback,
String url,
String method,
String... accept) |
void |
sendAsyncRequest(AsyncRequest request,
String method,
AsyncRequestCallback callback) |
void |
sendAsyncRequest(AsyncRequest request,
String method,
AsyncRequestCallback callback,
Object data,
String contentType) |
Response |
sendHttpRequest(String url,
String method,
Map<String,String> queryParams,
String... accept) |
Response |
sendHttpRequest(String url,
String method,
Object data,
String contentType,
String... accept) |
Response |
sendHttpRequest(String url,
String method,
String... accept)
Send a synchronous request to the server
|
protected void |
sendLongRequest(AsyncRequest request,
String method,
AsyncRequestCallback callback,
String data,
String mediaType) |
void |
setAgentId(String agentId) |
void |
setLogger(Logger logger) |
void |
setProxy(AbstractProxySettings proxySettings) |
protected void |
setServerUrlBase(URI serverUrl) |
void |
setTimeout(int timeout) |
protected Logger logger
protected HttpClient restClient
protected URI serverUrl
protected String agentId
protected com.fasterxml.jackson.databind.ObjectMapper jsonMapper
public void setLogger(Logger logger)
public Logger getLogger()
public void setProxy(AbstractProxySettings proxySettings)
public AbstractProxySettings getProxy()
public void setTimeout(int timeout)
public int getTimeout()
protected void setServerUrlBase(URI serverUrl)
protected URI getServerUrlBase()
public void setAgentId(String agentId)
public String getAgentId()
protected void initClient()
public void sendAsyncRequest(AsyncRequestCallback callback, String url, String method, String... accept)
public void sendAsyncRequest(AsyncRequestCallback callback, String url, String method, Map<String,String> queryParams, String... accept)
public void sendAsyncRequest(AsyncRequest request, String method, AsyncRequestCallback callback)
public void sendAsyncRequest(AsyncRequest request, String method, AsyncRequestCallback callback, Object data, String contentType)
protected AsyncRequest makeEyesRequest(RestClient.HttpRequestBuilder builder)
public Response sendHttpRequest(String url, String method, String... accept)
public Response sendHttpRequest(String url, String method, Map<String,String> queryParams, String... accept)
public Response sendHttpRequest(String url, String method, Object data, String contentType, String... accept)
protected void sendLongRequest(AsyncRequest request, String method, AsyncRequestCallback callback, String data, String mediaType) throws EyesException
EyesExceptionprotected String getReadResponseError(String errMsg, int statusCode, String statusPhrase, String responseBody)
errMsg - The error message.statusCode - The response status code.statusPhrase - The response status phrase.responseBody - The response body.protected <T> T parseResponseWithJsonData(Response response, List<Integer> validHttpStatusCodes, com.fasterxml.jackson.core.type.TypeReference<T> resultType) throws EyesException
T - The return value type.response - The response to parse.validHttpStatusCodes - The list of acceptable status codes.resultType - The class object of the type of result this response
should be parsed to.resultType.EyesException - For invalid status codes or if the response
parsing failed.protected byte[] downloadFile(Response response)
Copyright © 2021. All rights reserved.