public class ApiClient extends Object
| Constructor and Description |
|---|
ApiClient() |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
AsyncInvokeAPI(String path,
String method,
List<QueryPair> queryParams,
Object body,
Map<String,String> headerParams,
Map<String,Object> formParams,
String accept,
String contentType,
String[] authNames,
javax.ws.rs.core.GenericType<T> returnType)
Asynchronous Invoke API by sending HTTP request with the given options.
|
<T> T |
deserialize(javax.ws.rs.core.Response response,
javax.ws.rs.core.GenericType<T> returnType)
Deserialize response body to Java object according to the Content-Type.
|
File |
downloadFileFromResponse(javax.ws.rs.core.Response response)
Download file from the given response.
|
String |
escapeString(String str)
Escape the given string to be used as URL query value.
|
String |
formatDate(Date date)
Format the given Date object into string.
|
Authentication |
getAuthentication(String authName)
Get authentication for the given name.
|
Map<String,Authentication> |
getAuthentications()
Get authentications (key: authentication name, value: authentication).
|
String |
getBasePath()
Gets the Redfish Service Root path.
|
int |
getConnectTimeout()
Connect timeout (in milliseconds).
|
DateFormat |
getDateFormat()
Get the date format used to parse/format date parameters.
|
Map<String,String> |
getDefaultHeader() |
javax.ws.rs.client.Client |
getHttpsClient()
Gets HTTPS Client.
|
JSONUtil |
getJSON()
Gets the JSON instance to do JSON serialization and deserialization.
|
Map<String,List<String>> |
getResponseHeaders()
Gets the response headers of the previous request
|
int |
getStatusCode()
Gets the status code of the previous request
|
String |
getTempFolderPath()
The path of temporary folder used to store downloaded files from endpoints
with file response.
|
<T> T |
invokeAPI(String path,
String method,
List<QueryPair> queryParams,
Object body,
Map<String,String> headerParams,
Map<String,Object> formParams,
String accept,
String contentType,
String[] authNames,
javax.ws.rs.core.GenericType<T> returnType)
Invoke API by sending HTTP request with the given options.
|
boolean |
isJsonMime(String mime)
Check if the given MIME is a JSON MIME.
|
ApiClient |
Login(String serverHost,
String username,
String password)
Set HTTPS server host as base path, username and password.
|
List<QueryPair> |
parameterToPairs(String collectionFormat,
String name,
Object value)
Format to
Pair objects. |
String |
parameterToString(Object param)
Format the given parameter object into string.
|
Date |
parseDate(String str)
Parse the given string into Date object.
|
File |
prepareDownloadFile(javax.ws.rs.core.Response response) |
String |
selectHeaderAccept(String[] accepts)
Select the Accept header's value from the given accepts array:
if JSON exists in the given array, use it;
otherwise use all of them (joining into a string)
|
String |
selectHeaderContentType(String[] contentTypes)
Select the Content-Type header's value from the given array:
if JSON exists in the given array, use it;
otherwise use the first one of the array.
|
javax.ws.rs.client.Entity<?> |
serialize(Object obj,
Map<String,Object> formParams,
String contentType)
Serialize the given Java object into string entity according the given
Content-Type (only JSON is supported for now).
|
void |
setAccessToken(String accessToken)
Helper method to set access token for the first OAuth2 authentication.
|
void |
setApiKey(String apiKey)
Helper method to set API key value for the first API key authentication.
|
void |
setApiKeyPrefix(String apiKeyPrefix)
Helper method to set API key prefix for the first API key authentication.
|
ApiClient |
setConnectTimeout(int connectionTimeout)
Set the connect timeout (in milliseconds).
|
ApiClient |
setDateFormat(DateFormat dateFormat)
Set the date format used to parse/format date parameters.
|
ApiClient |
setTempFolderPath(String tempFolderPath) |
ApiClient |
setUserAgent(String userAgent)
Set the User-Agent header's value (by adding to the default header map).
|
public ApiClient Login(String serverHost, String username, String password)
public JSONUtil getJSON()
public javax.ws.rs.client.Client getHttpsClient()
public String getBasePath()
public int getStatusCode()
public Map<String,List<String>> getResponseHeaders()
public Map<String,Authentication> getAuthentications()
public Authentication getAuthentication(String authName)
authName - The authentication namepublic void setApiKey(String apiKey)
public void setApiKeyPrefix(String apiKeyPrefix)
public void setAccessToken(String accessToken)
public ApiClient setUserAgent(String userAgent)
public String getTempFolderPath()
null, i.e. using
the system's default tempopary folder.https://docs.oracle.com/javase/7/docs/api/java/io/File.html#createTempFile(java.lang.String,%20java.lang.String,%20java.io.File)public int getConnectTimeout()
public ApiClient setConnectTimeout(int connectionTimeout)
Integer.MAX_VALUE.public DateFormat getDateFormat()
public ApiClient setDateFormat(DateFormat dateFormat)
public String parameterToString(Object param)
public List<QueryPair> parameterToPairs(String collectionFormat, String name, Object value)
Pair objects.public boolean isJsonMime(String mime)
public String selectHeaderAccept(String[] accepts)
accepts - The accepts array to select frompublic String selectHeaderContentType(String[] contentTypes)
contentTypes - The Content-Type array to select frompublic String escapeString(String str)
public javax.ws.rs.client.Entity<?> serialize(Object obj, Map<String,Object> formParams, String contentType) throws ApiException
ApiExceptionpublic <T> T deserialize(javax.ws.rs.core.Response response,
javax.ws.rs.core.GenericType<T> returnType)
throws ApiException
ApiExceptionpublic File downloadFileFromResponse(javax.ws.rs.core.Response response) throws ApiException
ApiException - If fail to read file content from response and write to diskpublic File prepareDownloadFile(javax.ws.rs.core.Response response) throws IOException
IOExceptionpublic <T> T invokeAPI(String path, String method, List<QueryPair> queryParams, Object body, Map<String,String> headerParams, Map<String,Object> formParams, String accept, String contentType, String[] authNames, javax.ws.rs.core.GenericType<T> returnType) throws ApiException
path - The sub-path of the HTTP URLmethod - The request method, one of "GET", "POST", "PATCH", and "DELETE"queryParams - The query parametersbody - The request body objectheaderParams - The header parametersformParams - The form parametersaccept - The request's Accept headercontentType - The request's Content-Type headerauthNames - The authentications to applyreturnType - The return type into which to deserialize the responseApiExceptionpublic <T> T AsyncInvokeAPI(String path, String method, List<QueryPair> queryParams, Object body, Map<String,String> headerParams, Map<String,Object> formParams, String accept, String contentType, String[] authNames, javax.ws.rs.core.GenericType<T> returnType) throws ApiException
paths - The sub-path of the HTTP URLmethod - The request method, one of "GET", "POST", "PATCH", and "DELETE"queryParams - The query parametersbody - The request body objectheaderParams - The header parametersformParams - The form parametersaccept - The request's Accept headercontentType - The request's Content-Type headerauthNames - The authentications to applyreturnTypes - The return type into which to deserialize the responseApiExceptionCopyright © 2017. All rights reserved.