public class RestClient extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CONNECT_TIMEOUT |
static int |
DEFAULT_READ_TIMEOUT |
| Constructor and Description |
|---|
RestClient(String server_url,
Optional<String> api_key)
Instantiate a new REST Client with DEFAULT_CONNECT_TIMEOUT and DEFAULT_READ_TIMEOUT
|
RestClient(String server_url,
Optional<String> api_key,
int connection_timeout,
int read_timeout)
Instantiate a new REST Client
|
| Modifier and Type | Method and Description |
|---|---|
String |
json_get(String path)
Perform a GET request returning JSON
|
String |
json_post(String path,
String payload)
Perform a JSON POST request returning JSON
|
public static final int DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_READ_TIMEOUT
public RestClient(String server_url, Optional<String> api_key, int connection_timeout, int read_timeout)
server_url - the REST Server URL e.g. http://localhost:9000connection_timeout - Sets a specified timeout value, in milliseconds, to be used when opening a
communications link to the resource referenced by this URLConnection.read_timeout - Sets the read timeout to a specified timeout, in milliseconds.api_key - The API Key to use to authenticatepublic String json_get(String path) throws RestException
path - the REST service path and query parameters answering the GET requestRestException - on any REST errorpublic String json_post(String path, String payload) throws RestException
path - the REST service path and query parameters answering the POST requestpayload - the JSON payload passed as the body of the POST requestRestException - on any REST errorCopyright © 2023. All rights reserved.