Package com.seeq
Class ApiClient
java.lang.Object
com.seeq.ApiClient
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDefaultHeader
(String key, String value) Add a default header.<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.downloadFileFromResponse
(javax.ws.rs.core.Response response) Download file from the given response.escapeString
(String str) Escape the given string to be used as URL query value.formatDate
(Date date) Format the given Date object into string.getAuthentication
(String authName) Get authentication for the given name.Get authentications (key: authentication name, value: authentication).If this client has logged in, we've stored an authorization token that can serve as proof of the client's identity for future requests.int
Connect timeout (in milliseconds).If this client has logged in, we've stored a CSRF token that can serve as proof of the client's identity for future requests.Get the date format used to parse/format date parameters.javax.ws.rs.client.Client
If this client has logged in, we've stored the user's identity (and sub-identity, if it exists).getJSON()
Gets the JSON instance to do JSON serialization and deserialization.int
Read timeout (in milliseconds).The path of temporary folder used to store downloaded files from endpoints with file response.<T> T
invokeAPI
(String path, String method, List<Pair> 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.<T> ApiClient.ApiResponse<T>
invokeAPIWithHttpInfo
(String path, String method, List<Pair> 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
Check that whether debugging is enabled for this API client.boolean
isJsonMime
(String mime) Check if the given MIME is a JSON MIME.void
logout()
Logs the current user out by clearing the authorization token.parameterToPairs
(String collectionFormat, String name, Object value) parameterToString
(Object param) Format the given parameter object into string.Parse the given string into Date object.prepareDownloadFile
(javax.ws.rs.core.Response response) 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)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 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
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.void
setAuthToken
(String authToken) Sets or overrides the authorization token for the client.setBasePath
(String basePath) setCertificatePath
(Path certificatePath) Sets the path to a custom certificate to be used for connecting using an encrypted connection.setConnectTimeout
(int connectTimeout) Set the connect timeout (in milliseconds).setDateFormat
(DateFormat dateFormat) Set the date format used to parse/format date parameters.setDebugging
(boolean debugging) Enable/disable debugging for this API client.setHttpClient
(javax.ws.rs.client.Client httpClient) void
setIdentityPath
(String identityPath) Sets or overrides the user's identity (and sub-identity, if it exists).void
setPassword
(String password) Helper method to set password for the first HTTP basic authentication.setReadTimeout
(int readTimeout) Set the read timeout (in milliseconds).setTempFolderPath
(String tempFolderPath) Set temp folder pathsetUserAgent
(String userAgent) Set the User-Agent header's value (by adding to the default header map).void
setUsername
(String username) Helper method to set username for the first HTTP basic authentication.
-
Constructor Details
-
ApiClient
public ApiClient()
-
-
Method Details
-
getJSON
Gets the JSON instance to do JSON serialization and deserialization.- Returns:
- JSON
-
getHttpClient
public javax.ws.rs.client.Client getHttpClient() -
setHttpClient
-
getBasePath
-
setBasePath
-
getAuthentications
Get authentications (key: authentication name, value: authentication).- Returns:
- Map of authentication object
-
logout
public void logout()Logs the current user out by clearing the authorization token. -
getAuthentication
Get authentication for the given name.- Parameters:
authName
- The authentication name- Returns:
- The authentication, null if not found
-
setUsername
Helper method to set username for the first HTTP basic authentication.- Parameters:
username
- Username
-
setPassword
Helper method to set password for the first HTTP basic authentication.- Parameters:
password
- Password
-
setApiKey
Helper method to set API key value for the first API key authentication.- Parameters:
accessKey
- API key
-
setCertificatePath
Sets the path to a custom certificate to be used for connecting using an encrypted connection. If connecting against an unknown CA/certificate chain or using self-signed certificates, setting the certificate path will be necessary. If connecting against an official CA/certificate chain, setting the certificate path shouldn't be necessary as it'll be handled by the OS.- Parameters:
certificatePath
- The path to a certificate (PEM) file containing the public key/cert and any necessary CA chains
-
setApiKeyPrefix
Helper method to set API key prefix for the first API key authentication.- Parameters:
apiKeyPrefix
- API key prefix
-
setAccessToken
Helper method to set access token for the first OAuth2 authentication.- Parameters:
accessToken
- Access token
-
setUserAgent
Set the User-Agent header's value (by adding to the default header map).- Parameters:
userAgent
- Http user agent- Returns:
- API client
-
addDefaultHeader
Add a default header.- Parameters:
key
- The header's keyvalue
- The header's value- Returns:
- API client
-
isDebugging
public boolean isDebugging()Check that whether debugging is enabled for this API client.- Returns:
- True if debugging is switched on
-
setDebugging
Enable/disable debugging for this API client.- Parameters:
debugging
- To enable (true) or disable (false) debugging- Returns:
- API client
-
getTempFolderPath
The path of temporary folder used to store downloaded files from endpoints with file response. The default value isnull
, i.e. using the system's default tempopary folder.- Returns:
- Temp folder path
-
setTempFolderPath
Set temp folder path- Parameters:
tempFolderPath
- Temp folder path- Returns:
- API client
-
getConnectTimeout
public int getConnectTimeout()Connect timeout (in milliseconds).- Returns:
- Connection timeout
-
setConnectTimeout
Set the connect timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 andInteger.MAX_VALUE
.- Parameters:
connectTimeout
- Connection timeout in milliseconds- Returns:
- API client
-
getReadTimeout
public int getReadTimeout()Read timeout (in milliseconds).- Returns:
- Read timeout
-
setReadTimeout
Set the read timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 andInteger.MAX_VALUE
.- Parameters:
readTimeout
- Read timeout in milliseconds- Returns:
- API client
-
getDateFormat
Get the date format used to parse/format date parameters.- Returns:
- Date format
-
setDateFormat
Set the date format used to parse/format date parameters.- Parameters:
dateFormat
- Date format- Returns:
- API client
-
parseDate
Parse the given string into Date object.- Parameters:
str
- String- Returns:
- Date
-
formatDate
Format the given Date object into string.- Parameters:
date
- Date- Returns:
- Date in string format
-
parameterToString
Format the given parameter object into string.- Parameters:
param
- Object- Returns:
- Object in string format
-
parameterToPairs
-
isJsonMime
Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json- Parameters:
mime
- MIME- Returns:
- True if the MIME type is JSON
-
selectHeaderAccept
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)- Parameters:
accepts
- The accepts array to select from- Returns:
- The Accept header to use. If the given array is empty, null will be returned (not to set the Accept header explicitly).
-
selectHeaderContentType
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.- Parameters:
contentTypes
- The Content-Type array to select from- Returns:
- The Content-Type header to use. If the given array is empty, JSON will be used.
-
escapeString
Escape the given string to be used as URL query value.- Parameters:
str
- String- Returns:
- Escaped string
-
serialize
public javax.ws.rs.client.Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType) throws ApiExceptionSerialize the given Java object into string entity according the given Content-Type (only JSON is supported for now).- Parameters:
obj
- ObjectformParams
- Form parameterscontentType
- Context type- Returns:
- Entity
- Throws:
ApiException
- API exception
-
deserialize
public <T> T deserialize(javax.ws.rs.core.Response response, javax.ws.rs.core.GenericType<T> returnType) throws ApiException Deserialize response body to Java object according to the Content-Type.- Type Parameters:
T
- Type- Parameters:
response
- ResponsereturnType
- Return type- Returns:
- Deserialize object
- Throws:
ApiException
- API exception
-
downloadFileFromResponse
Download file from the given response.- Parameters:
response
- Response- Returns:
- File
- Throws:
ApiException
- If fail to read file content from response and write to disk
-
prepareDownloadFile
- Throws:
IOException
-
invokeAPI
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, throws ApiExceptionObject> formParams, String accept, String contentType, String[] authNames, javax.ws.rs.core.GenericType<T> returnType) Invoke API by sending HTTP request with the given options.- Type Parameters:
T
- API return object type- Parameters:
path
- The sub-path of the HTTP URLmethod
- The request method, one of "GET", "POST", "PUT", 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 response- Returns:
- The data object from the API response
- Throws:
ApiException
- API exception
-
invokeAPIWithHttpInfo
public <T> ApiClient.ApiResponse<T> invokeAPIWithHttpInfo(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, throws ApiExceptionObject> formParams, String accept, String contentType, String[] authNames, javax.ws.rs.core.GenericType<T> returnType) Invoke API by sending HTTP request with the given options.- Type Parameters:
T
- API return object type- Parameters:
path
- The sub-path of the HTTP URLmethod
- The request method, one of "GET", "POST", "PUT", 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 response- Returns:
- An ApiResponse object with the status code, response headers and data object
- Throws:
ApiException
- API exception
-
getAuthToken
If this client has logged in, we've stored an authorization token that can serve as proof of the client's identity for future requests. This method retrieves the authorization token. Note: the authorization token is secret and should be protected like a password, but unlike a password it will expire after the client logs out.- Returns:
- the authorization token, or null if the client isn't logged in.
-
setAuthToken
Sets or overrides the authorization token for the client. Note: If an invalid authorization token is provided. This client will not be usable until reauthenticated. -
getIdentityPath
If this client has logged in, we've stored the user's identity (and sub-identity, if it exists).- Returns:
- the full identity path, or null if the client isn't logged in.
-
setIdentityPath
Sets or overrides the user's identity (and sub-identity, if it exists). -
getCsrfToken
If this client has logged in, we've stored a CSRF token that can serve as proof of the client's identity for future requests. This method retrieves the CSRF token. Note: the CSRF token is secret and should be protected like a password, but unlike a password it will expire after the client logs out.- Returns:
- the CSRF token, or null if the client isn't logged in.
-