@Generated(value="org.openapitools.codegen.languages.JavaClientCodegen", date="2023-07-14T23:40:43.026Z[Etc/UTC]") public class ApiClient extends JavaTimeFormatter
Modifier and Type | Field and Description |
---|---|
protected Integer |
serverIndex |
protected List<ServerConfiguration> |
servers |
protected Map<String,String> |
serverVariables |
protected String |
tempFolderPath |
Constructor and Description |
---|
ApiClient() |
ApiClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient,
CacheManager cacheManager,
com.okta.commons.http.config.HttpClientConfiguration httpClientConfiguration) |
Modifier and Type | Method and Description |
---|---|
ApiClient |
addDefaultCookie(String key,
String value)
Add a default cookie.
|
ApiClient |
addDefaultHeader(String key,
String value)
Add a default header.
|
protected org.apache.hc.client5.http.cookie.Cookie |
buildCookie(String key,
String value,
URI uri) |
static DateFormat |
buildDefaultDateFormat() |
<T> T |
deserialize(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response,
com.fasterxml.jackson.core.type.TypeReference<T> valueType)
Deserialize response body to Java object according to the Content-Type.
|
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() |
int |
getConnectTimeout()
Connect timeout (in milliseconds).
|
DateFormat |
getDateFormat()
Get the date format used to parse/format date parameters.
|
org.apache.hc.client5.http.impl.classic.CloseableHttpClient |
getHttpClient() |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Returns the current object mapper used for JSON serialization/deserialization.
|
Map<String,List<String>> |
getResponseHeaders()
Gets the response headers of the previous request
|
Integer |
getServerIndex() |
List<ServerConfiguration> |
getServers() |
Map<String,String> |
getServerVariables() |
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<Pair> queryParams,
List<Pair> collectionQueryParams,
String urlQueryDeepObject,
Object body,
Map<String,String> headerParams,
Map<String,String> cookieParams,
Map<String,Object> formParams,
String accept,
String contentType,
String[] authNames,
com.fasterxml.jackson.core.type.TypeReference<T> returnType)
Invoke API by sending HTTP request with the given options.
|
protected boolean |
isBodyAllowed(String method) |
boolean |
isDebugging()
Check that whether debugging is enabled for this API client.
|
boolean |
isJsonMime(String mime)
Check if the given MIME is a JSON MIME.
|
protected boolean |
isSuccessfulStatus(int statusCode) |
List<Pair> |
parameterToPair(String name,
Object value)
Formats the specified query parameter to a list containing a single
Pair object. |
List<Pair> |
parameterToPairs(String collectionFormat,
String name,
Collection value)
Formats the specified collection query parameters to a list of
Pair objects. |
String |
parameterToString(Object param)
Format the given parameter object into string.
|
Date |
parseDate(String str)
Parse the given string into Date object.
|
protected File |
prepareDownloadFile(String contentDisposition) |
protected <T> T |
processResponse(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response,
com.fasterxml.jackson.core.type.TypeReference<T> returnType) |
void |
replaceAuthentication(String authName,
Authentication authentication)
Replaces authentication for the given name.
|
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.
|
org.apache.hc.core5.http.HttpEntity |
serialize(Object obj,
Map<String,Object> formParams,
org.apache.hc.core5.http.ContentType contentType)
Serialize the given Java object into string according the given
Content-Type (only JSON is supported for now).
|
ApiClient |
setAccessToken(String accessToken)
Helper method to set access token for the first OAuth2 authentication.
|
ApiClient |
setApiKey(String apiKey)
Helper method to set API key value for the first API key authentication.
|
ApiClient |
setApiKeyPrefix(String apiKeyPrefix)
Helper method to set API key prefix for the first API key authentication.
|
ApiClient |
setBasePath(String basePath)
Sets the base path.
|
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 |
setDebugging(boolean debugging)
Enable/disable debugging for this API client.
|
ApiClient |
setHttpClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient)
Sets the HTTP client.
|
ApiClient |
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Sets the object mapper.
|
ApiClient |
setServerIndex(Integer serverIndex)
Sets the server index.
|
ApiClient |
setServers(List<ServerConfiguration> servers)
Sets the server.
|
ApiClient |
setServerVariables(Map<String,String> serverVariables)
Sets the server variables.
|
ApiClient |
setTempFolderPath(String tempFolderPath)
Set temp folder path
|
ApiClient |
setUserAgent(String userAgent)
Set the User-Agent header's value (by adding to the default header map).
|
protected Map<String,List<String>> |
transformResponseHeaders(org.apache.hc.core5.http.Header[] headers)
Transforms response headers into map.
|
formatOffsetDateTime, getOffsetDateTimeFormatter, parseOffsetDateTime, setOffsetDateTimeFormatter
protected List<ServerConfiguration> servers
protected Integer serverIndex
protected String tempFolderPath
public ApiClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient, CacheManager cacheManager, com.okta.commons.http.config.HttpClientConfiguration httpClientConfiguration)
public ApiClient()
public static DateFormat buildDefaultDateFormat()
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
Note: If you make changes to the object mapper, remember to set it back via
setObjectMapper
in order to trigger HTTP client rebuilding.
public ApiClient setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper
- object mapperpublic org.apache.hc.client5.http.impl.classic.CloseableHttpClient getHttpClient()
public ApiClient setHttpClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient)
httpClient
- HTTP clientpublic String getBasePath()
public ApiClient setBasePath(String basePath)
basePath
- base pathpublic List<ServerConfiguration> getServers()
public ApiClient setServers(List<ServerConfiguration> servers)
servers
- a list of server configurationpublic Integer getServerIndex()
public ApiClient setServerIndex(Integer serverIndex)
serverIndex
- server indexpublic ApiClient setServerVariables(Map<String,String> serverVariables)
serverVariables
- server variablespublic int getStatusCode()
public Map<String,List<String>> getResponseHeaders()
public Map<String,Authentication> getAuthentications()
public Authentication getAuthentication(String authName)
authName
- The authentication namepublic void replaceAuthentication(String authName, Authentication authentication)
authName
- The authentication nameauthentication
- The new implementation (must be of the same type of the existing implementation)public String getTempFolderPath()
null
, i.e. using
the system's default temporary folder.public ApiClient setApiKey(String apiKey)
apiKey
- the API keypublic ApiClient setApiKeyPrefix(String apiKeyPrefix)
apiKeyPrefix
- API key prefixpublic ApiClient setAccessToken(String accessToken)
accessToken
- Access tokenpublic ApiClient setUserAgent(String userAgent)
userAgent
- User agentpublic ApiClient setTempFolderPath(String tempFolderPath)
tempFolderPath
- Temp folder pathpublic ApiClient addDefaultHeader(String key, String value)
key
- The header's keyvalue
- The header's valuepublic ApiClient addDefaultCookie(String key, String value)
key
- The cookie's keyvalue
- The cookie's valuepublic boolean isDebugging()
public ApiClient setDebugging(boolean debugging)
debugging
- To enable (true) or disable (false) debuggingpublic int getConnectTimeout()
public ApiClient setConnectTimeout(int connectionTimeout)
Integer.MAX_VALUE
.connectionTimeout
- Connection timeout in millisecondspublic DateFormat getDateFormat()
public ApiClient setDateFormat(DateFormat dateFormat)
dateFormat
- Date formatpublic Date parseDate(String str)
str
- Stringpublic String formatDate(Date date)
date
- Datepublic String parameterToString(Object param)
param
- Objectpublic List<Pair> parameterToPair(String name, Object value)
Pair
object.
Note that value
must not be a collection.name
- The name of the parameter.value
- The value of the parameter.Pair
object.public List<Pair> parameterToPairs(String collectionFormat, String name, Collection value)
Pair
objects.
Note that the values of each of the returned Pair objects are percent-encoded.collectionFormat
- The collection format of the parameter.name
- The name of the parameter.value
- The value of the parameter.Pair
objects.public boolean isJsonMime(String mime)
mime
- MIMEpublic 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)
str
- Stringprotected Map<String,List<String>> transformResponseHeaders(org.apache.hc.core5.http.Header[] headers)
headers
- HTTP headerspublic org.apache.hc.core5.http.HttpEntity serialize(Object obj, Map<String,Object> formParams, org.apache.hc.core5.http.ContentType contentType) throws ApiException
obj
- ObjectcontentType
- Content typeformParams
- Form parametersApiException
- API exceptionpublic <T> T deserialize(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response, com.fasterxml.jackson.core.type.TypeReference<T> valueType) throws ApiException, IOException, org.apache.hc.core5.http.ParseException
T
- Typeresponse
- ResponsevalueType
- Return typeApiException
- API exceptionIOException
- IO exceptionorg.apache.hc.core5.http.ParseException
protected File prepareDownloadFile(String contentDisposition) throws IOException
IOException
protected boolean isSuccessfulStatus(int statusCode)
protected boolean isBodyAllowed(String method)
protected org.apache.hc.client5.http.cookie.Cookie buildCookie(String key, String value, URI uri)
protected <T> T processResponse(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response, com.fasterxml.jackson.core.type.TypeReference<T> returnType) throws ApiException, IOException, org.apache.hc.core5.http.ParseException
ApiException
IOException
org.apache.hc.core5.http.ParseException
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, String urlQueryDeepObject, Object body, Map<String,String> headerParams, Map<String,String> cookieParams, Map<String,Object> formParams, String accept, String contentType, String[] authNames, com.fasterxml.jackson.core.type.TypeReference<T> returnType) throws ApiException
T
- Typepath
- The sub-path of the HTTP URLmethod
- The request method, one of "GET", "POST", "PUT", and "DELETE"queryParams
- The query parameterscollectionQueryParams
- The collection query parametersurlQueryDeepObject
- A URL query string for deep object parametersbody
- The request body object - if it is not binary, otherwise nullheaderParams
- The header parameterscookieParams
- The cookie parametersformParams
- The form parametersaccept
- The request's Accept headercontentType
- The request's Content-Type headerauthNames
- The authentications to applyreturnType
- Return typeApiException
- API exceptionCopyright © 2017–2023 Okta. All rights reserved.