@Generated(value="org.openapitools.codegen.languages.JavaClientCodegen", date="2024-01-18T11:30:51.778905-05:00[America/New_York]") public class ApiClient extends JavaTimeFormatter
ApiClient class.
Modifier and Type | Field and Description |
---|---|
protected Map<String,String> |
authenticationLookup |
protected Map<String,Authentication> |
authentications |
protected String |
basePath |
protected ClientConfig |
clientConfig |
protected int |
connectionTimeout |
protected DateFormat |
dateFormat |
protected boolean |
debugging |
protected Map<String,String> |
defaultCookieMap |
protected Map<String,String> |
defaultHeaderMap |
protected Client |
httpClient |
protected JSON |
json |
protected Map<String,Integer> |
operationServerIndex |
protected Map<String,List<ServerConfiguration>> |
operationServers |
protected Map<String,Map<String,String>> |
operationServerVariables |
protected Integer |
serverIndex |
protected List<ServerConfiguration> |
servers |
protected Map<String,String> |
serverVariables |
protected String |
tempFolderPath |
protected String |
userAgent |
Constructor and Description |
---|
ApiClient()
Constructs a new ApiClient with default parameters.
|
ApiClient(Map<String,Authentication> authMap)
Constructs a new ApiClient with the specified authentication parameters.
|
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 Client |
buildHttpClient()
Build the Client used to make HTTP requests.
|
protected Map<String,List<String>> |
buildResponseHeaders(Response response)
Build the response headers.
|
ApiClient |
configureApiKeys(Map<String,String> secrets)
Helper method to configure authentications which respects aliases of API keys.
|
<T> T |
deserialize(Response response,
GenericType<T> returnType)
Deserialize response body to Java object according to the Content-Type.
|
protected void |
disableCertificateValidation(ClientBuilder clientBuilder)
Disable X.509 certificate validation in TLS connections.
|
File |
downloadFileFromResponse(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()
Returns the base URL to the location where the OpenAPI document is being served.
|
ClientConfig |
getClientConfig()
Gets the client config.
|
int |
getConnectTimeout()
Connect timeout (in milliseconds).
|
DateFormat |
getDateFormat()
Get the date format used to parse/format date parameters.
|
ClientConfig |
getDefaultClientConfig()
Get the default client config.
|
Client |
getHttpClient()
Getter for the field
httpClient . |
JSON |
getJSON()
Gets the JSON instance to do JSON serialization and deserialization.
|
int |
getReadTimeout()
read timeout (in milliseconds).
|
Integer |
getServerIndex()
Getter for the field
serverIndex . |
List<ServerConfiguration> |
getServers()
Getter for the field
servers . |
Map<String,String> |
getServerVariables()
Getter for the field
serverVariables . |
String |
getTempFolderPath()
The path of temporary folder used to store downloaded files from endpoints
with file response.
|
String |
getUserAgent()
Get the User-Agent header's value.
|
<T> ApiResponse<T> |
invokeAPI(String path,
String method,
List<Pair> queryParams,
Object body,
Map<String,String> headerParams,
Map<String,String> cookieParams,
Map<String,Object> formParams,
String accept,
String contentType,
String[] authNames,
GenericType<T> returnType,
boolean isBodyNullable)
Deprecated.
Add qualified name of the operation as a first parameter.
|
<T> ApiResponse<T> |
invokeAPI(String operation,
String path,
String method,
List<Pair> queryParams,
Object body,
Map<String,String> headerParams,
Map<String,String> cookieParams,
Map<String,Object> formParams,
String accept,
String contentType,
String[] authNames,
GenericType<T> returnType,
boolean isBodyNullable)
Invoke API by sending HTTP request with the given options.
|
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.
|
List<Pair> |
parameterToPairs(String collectionFormat,
String name,
Object value) |
String |
parameterToString(Object param)
Format the given parameter object into string.
|
Date |
parseDate(String str)
Parse the given string into Date object.
|
File |
prepareDownloadFile(Response response)
Prepare the file for download from the 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.
|
Entity<?> |
serialize(Object obj,
Map<String,Object> formParams,
String contentType,
boolean isBodyNullable)
Serialize the given Java object into string entity according the given
Content-Type (only JSON is supported for now).
|
String |
serializeToString(Object obj,
Map<String,Object> formParams,
String contentType,
boolean isBodyNullable)
Serialize the given Java object into string according the given
Content-Type (only JSON, HTTP form is supported for now).
|
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 URL to the location where the OpenAPI document is being served.
|
ApiClient |
setBearerToken(String bearerToken)
Helper method to set bearer token for the first Bearer authentication.
|
ApiClient |
setClientConfig(ClientConfig clientConfig)
Set the client config.
|
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(Client httpClient)
Setter for the field
httpClient . |
ApiClient |
setPassword(String password)
Helper method to set password for the first HTTP basic authentication.
|
ApiClient |
setReadTimeout(int readTimeout)
Set the read timeout (in milliseconds).
|
ApiClient |
setServerIndex(Integer serverIndex)
Setter for the field
serverIndex . |
ApiClient |
setServers(List<ServerConfiguration> servers)
Setter for the field
servers . |
ApiClient |
setServerVariables(Map<String,String> serverVariables)
Setter for the field
serverVariables . |
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).
|
ApiClient |
setUsername(String username)
Helper method to set username for the first HTTP basic authentication.
|
protected void |
updateParamsForAuth(String[] authNames,
List<Pair> queryParams,
Map<String,String> headerParams,
Map<String,String> cookieParams,
String payload,
String method,
URI uri)
Update query and header parameters based on authentication settings.
|
formatOffsetDateTime, getOffsetDateTimeFormatter, parseOffsetDateTime, setOffsetDateTimeFormatter
protected String basePath
protected String userAgent
protected List<ServerConfiguration> servers
protected Integer serverIndex
protected Map<String,List<ServerConfiguration>> operationServers
protected boolean debugging
protected ClientConfig clientConfig
protected int connectionTimeout
protected Client httpClient
protected JSON json
protected String tempFolderPath
protected Map<String,Authentication> authentications
protected DateFormat dateFormat
public ApiClient()
public ApiClient(Map<String,Authentication> authMap)
authMap
- A hash map containing authentication parameters.public JSON getJSON()
public Client getHttpClient()
Getter for the field httpClient
.
Client
object.public ApiClient setHttpClient(Client httpClient)
Setter for the field httpClient
.
httpClient
- a Client
object.org.openapitools.client.ApiClient
object.public String getBasePath()
public ApiClient setBasePath(String basePath)
basePath
- The base URL to the target host.org.openapitools.client.ApiClient
object.public List<ServerConfiguration> getServers()
Getter for the field servers
.
List
of servers.public ApiClient setServers(List<ServerConfiguration> servers)
Setter for the field servers
.
servers
- a List
of servers.org.openapitools.client.ApiClient
object.public Integer getServerIndex()
Getter for the field serverIndex
.
Integer
object.public ApiClient setServerIndex(Integer serverIndex)
Setter for the field serverIndex
.
serverIndex
- the server indexorg.openapitools.client.ApiClient
object.public Map<String,String> getServerVariables()
Getter for the field serverVariables
.
Map
of server variables.public ApiClient setServerVariables(Map<String,String> serverVariables)
Setter for the field serverVariables
.
serverVariables
- a Map
of server variables.org.openapitools.client.ApiClient
object.public Map<String,Authentication> getAuthentications()
public Authentication getAuthentication(String authName)
authName
- The authentication namepublic ApiClient setUsername(String username)
username
- Usernameorg.openapitools.client.ApiClient
object.public ApiClient setPassword(String password)
password
- Passwordorg.openapitools.client.ApiClient
object.public ApiClient setApiKey(String apiKey)
apiKey
- API keyorg.openapitools.client.ApiClient
object.public ApiClient configureApiKeys(Map<String,String> secrets)
secrets
- Hash map from authentication name to its secret.org.openapitools.client.ApiClient
object.public ApiClient setApiKeyPrefix(String apiKeyPrefix)
apiKeyPrefix
- API key prefixorg.openapitools.client.ApiClient
object.public ApiClient setBearerToken(String bearerToken)
bearerToken
- Bearer tokenorg.openapitools.client.ApiClient
object.public ApiClient setUserAgent(String userAgent)
userAgent
- Http user agentorg.openapitools.client.ApiClient
object.public String getUserAgent()
public ApiClient addDefaultHeader(String key, String value)
key
- The header's keyvalue
- The header's valueorg.openapitools.client.ApiClient
object.public ApiClient addDefaultCookie(String key, String value)
key
- The cookie's keyvalue
- The cookie's valueorg.openapitools.client.ApiClient
object.public ClientConfig getClientConfig()
public ApiClient setClientConfig(ClientConfig clientConfig)
clientConfig
- Set the client configorg.openapitools.client.ApiClient
object.public boolean isDebugging()
public ApiClient setDebugging(boolean debugging)
debugging
- To enable (true) or disable (false) debuggingorg.openapitools.client.ApiClient
object.public String getTempFolderPath()
null
, i.e. using
the system's default temporary folder.public ApiClient setTempFolderPath(String tempFolderPath)
tempFolderPath
- Temp folder pathorg.openapitools.client.ApiClient
object.public int getConnectTimeout()
public ApiClient setConnectTimeout(int connectionTimeout)
Integer.MAX_VALUE
.connectionTimeout
- Connection timeout in millisecondsorg.openapitools.client.ApiClient
object.public int getReadTimeout()
public ApiClient setReadTimeout(int readTimeout)
Integer.MAX_VALUE
.readTimeout
- Read timeout in millisecondsorg.openapitools.client.ApiClient
object.public DateFormat getDateFormat()
public ApiClient setDateFormat(DateFormat dateFormat)
dateFormat
- Date formatorg.openapitools.client.ApiClient
object.public Date parseDate(String str)
str
- Stringpublic String formatDate(Date date)
date
- Datepublic String parameterToString(Object param)
param
- Objectpublic List<Pair> parameterToPairs(String collectionFormat, String name, Object value)
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
- Stringpublic Entity<?> serialize(Object obj, Map<String,Object> formParams, String contentType, boolean isBodyNullable) throws ApiException
obj
- ObjectformParams
- Form parameterscontentType
- Context typeApiException
- API exceptionpublic String serializeToString(Object obj, Map<String,Object> formParams, String contentType, boolean isBodyNullable) throws ApiException
obj
- ObjectformParams
- Form parameterscontentType
- Context typeisBodyNullable
- True if the body is nullableApiException
- API exceptionpublic <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException
T
- Typeresponse
- ResponsereturnType
- Return typeApiException
- API exceptionpublic File downloadFileFromResponse(Response response) throws ApiException
response
- ResponseApiException
- If fail to read file content from response and write to diskpublic File prepareDownloadFile(Response response) throws IOException
Prepare the file for download from the response.
response
- a Response
object.File
object.IOException
- if any.public <T> ApiResponse<T> invokeAPI(String operation, String path, String method, List<Pair> queryParams, Object body, Map<String,String> headerParams, Map<String,String> cookieParams, Map<String,Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType, boolean isBodyNullable) throws ApiException
T
- Typeoperation
- The qualified name of the operationpath
- The sub-path of the HTTP URLmethod
- The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"queryParams
- The query parametersbody
- The request body objectheaderParams
- The header parameterscookieParams
- The cookie 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 responseisBodyNullable
- True if the body is nullableApiException
- API exception@Deprecated public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String,String> headerParams, Map<String,String> cookieParams, Map<String,Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType, boolean isBodyNullable) throws ApiException
ApiException
protected Client buildHttpClient()
public ClientConfig getDefaultClientConfig()
protected void disableCertificateValidation(ClientBuilder clientBuilder) throws KeyManagementException, NoSuchAlgorithmException
clientBuilder
- a ClientBuilder
object.KeyManagementException
- if any.NoSuchAlgorithmException
- if any.protected Map<String,List<String>> buildResponseHeaders(Response response)
Build the response headers.
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String,String> headerParams, Map<String,String> cookieParams, String payload, String method, URI uri) throws ApiException
authNames
- The authentications to applyqueryParams
- List of query parametersheaderParams
- Map of header parameterscookieParams
- Map of cookie parametersmethod
- HTTP method (e.g. POST)uri
- HTTP URIApiException