Class ApiClient
java.lang.Object
com.kryptokrauts.sophia.compiler.generated.ApiClient
@Generated(value="org.openapitools.codegen.languages.JavaClientCodegen",
date="2022-01-10T23:40:13.294772960Z[Etc/UTC]")
public class ApiClient
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description ApiClient(io.vertx.core.Vertx vertx, io.vertx.core.json.JsonObject config) -
Method Summary
Modifier and Type Method Description ApiClientaddDefaultHeader(java.lang.String key, java.lang.String value)protected <T> io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>>>buildResponseHandler(com.fasterxml.jackson.core.type.TypeReference<T> returnType, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)Build a response handler for the HttpResponse.protected io.vertx.ext.web.client.WebClientbuildWebClient(io.vertx.core.Vertx vertx, io.vertx.core.json.JsonObject config)Build the WebClient used to make HTTP requests.java.lang.StringformatDate(java.util.Date date)Format the given Date object into string.protected java.lang.StringgenerateFilename(io.vertx.core.MultiMap headers)Create a filename from the given headers.AuthenticationgetAuthentication(java.lang.String authName)Get authentication for the given name.java.util.Map<java.lang.String,Authentication>getAuthentications()Get authentications (key: authentication name, value: authentication).java.lang.StringgetBasePath()io.vertx.core.MultiMapgetDefaultHeaders()java.lang.StringgetDownloadsDir()com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()io.vertx.core.VertxgetVertx()io.vertx.ext.web.client.WebClientgetWebClient()protected <T> voidhandleFileDownload(io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer> response, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)File Download handling.<T> voidinvokeAPI(java.lang.String path, java.lang.String method, java.util.List<Pair> queryParams, java.lang.Object body, io.vertx.core.MultiMap headerParams, java.util.Map<java.lang.String,java.lang.Object> formParams, java.lang.String[] accepts, java.lang.String[] contentTypes, java.lang.String[] authNames, com.fasterxml.jackson.core.type.TypeReference<T> returnType, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> resultHandler)Invoke API by sending HTTP request with the given options.java.util.List<Pair>parameterToPairs(java.lang.String collectionFormat, java.lang.String name, java.lang.Object value)java.lang.StringparameterToString(java.lang.Object param)Format the given parameter object into string.protected java.lang.StringsanitizeFilename(java.lang.String filename)Sanitize filename by removing path.protected java.lang.StringselectHeaderAccept(java.lang.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)protected java.lang.StringselectHeaderContentType(java.lang.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.voidsendBody(io.vertx.ext.web.client.HttpRequest<io.vertx.core.buffer.Buffer> request, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>>> responseHandler, java.lang.Object body)ApiClientsetApiKey(java.lang.String apiKey)Helper method to set API key value for the first API key authentication.ApiClientsetApiKeyPrefix(java.lang.String apiKeyPrefix)Helper method to set API key prefix for the first API key authentication.ApiClientsetBasePath(java.lang.String basePath)ApiClientsetDownloadsDir(java.lang.String downloadsDir)ApiClientsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)ApiClientsetPassword(java.lang.String password)Helper method to set password for the first HTTP basic authentication.ApiClientsetUsername(java.lang.String username)Helper method to set username for the first HTTP basic authentication.protected voidupdateParamsForAuth(java.lang.String[] authNames, java.util.List<Pair> queryParams, io.vertx.core.MultiMap headerParams)Update query and header parameters based on authentication settings.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ApiClient
public ApiClient(io.vertx.core.Vertx vertx, io.vertx.core.json.JsonObject config)
-
-
Method Details
-
getVertx
public io.vertx.core.Vertx getVertx() -
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
setObjectMapper
-
getWebClient
public io.vertx.ext.web.client.WebClient getWebClient() -
getBasePath
public java.lang.String getBasePath() -
setBasePath
-
getDownloadsDir
public java.lang.String getDownloadsDir() -
setDownloadsDir
-
getDefaultHeaders
public io.vertx.core.MultiMap getDefaultHeaders() -
addDefaultHeader
-
getAuthentications
Get authentications (key: authentication name, value: authentication).- Returns:
- Map of authentication object
-
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- Username
-
setPassword
Helper method to set password for the first HTTP basic authentication.- Parameters:
password- Password
-
setApiKey
Helper method to set API key value for the first API key authentication.- Parameters:
apiKey- API key
-
setApiKeyPrefix
Helper method to set API key prefix for the first API key authentication.- Parameters:
apiKeyPrefix- API key prefix
-
formatDate
public java.lang.String formatDate(java.util.Date date)Format the given Date object into string.- Parameters:
date- Date- Returns:
- Date in string format
-
parameterToString
public java.lang.String parameterToString(java.lang.Object param)Format the given parameter object into string.- Parameters:
param- Object- Returns:
- Object in string format
-
parameterToPairs
public java.util.List<Pair> parameterToPairs(java.lang.String collectionFormat, java.lang.String name, java.lang.Object value) -
selectHeaderAccept
protected java.lang.String selectHeaderAccept(java.lang.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)- 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
protected java.lang.String selectHeaderContentType(java.lang.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.- 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.
-
sendBody
public void sendBody(io.vertx.ext.web.client.HttpRequest<io.vertx.core.buffer.Buffer> request, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>>> responseHandler, java.lang.Object body) -
invokeAPI
public <T> void invokeAPI(java.lang.String path, java.lang.String method, java.util.List<Pair> queryParams, java.lang.Object body, io.vertx.core.MultiMap headerParams, java.util.Map<java.lang.String,java.lang.Object> formParams, java.lang.String[] accepts, java.lang.String[] contentTypes, java.lang.String[] authNames, com.fasterxml.jackson.core.type.TypeReference<T> returnType, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> resultHandler)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", "HEAD" and "DELETE"queryParams- The query parametersbody- The request body objectheaderParams- The header parametersformParams- The form parametersaccepts- The request's Accept headerscontentTypes- The request's Content-Type headersauthNames- The authentications to applyreturnType- The return type into which to deserialize the responseresultHandler- The asynchronous response handler
-
sanitizeFilename
protected java.lang.String sanitizeFilename(java.lang.String filename)Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif- Parameters:
filename- The filename to be sanitized- Returns:
- The sanitized filename
-
generateFilename
protected java.lang.String generateFilename(io.vertx.core.MultiMap headers)Create a filename from the given headers. When the headers have no "Content-Disposition" information, a random UUID name is generated.- Parameters:
headers- The HTTP response headers- Returns:
- The filename
-
handleFileDownload
protected <T> void handleFileDownload(io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer> response, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)File Download handling.- Parameters:
response- The HTTP responsehandler- The response handler
-
buildResponseHandler
protected <T> io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>>> buildResponseHandler(com.fasterxml.jackson.core.type.TypeReference<T> returnType, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)Build a response handler for the HttpResponse.- Parameters:
returnType- The return typehandler- The response handler- Returns:
- The HTTP response handler
-
buildWebClient
protected io.vertx.ext.web.client.WebClient buildWebClient(io.vertx.core.Vertx vertx, io.vertx.core.json.JsonObject config)Build the WebClient used to make HTTP requests.- Parameters:
vertx- Vertx- Returns:
- WebClient
-
updateParamsForAuth
protected void updateParamsForAuth(java.lang.String[] authNames, java.util.List<Pair> queryParams, io.vertx.core.MultiMap headerParams)Update query and header parameters based on authentication settings.- Parameters:
authNames- The authentications to apply
-