@Generated(value="https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class ApiClient extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Authentication> |
authentications |
protected String |
basePath |
protected org.glassfish.jersey.client.ClientConfig |
clientConfig |
protected boolean |
compress |
protected int |
connectionTimeout |
protected DateFormat |
dateFormat |
protected boolean |
debugging |
protected Map<String,String> |
defaultCookieMap |
protected Map<String,String> |
defaultHeaderMap |
protected jakarta.ws.rs.client.Client |
httpClient |
protected JSON |
json |
protected static Logger |
logger |
protected Map<String,Integer> |
operationServerIndex |
protected Map<String,List<ServerConfiguration>> |
operationServers |
protected Map<String,Map<String,String>> |
operationServerVariables |
protected RetryConfig |
retry |
protected Integer |
serverIndex |
protected List<ServerConfiguration> |
servers |
protected Map<String,String> |
serverVariables |
protected String |
tempFolderPath |
protected Map<String,Boolean> |
unstableOperations |
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 jakarta.ws.rs.client.Client |
buildHttpClient()
Build the Client used to make HTTP requests.
|
protected Map<String,List<String>> |
buildResponseHeaders(jakarta.ws.rs.core.Response response) |
ApiClient |
configureApiKeys(Map<String,String> secrets)
Helper method to configure authentications which respects aliases of API keys.
|
jakarta.ws.rs.client.Invocation.Builder |
createBuilder(String operation,
String path,
List<Pair> queryParams,
Map<String,String> headerParams,
Map<String,String> cookieParams,
String[] accepts,
String[] authNames)
Create builder to invoke the API.
|
protected void |
customizeClientBuilder(jakarta.ws.rs.client.ClientBuilder clientBuilder)
Customize the client builder.
|
<T> T |
deserialize(jakarta.ws.rs.core.Response response,
jakarta.ws.rs.core.GenericType<T> returnType)
Deserialize response body to Java object according to the Content-Type.
|
protected void |
disableCertificateValidation(jakarta.ws.rs.client.ClientBuilder clientBuilder)
Disable X.509 certificate validation in TLS connections.
|
void |
enableRetry(boolean enableRetry)
Enable retry directly on the client instead of creating a new retry object
|
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.
|
String |
formatOffsetDateTime(OffsetDateTime offsetDateTime)
Format the given
OffsetDateTime 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.
|
org.glassfish.jersey.client.ClientConfig |
getClientConfig()
Gets the client config.
|
int |
getConnectTimeout()
Connect timeout (in milliseconds).
|
DateFormat |
getDateFormat()
Get the date format used to parse/format date parameters.
|
static ApiClient |
getDefaultApiClient()
Get the default API client, which would be used when creating API instances without providing
an API client.
|
org.glassfish.jersey.client.ClientConfig |
getDefaultClientConfig()
Get the default client config.
|
jakarta.ws.rs.client.Client |
getHttpClient() |
JSON |
getJSON()
Gets the JSON instance to do JSON serialization and deserialization.
|
Logger |
getLogger()
Get the ApiClient logger
|
DateTimeFormatter |
getOffsetDateTimeFormatter()
Get the date format used to parse/format
OffsetDateTime parameters. |
int |
getReadTimeout()
read timeout (in milliseconds).
|
RetryConfig |
getRetry()
Return the retryConfig object
|
Integer |
getServerIndex() |
List<ServerConfiguration> |
getServers() |
Map<String,String> |
getServerVariables() |
String |
getTempFolderPath()
The path of temporary folder used to store downloaded files from endpoints with file response.
|
Set<String> |
getUnstableOperations()
Get list of all unstable operations
|
String |
getUserAgent()
Get the User-Agent header's value.
|
<T> ApiResponse<T> |
invokeAPI(String method,
jakarta.ws.rs.client.Invocation.Builder invocationBuilder,
Map<String,String> headerParams,
String[] contentTypes,
Object body,
Map<String,Object> formParams,
Boolean isBodyNullable,
jakarta.ws.rs.core.GenericType<T> returnType)
Invoke API by sending HTTP request with the given options.
|
<T> CompletableFuture<ApiResponse<T>> |
invokeAPIAsync(String method,
jakarta.ws.rs.client.Invocation.Builder invocationBuilder,
Map<String,String> headerParams,
String[] contentTypes,
Object body,
Map<String,Object> formParams,
Boolean isBodyNullable,
jakarta.ws.rs.core.GenericType<T> returnType)
Invoke API by sending HTTP request with the given options, asynchronously.
|
boolean |
isCompress()
Check that whether compress is enabled for this API client.
|
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.
|
boolean |
isUnstableOperation(String operation)
Determine whether an operation is an unstable operation.
|
boolean |
isUnstableOperationEnabled(String operation)
Determine whether an unstable operation is enabled.
|
List<Pair> |
parameterToPairs(String collectionFormat,
String name,
Object value) |
String |
parameterToString(Object param)
Format the given parameter object into string.
|
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.
|
jakarta.ws.rs.client.Entity<?> |
serialize(Object obj,
Map<String,Object> formParams,
String contentType,
String contentEncoding,
boolean isBodyNullable)
Serialize the given Java object into string entity 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 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(org.glassfish.jersey.client.ClientConfig clientConfig)
Set the client config.
|
ApiClient |
setCompress(boolean compress)
Enable/disable compress for this API client.
|
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.
|
static void |
setDefaultApiClient(ApiClient apiClient)
Set the default API client, which would be used when creating API instances without providing
an API client.
|
ApiClient |
setHttpClient(jakarta.ws.rs.client.Client httpClient) |
ApiClient |
setOauthAuthorizationCodeFlow(String code)
Helper method to set the authorization code flow for the first OAuth2 authentication.
|
ApiClient |
setOauthCredentials(String clientId,
String clientSecret)
Helper method to set the credentials for the first OAuth2 authentication.
|
ApiClient |
setOauthPasswordFlow(String username,
String password)
Helper method to set the password flow for the first OAuth2 authentication.
|
ApiClient |
setOauthScope(String scope)
Helper method to set the scopes for the first OAuth2 authentication.
|
void |
setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter)
Set the date format used to parse/format
OffsetDateTime parameters. |
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).
|
void |
setRetry(RetryConfig retry)
Add custom retry object in the client
|
ApiClient |
setServerIndex(Integer serverIndex) |
ApiClient |
setServers(List<ServerConfiguration> servers) |
ApiClient |
setServerVariables(Map<String,String> serverVariables) |
ApiClient |
setTempFolderPath(String tempFolderPath)
Set temp folder path
|
boolean |
setUnstableOperationEnabled(String operation,
boolean enabled)
Mark an unstable operation as enabled/disabled.
|
ApiClient |
setUserAgent()
Set the default User-Agent header's value with telemetry information (by adding to the default
header map).
|
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,
URI uri)
Update query and header parameters based on authentication settings.
|
protected String basePath
protected String userAgent
protected List<ServerConfiguration> servers
protected Integer serverIndex
protected Map<String,List<ServerConfiguration>> operationServers
protected boolean debugging
protected RetryConfig retry
protected boolean compress
protected org.glassfish.jersey.client.ClientConfig clientConfig
protected int connectionTimeout
protected jakarta.ws.rs.client.Client httpClient
protected JSON json
protected String tempFolderPath
protected Map<String,Authentication> authentications
protected DateFormat dateFormat
protected static final Logger logger
public ApiClient()
public ApiClient(Map<String,Authentication> authMap)
authMap - A hash map containing authentication parameters.public static ApiClient getDefaultApiClient()
public static void setDefaultApiClient(ApiClient apiClient)
apiClient - API clientpublic DateTimeFormatter getOffsetDateTimeFormatter()
OffsetDateTime parameters.public void setRetry(RetryConfig retry)
retry - retry objectpublic RetryConfig getRetry()
public void enableRetry(boolean enableRetry)
enableRetry - bool, enable retry or notpublic void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter)
OffsetDateTime parameters.offsetDateTimeFormatter - DateTimeFormatterpublic String formatOffsetDateTime(OffsetDateTime offsetDateTime)
OffsetDateTime object into string.offsetDateTime - OffsetDateTimeOffsetDateTime in string formatpublic JSON getJSON()
public jakarta.ws.rs.client.Client getHttpClient()
public ApiClient setHttpClient(jakarta.ws.rs.client.Client httpClient)
public String getBasePath()
public ApiClient setBasePath(String basePath)
basePath - The base URL to the target host.public List<ServerConfiguration> getServers()
public ApiClient setServers(List<ServerConfiguration> servers)
public Integer getServerIndex()
public Map<String,Authentication> getAuthentications()
public Authentication getAuthentication(String authName)
authName - The authentication namepublic ApiClient setUsername(String username)
username - Usernamepublic ApiClient setPassword(String password)
password - Passwordpublic ApiClient setApiKey(String apiKey)
apiKey - API keypublic ApiClient configureApiKeys(Map<String,String> secrets)
secrets - Hash map from authentication name to its secret.public ApiClient setApiKeyPrefix(String apiKeyPrefix)
apiKeyPrefix - API key prefixpublic ApiClient setBearerToken(String bearerToken)
bearerToken - Bearer tokenpublic ApiClient setAccessToken(String accessToken)
accessToken - Access tokenpublic ApiClient setOauthCredentials(String clientId, String clientSecret)
clientId - the client IDclientSecret - the client secretpublic ApiClient setOauthPasswordFlow(String username, String password)
username - the user namepassword - the user passwordpublic ApiClient setOauthAuthorizationCodeFlow(String code)
code - the authorization codepublic ApiClient setOauthScope(String scope)
scope - the oauth scopepublic ApiClient setUserAgent(String userAgent)
userAgent - Http user agentpublic String getUserAgent()
public ApiClient setUserAgent()
public 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 org.glassfish.jersey.client.ClientConfig getClientConfig()
public ApiClient setClientConfig(org.glassfish.jersey.client.ClientConfig clientConfig)
clientConfig - Set the client configpublic boolean isDebugging()
public ApiClient setDebugging(boolean debugging)
debugging - To enable (true) or disable (false) debuggingpublic boolean isCompress()
public ApiClient setCompress(boolean compress)
compress - To enable (true) or disable (false) compresspublic String getTempFolderPath()
null, i.e. using the system's default temporary folder.public ApiClient setTempFolderPath(String tempFolderPath)
tempFolderPath - Temp folder pathpublic int getConnectTimeout()
public ApiClient setConnectTimeout(int connectionTimeout)
Integer.MAX_VALUE.connectionTimeout - Connection timeout in millisecondspublic int getReadTimeout()
public ApiClient setReadTimeout(int readTimeout)
Integer.MAX_VALUE.readTimeout - Read timeout in millisecondspublic DateFormat getDateFormat()
public ApiClient setDateFormat(DateFormat dateFormat)
dateFormat - Date formatpublic Set<String> getUnstableOperations()
public boolean setUnstableOperationEnabled(String operation, boolean enabled)
operation - operation Id - this is the name of the method on the API class, e.g.
"createFoo"enabled - whether to mark the operation as enabled (true) or disabled (false)public boolean isUnstableOperation(String operation)
operation - operation Id - this is the name of the method on the API class, e.g.
"createFoo"public boolean isUnstableOperationEnabled(String operation)
operation - operation Id - this is the name of the method on the API class, e.g.
"createFoo"public Logger getLogger()
public 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 jakarta.ws.rs.client.Entity<?> serialize(Object obj, Map<String,Object> formParams, String contentType, String contentEncoding, boolean isBodyNullable)
obj - ObjectformParams - Form parameterscontentType - Content type headercontentEncoding - Content encoding headerisBodyNullable - Whether the body can be null or notpublic <T> T deserialize(jakarta.ws.rs.core.Response response,
jakarta.ws.rs.core.GenericType<T> returnType)
T - Typeresponse - ResponsereturnType - Return typepublic jakarta.ws.rs.client.Invocation.Builder createBuilder(String operation, String path, List<Pair> queryParams, Map<String,String> headerParams, Map<String,String> cookieParams, String[] accepts, String[] authNames) throws ApiException
operation - The qualified name of the operationpath - The sub-path of the HTTP URLqueryParams - The query parametersheaderParams - The header parameterscookieParams - The cookie parametersaccepts - The list of possible request's Accept headerauthNames - The authentications to applyApiException - API exceptionpublic <T> ApiResponse<T> invokeAPI(String method, jakarta.ws.rs.client.Invocation.Builder invocationBuilder, Map<String,String> headerParams, String[] contentTypes, Object body, Map<String,Object> formParams, Boolean isBodyNullable, jakarta.ws.rs.core.GenericType<T> returnType) throws ApiException
T - TypeinvocationBuilder - HTTP requests buildermethod - The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"body - The request body objectheaderParams - The header parametersformParams - The form parameterscontentTypes - The list of request Content-Type headersreturnType - The return type into which to deserialize the responseisBodyNullable - True if the body is nullableApiException - API exceptionpublic <T> CompletableFuture<ApiResponse<T>> invokeAPIAsync(String method, jakarta.ws.rs.client.Invocation.Builder invocationBuilder, Map<String,String> headerParams, String[] contentTypes, Object body, Map<String,Object> formParams, Boolean isBodyNullable, jakarta.ws.rs.core.GenericType<T> returnType)
T - TypeinvocationBuilder - HTTP requests buildermethod - The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"body - The request body objectheaderParams - The header parametersformParams - The form parameterscontentTypes - The list of request Content-Type headersreturnType - The return type into which to deserialize the responseisBodyNullable - True if the body is nullableprotected jakarta.ws.rs.client.Client buildHttpClient()
public org.glassfish.jersey.client.ClientConfig getDefaultClientConfig()
protected void customizeClientBuilder(jakarta.ws.rs.client.ClientBuilder clientBuilder)
This method can be overridden to customize the API client. For example, this can be used to: 1. Set the hostname verifier to be used by the client to verify the endpoint's hostname against its identification information. 2. Set the client-side key store. 3. Set the SSL context that will be used when creating secured transport connections to server endpoints from web targets created by the client instance that is using this SSL context. 4. Set the client-side trust store.
To completely disable certificate validation (at your own risk), you can override this method and invoke disableCertificateValidation(clientBuilder).
clientBuilder: - HTTP client builderprotected void disableCertificateValidation(jakarta.ws.rs.client.ClientBuilder clientBuilder)
throws KeyManagementException,
NoSuchAlgorithmException
Please note that trusting all certificates is extremely risky. This may be useful in a development environment with self-signed certificates.
clientBuilder: - HTTP client builderKeyManagementException - When the SSL context can't be initializedNoSuchAlgorithmException - If the environment doesn't support the required algorithmprotected Map<String,List<String>> buildResponseHeaders(jakarta.ws.rs.core.Response response)
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String,String> headerParams, Map<String,String> cookieParams, URI uri) throws ApiException
authNames - The authentications to applyqueryParams - List of query parametersheaderParams - Map of header parameterscookieParams - Map of cookie parametersuri - HTTP URIApiException - If one of the authentication schemes failed to be appliedCopyright © 2024. All rights reserved.