Class ApiClient
java.lang.Object
fr.gouv.vitam.antivirus.client.invoker.JavaTimeFormatter
fr.gouv.vitam.antivirus.client.invoker.ApiClient
- Direct Known Subclasses:
VitamApiClient
@Generated(value="org.openapitools.codegen.languages.JavaClientCodegen",
date="2025-10-29T21:12:11.613695899+01:00[Europe/Paris]",
comments="Generator version: 7.4.0")
public class ApiClient
extends JavaTimeFormatter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDefaultHeader(String key, String value) Add a default header.<T> Tdeserialize(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> returnType) Deserialize response body to Java object according to the Content-Type.downloadFileFromResponse(jakarta.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).Get the date format used to parse/format date parameters.jakarta.ws.rs.client.ClientgetJSON()Gets the JSON instance to do JSON serialization and deserialization.Gets the response headers of the previous requestintGets the status code of the previous requestThe path of temporary folder used to store downloaded files from endpoints with file response.<T> TinvokeAPI(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, jakarta.ws.rs.core.GenericType<T> returnType) Invoke API by sending HTTP request with the given options.booleanCheck that whether debugging is enabled for this API client.booleanisJsonMime(String mime) Check if the given MIME is a JSON MIME.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(jakarta.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.jakarta.ws.rs.client.Entity<?> Serialize the given Java object into string entity according the given Content-Type (only JSON is supported for now).voidHelper method to set API key value for the first API key authentication.voidsetApiKeyPrefix(String apiKeyPrefix) Helper method to set API key prefix for the first API key authentication.setBasePath(String basePath) setDateFormat(DateFormat dateFormat) Set the date format used to parse/format date parameters.setDebugging(boolean debugging) Enable/disable debugging for this API client.setHttpClient(jakarta.ws.rs.client.Client httpClient) voidsetPassword(String password) Helper method to set password for the first HTTP basic authentication.setTempFolderPath(String tempFolderPath) setUserAgent(String userAgent) Set the User-Agent header's value (by adding to the default header map).voidsetUsername(String username) Helper method to set username for the first HTTP basic authentication.Methods inherited from class fr.gouv.vitam.antivirus.client.invoker.JavaTimeFormatter
formatOffsetDateTime, getOffsetDateTimeFormatter, parseOffsetDateTime, setOffsetDateTimeFormatter
-
Constructor Details
-
ApiClient
public ApiClient()
-
-
Method Details
-
getJSON
Gets the JSON instance to do JSON serialization and deserialization.- Returns:
- the JSON utility class
-
getHttpClient
public jakarta.ws.rs.client.Client getHttpClient() -
setHttpClient
-
getBasePath
-
setBasePath
-
getStatusCode
public int getStatusCode()Gets the status code of the previous request- Returns:
- the status code of the previous request
-
getResponseHeaders
Gets the response headers of the previous request- Returns:
- the response headers of the previous request
-
getAuthentications
Get authentications (key: authentication name, value: authentication).- Returns:
- the authentications
-
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- the username
-
setPassword
Helper method to set password for the first HTTP basic authentication.- Parameters:
password- the password
-
setApiKey
Helper method to set API key value for the first API key authentication.- Parameters:
apiKey- the API key
-
setApiKeyPrefix
Helper method to set API key prefix for the first API key authentication.- Parameters:
apiKeyPrefix- the API key prefix
-
setUserAgent
Set the User-Agent header's value (by adding to the default header map).- Parameters:
userAgent- the User-Agent header value- Returns:
- this
ApiClient
-
addDefaultHeader
Add a default header.- Parameters:
key- The header's keyvalue- The header's value- Returns:
- this
ApiClient
-
isDebugging
public boolean isDebugging()Check that whether debugging is enabled for this API client.- Returns:
trueif debugging is enabled for this API client
-
setDebugging
Enable/disable debugging for this API client.- Parameters:
debugging- To enable (true) or disable (false) debugging- Returns:
- this
ApiClient
-
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:
- the temporary folder path
- See Also:
-
setTempFolderPath
-
getDateFormat
Get the date format used to parse/format date parameters.- Returns:
- the date format used to parse/format date parameters
-
setDateFormat
Set the date format used to parse/format date parameters.- Parameters:
dateFormat- a date format used to parse/format date parameters- Returns:
- this
ApiClient
-
parseDate
Parse the given string into Date object.- Parameters:
str- a string to parse- Returns:
- a
Dateobject
-
formatDate
Format the given Date object into string.- Parameters:
date- aDateobject to format- Returns:
- the
Stringversion of theDateobject
-
parameterToString
Format the given parameter object into string.- Parameters:
param- an object to format- Returns:
- the
Stringversion of the object
-
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 (Multipurpose Internet Mail Extensions)- Returns:
- True if the given MIME is JSON, false otherwise.
-
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- aStringto escape- Returns:
- the escaped version of the
String
-
serialize
public jakarta.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- the object to serializeformParams- the form parameterscontentType- the content type- Returns:
- an
Entity - Throws:
ApiException- on failure to serialize
-
deserialize
public <T> T deserialize(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> returnType) throws ApiException Deserialize response body to Java object according to the Content-Type.- Type Parameters:
T- a Java type parameter- Parameters:
response- the response body to deserializereturnType- a Java type to deserialize into- Returns:
- a deserialized Java object
- Throws:
ApiException- on failure to deserialize
-
downloadFileFromResponse
Download file from the given response.- Parameters:
response- a response- Returns:
- a file from the given response
- 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 ApiExceptionString> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, jakarta.ws.rs.core.GenericType<T> returnType) Invoke API by sending HTTP request with the given options.- Type Parameters:
T- a Java type parameter- Parameters:
path- 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 response- Returns:
- The response body in type of string
- Throws:
ApiException- if the invocation failed
-