Package com.okta.sdk.resource.client
Class ApiClient
java.lang.Object
com.okta.sdk.resource.client.JavaTimeFormatter
com.okta.sdk.resource.client.ApiClient
@Generated(value="org.openapitools.codegen.languages.JavaClientCodegen",
date="2024-03-29T16:47:02.065887-05:00[America/Chicago]",
comments="Generator version: 7.4.0")
public class ApiClient
extends JavaTimeFormatter
-
Field Summary
Modifier and TypeFieldDescriptionprotected Integer
protected List
<ServerConfiguration> protected String
-
Constructor Summary
ConstructorDescriptionApiClient
(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient, CacheManager cacheManager, com.okta.commons.http.config.HttpClientConfiguration httpClientConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionaddDefaultCookie
(String key, String value) Add a default cookie.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
<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.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).int
Connect timeout (in milliseconds).Get the date format used to parse/format date parameters.org.apache.hc.client5.http.impl.classic.CloseableHttpClient
com.fasterxml.jackson.databind.ObjectMapper
Returns the current object mapper used for JSON serialization/deserialization.Gets the response headers of the previous requestint
Gets the status code of the previous requestThe 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
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) parameterToPair
(String name, Object value) Formats the specified query parameter to a list containing a singlePair
object.parameterToPairs
(String collectionFormat, String name, Collection value) Formats the specified collection query parameters to a list ofPair
objects.parameterToString
(Object param) Format the given parameter object into string.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.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.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).setAccessToken
(String accessToken) Helper method to set access token for the first OAuth2 authentication.Helper method to set API key value for the first API key authentication.setApiKeyPrefix
(String apiKeyPrefix) Helper method to set API key prefix for the first API key authentication.setBasePath
(String basePath) Sets the base path.setConnectTimeout
(int connectionTimeout) 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
(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient) Sets the HTTP client.setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Sets the object mapper.setServerIndex
(Integer serverIndex) Sets the server index.setServers
(List<ServerConfiguration> servers) Sets the server.setServerVariables
(Map<String, String> serverVariables) Sets the server variables.setTempFolderPath
(String tempFolderPath) Set temp folder pathsetUserAgent
(String userAgent) Set the User-Agent header's value (by adding to the default header map).transformResponseHeaders
(org.apache.hc.core5.http.Header[] headers) Transforms response headers into map.Methods inherited from class com.okta.sdk.resource.client.JavaTimeFormatter
formatOffsetDateTime, getOffsetDateTimeFormatter, parseOffsetDateTime, setOffsetDateTimeFormatter
-
Field Details
-
servers
-
serverIndex
-
serverVariables
-
tempFolderPath
-
-
Constructor Details
-
ApiClient
public ApiClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient, CacheManager cacheManager, com.okta.commons.http.config.HttpClientConfiguration httpClientConfiguration) -
ApiClient
public ApiClient()
-
-
Method Details
-
buildDefaultDateFormat
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Returns the current object mapper used for JSON serialization/deserialization.Note: If you make changes to the object mapper, remember to set it back via
setObjectMapper
in order to trigger HTTP client rebuilding.- Returns:
- Object mapper
-
setObjectMapper
Sets the object mapper.- Parameters:
objectMapper
- object mapper- Returns:
- API client
-
getHttpClient
public org.apache.hc.client5.http.impl.classic.CloseableHttpClient getHttpClient() -
setHttpClient
public ApiClient setHttpClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient) Sets the HTTP client.- Parameters:
httpClient
- HTTP client- Returns:
- API client
-
getBasePath
-
setBasePath
Sets the base path.- Parameters:
basePath
- base path- Returns:
- API client
-
getServers
-
setServers
Sets the server.- Parameters:
servers
- a list of server configuration- Returns:
- API client
-
getServerIndex
-
setServerIndex
Sets the server index.- Parameters:
serverIndex
- server index- Returns:
- API client
-
getServerVariables
-
setServerVariables
Sets the server variables.- Parameters:
serverVariables
- server variables- Returns:
- API client
-
getStatusCode
public int getStatusCode()Gets the status code of the previous request- Returns:
- Status code
-
getResponseHeaders
Gets the response headers of the previous request- Returns:
- Response headers
-
getAuthentications
Get authentications (key: authentication name, value: authentication).- Returns:
- Map of authentication
-
getAuthentication
Get authentication for the given name.- Parameters:
authName
- The authentication name- Returns:
- The authentication, null if not found
-
replaceAuthentication
Replaces authentication for the given name.- Parameters:
authName
- The authentication nameauthentication
- The new implementation (must be of the same type of the existing implementation)
-
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 temporary folder.- Returns:
- Temp folder path
-
setApiKey
Helper method to set API key value for the first API key authentication.- Parameters:
apiKey
- the API key- Returns:
- API client
-
setApiKeyPrefix
Helper method to set API key prefix for the first API key authentication.- Parameters:
apiKeyPrefix
- API key prefix- Returns:
- API client
-
setAccessToken
Helper method to set access token for the first OAuth2 authentication.- Parameters:
accessToken
- Access token- Returns:
- API client
-
setUserAgent
Set the User-Agent header's value (by adding to the default header map).- Parameters:
userAgent
- User agent- Returns:
- API client
-
setTempFolderPath
Set temp folder path- Parameters:
tempFolderPath
- Temp folder path- Returns:
- API client
-
addDefaultHeader
Add a default header.- Parameters:
key
- The header's keyvalue
- The header's value- Returns:
- API client
-
addDefaultCookie
Add a default cookie.- Parameters:
key
- The cookie's keyvalue
- The cookie's value- Returns:
- API client
-
isDebugging
public boolean isDebugging()Check that whether debugging is enabled for this API client.- Returns:
- True if debugging is on
-
setDebugging
Enable/disable debugging for this API client.- Parameters:
debugging
- To enable (true) or disable (false) debugging- 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:
connectionTimeout
- Connection 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
-
parameterToPair
Formats the specified query parameter to a list containing a singlePair
object. Note thatvalue
must not be a collection.- Parameters:
name
- The name of the parameter.value
- The value of the parameter.- Returns:
- A list containing a single
Pair
object.
-
parameterToPairs
Formats the specified collection query parameters to a list ofPair
objects. Note that the values of each of the returned Pair objects are percent-encoded.- Parameters:
collectionFormat
- The collection format of the parameter.name
- The name of the parameter.value
- The value of the parameter.- Returns:
- A list of
Pair
objects.
-
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 MIME type is boolean
-
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, or matches "any", JSON will be used.
-
escapeString
Escape the given string to be used as URL query value.- Parameters:
str
- String- Returns:
- Escaped string
-
transformResponseHeaders
protected Map<String,List<String>> transformResponseHeaders(org.apache.hc.core5.http.Header[] headers) Transforms response headers into map.- Parameters:
headers
- HTTP headers- Returns:
- a map of string array
-
serialize
public org.apache.hc.core5.http.HttpEntity serialize(Object obj, Map<String, Object> formParams, org.apache.hc.core5.http.ContentType contentType) throws ApiExceptionSerialize the given Java object into string according the given Content-Type (only JSON is supported for now).- Parameters:
obj
- ObjectformParams
- Form parameterscontentType
- Content type- Returns:
- Object
- Throws:
ApiException
- API exception
-
deserialize
public <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 Deserialize response body to Java object according to the Content-Type.- Type Parameters:
T
- Type- Parameters:
response
- ResponsevalueType
- Return type- Returns:
- Deserialized object
- Throws:
ApiException
- API exceptionIOException
- IO exceptionorg.apache.hc.core5.http.ParseException
-
prepareDownloadFile
- Throws:
IOException
-
isSuccessfulStatus
protected boolean isSuccessfulStatus(int statusCode) -
isBodyAllowed
-
buildCookie
-
processResponse
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 - Throws:
ApiException
IOException
org.apache.hc.core5.http.ParseException
-
invokeAPI
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, String urlQueryDeepObject, Object body, Map<String, String> headerParams, Map<String, throws ApiExceptionString> 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.- Type Parameters:
T
- Type- Parameters:
path
- 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 type- Returns:
- The response body in type of string
- Throws:
ApiException
- API exception
-