public class ApiClient extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_API_BASE_URL
The default API base URL.
|
static String |
DEFAULT_USER_AGENT
The default user agent.
|
| Constructor and Description |
|---|
ApiClient(String appId,
Credentials credentials)
ApiClient constructor.
|
ApiClient(String appId,
Credentials credentials,
String agentString)
ApiClient Constructor.
|
ApiClient(String appId,
Credentials credentials,
String agentString,
String apiBaseURL)
ApiClient constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
call(String method,
String url,
Object obj,
com.fasterxml.jackson.core.type.TypeReference<T> valueType,
boolean auth,
boolean binary)
call is used to make a API call.
|
<T> T |
callWithAuth(String method,
String endpoint,
Object obj,
com.fasterxml.jackson.core.type.TypeReference<T> valueType)
callWithAuth is used to make requests that require Authentication on
CoScale API.
|
<T> T |
callWithAuthBinary(String method,
String endpoint,
BinaryData data,
com.fasterxml.jackson.core.type.TypeReference<T> valueType,
boolean binary)
callWithAuthBinary is used to make requests that require Authentication on
CoScale API.
|
String |
doHttpRequestBinary(String method,
String uri,
BinaryData payload,
boolean authenticate)
Do an HTTP request with a binary upload in it.
|
String |
getApiPath()
getApiPath is used to get the API path.
|
String |
getApiVersion()
getApiVersion is used to get the API version which will be used to build
the request URL.
|
String |
getAppRequestURL(String endpoint)
getAppRequestURL will construct the URL for a request using the end point
provided.
|
String |
getBaseURL()
getBaseURL is used to get the CoScale API domain.
|
int |
getConnectionTimeout()
return the default connection timeout in ms.
|
int |
getDeserializationExceptions()
getDeserializationExceptions is used to get the number of JSON
deserialization errors.
|
String |
getGlobalRequestURL(String endpoint)
getGlobalRequestURL will construct the URL for a request using the end
point provided.
|
int |
getReadTimeout()
return the default read timeout in ms.
|
String |
getRequesUrl(String endpoint,
Options options,
boolean globalApi)
getRequesUrl will build the URL for a request using the end point
provided.
|
static String |
getSource()
Get the SOURCE String which mark the created resources.
|
void |
setBaseURL(String url)
setBaseURL is used to set a new API base URL.
|
void |
setConnectionTimeout(int timeout)
Change the default connection timeout.
|
void |
setReadTimeout(int timeout)
Change the default read timeout.
|
static void |
setSource(String source)
Set the Source String which mark the created resources.
|
public static final String DEFAULT_API_BASE_URL
public static final String DEFAULT_USER_AGENT
public ApiClient(String appId, Credentials credentials, String agentString, String apiBaseURL)
appId - The CoScale Application id.credentials - Api authentication information.agentString - HTTP "User-Agent" header.apiBaseURL - The API base url, eg. https://api.coscale.compublic ApiClient(String appId, Credentials credentials, String agentString)
appId - The CoScale Application id.credentials - API authentication informations.agentString - HTTP "User-Agent" headerpublic ApiClient(String appId, Credentials credentials)
appId - The CoScale Application id.credentials - Api authentication informations.public String getApiPath()
public String getApiVersion()
public String getBaseURL()
public void setBaseURL(String url)
url - public int getConnectionTimeout()
public void setConnectionTimeout(int timeout)
timeout - in ms.public int getReadTimeout()
public void setReadTimeout(int timeout)
timeout - in ms.public static String getSource()
public static void setSource(String source)
source - public int getDeserializationExceptions()
public <T> T callWithAuth(String method, String endpoint, Object obj, com.fasterxml.jackson.core.type.TypeReference<T> valueType) throws IOException
method - request HTTP method.endpoint - The url for the request.obj - object with data for the request. This parameter can be null.valueType - is the type expected.IOExceptionpublic <T> T callWithAuthBinary(String method, String endpoint, BinaryData data, com.fasterxml.jackson.core.type.TypeReference<T> valueType, boolean binary) throws IOException
method - request HTTP method.endpoint - The url for the request.data - object with data for the request. This parameter can be null.valueType - is the type expected.binary - is the action a binary upload.IOExceptionpublic <T> T call(String method, String url, Object obj, com.fasterxml.jackson.core.type.TypeReference<T> valueType, boolean auth, boolean binary) throws IOException
method - request HTTP method.url - for the request.obj - object with data for the request. This parameter can be null.valueType - is the type expected.IOExceptionpublic String doHttpRequestBinary(String method, String uri, BinaryData payload, boolean authenticate) throws IOException
method - The methoduri - The urlpayload - The object with the dataauthenticate - The authentication token.IOExceptionpublic String getAppRequestURL(String endpoint)
endpoint - String representing the API end point of the request.public String getGlobalRequestURL(String endpoint)
endpoint - String representing the API end point of the request.public String getRequesUrl(String endpoint, Options options, boolean globalApi)
endpoint - String representing the API end point of the request.options - Optional query parametersglobalApi - if is set true, application Id will not be include into URL.Copyright © 2016. All rights reserved.