public class AbstractRESTClient extends Object implements ServiceStatus
| Modifier and Type | Field and Description |
|---|---|
protected static com.fasterxml.jackson.databind.ObjectMapper |
mapper |
| Constructor and Description |
|---|
AbstractRESTClient(String uriProperty)
By default rest client tries to find username and password in environmental variables.
|
AbstractRESTClient(String username,
String password,
String url) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addHeaders(HttpURLConnection connection,
String tenantId)
Add the header values to the supplied connection.
|
void |
clear(String tenantId,
String path) |
String |
encodedCriteria(Criteria criteria) |
HttpURLConnection |
getConnectionForGetRequest(String tenantId,
URL url) |
HttpURLConnection |
getConnectionForRequest(String tenantId,
URL url,
String method) |
String |
getResponse(HttpURLConnection connection) |
<T> T |
getResultsForUrl(String tenantId,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference,
String path,
Criteria criteria) |
<T> T |
getResultsForUrl(String tenantId,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference,
String path,
Criteria criteria,
Object arg) |
<T> T |
getResultsForUrl(String tenantId,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference,
String path,
Object... parameters) |
URL |
getUrl(String path) |
URL |
getUrl(String path,
Object... args) |
boolean |
isAvailable() |
<T> T |
parseResultsIntoJson(HttpURLConnection connection,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference) |
int |
postAsJsonTo(String tenantId,
String path,
Object toSerialize) |
void |
setAuthorization(String username,
String password) |
<T> T |
withContext(String tenantId,
URL url,
Function<HttpURLConnection,T> function) |
<T> T |
withJsonPayloadAndResults(String method,
String tenantId,
URL url,
Object toSerialize,
Function<HttpURLConnection,T> function) |
public AbstractRESTClient(String uriProperty)
uriProperty - public boolean isAvailable()
isAvailable in interface ServiceStatusprotected void addHeaders(HttpURLConnection connection, String tenantId)
connection - The connectiontenantId - The optional tenant idpublic <T> T withContext(String tenantId, URL url, Function<HttpURLConnection,T> function)
public <T> T getResultsForUrl(String tenantId, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, String path, Object... parameters)
public <T> T parseResultsIntoJson(HttpURLConnection connection, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
public <T> T getResultsForUrl(String tenantId, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, String path, Criteria criteria)
public <T> T getResultsForUrl(String tenantId, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, String path, Criteria criteria, Object arg)
public HttpURLConnection getConnectionForGetRequest(String tenantId, URL url) throws IOException
IOExceptionpublic HttpURLConnection getConnectionForRequest(String tenantId, URL url, String method) throws IOException
IOExceptionpublic String getResponse(HttpURLConnection connection) throws IOException
IOExceptionpublic <T> T withJsonPayloadAndResults(String method, String tenantId, URL url, Object toSerialize, Function<HttpURLConnection,T> function)
Copyright © 2015–2017 Red Hat, Inc.. All rights reserved.