Package io.dialob.api.client.okhttp
Class ApiClient
java.lang.Object
io.dialob.api.client.okhttp.ApiClient
@Generated(value="io.swagger.codegen.v3.generators.java.JavaClientCodegen",
date="2023-09-29T12:45:39.934004759Z[Etc/UTC]")
public class ApiClient
extends Object
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.fasterxml.jackson.databind.ObjectMapper -
Constructor Summary
ConstructorsConstructorDescriptionBasic constructor for single auth nameHelper constructor for single api keyHelper constructor for single basic auth or password oauth2Helper constructor for single password oauth2 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAuthorization(String authName, feign.RequestInterceptor authorization) Adds an authorization to be used by the client<T extends ApiClient.Api>
TbuildClient(Class<T> clientClass) Creates a feign client for given API interface.voidconfigureAuthorizationFlow(String clientId, String clientSecret, String redirectURI) Helper method to configure the oauth accessCode/implicit flow parametersfeign.RequestInterceptorgetAuthorization(String authName) Gets request interceptor based on authentication nameorg.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilderHelper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one)feign.Feign.Buildercom.fasterxml.jackson.databind.ObjectMapperorg.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilderHelper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)voidregisterAccessTokenListener(OAuth.AccessTokenListener accessTokenListener) Configures a listener which is notified when a new access token is received.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.voidsetAccessToken(String accessToken, Long expiresIn) Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one)voidsetApiAuthorizations(Map<String, feign.RequestInterceptor> apiAuthorizations) voidHelper method to configure the first api key foundsetBasePath(String basePath) voidsetCredentials(String username, String password) Helper method to configure the username/password for basic auth or password OAuthsetFeignBuilder(feign.Feign.Builder feignBuilder)
-
Field Details
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
ApiClient
public ApiClient() -
ApiClient
-
ApiClient
Basic constructor for single auth name- Parameters:
authName-
-
ApiClient
Helper constructor for single api key- Parameters:
authName-apiKey-
-
ApiClient
Helper constructor for single basic auth or password oauth2- Parameters:
authName-username-password-
-
ApiClient
Helper constructor for single password oauth2- Parameters:
authName-clientId-secret-username-password-
-
-
Method Details
-
getBasePath
-
setBasePath
-
getApiAuthorizations
-
setApiAuthorizations
-
getFeignBuilder
public feign.Feign.Builder getFeignBuilder() -
setFeignBuilder
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
buildClient
Creates a feign client for given API interface. Usage: ApiClient apiClient = new ApiClient(); apiClient.setBasePath("http://localhost:8080"); XYZApi api = apiClient.buildClient(XYZApi.class); XYZResponse response = api.someMethod(...);- Type Parameters:
T- Type- Parameters:
clientClass- Client class- Returns:
- The Client
-
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.
-
setApiKey
Helper method to configure the first api key found- Parameters:
apiKey- API key
-
setCredentials
Helper method to configure the username/password for basic auth or password OAuth- Parameters:
username- Usernamepassword- Password
-
getTokenEndPoint
public org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder getTokenEndPoint()Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)- Returns:
- Token request builder
-
getAuthorizationEndPoint
public org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder getAuthorizationEndPoint()Helper method to configure authorization endpoint of the first oauth found in the apiAuthorizations (there should be only one)- Returns:
- Authentication request builder
-
setAccessToken
Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there should be only one)- Parameters:
accessToken- Access TokenexpiresIn- Validity period in seconds
-
configureAuthorizationFlow
Helper method to configure the oauth accessCode/implicit flow parameters- Parameters:
clientId- Client IDclientSecret- Client secretredirectURI- Redirect URI
-
registerAccessTokenListener
Configures a listener which is notified when a new access token is received.- Parameters:
accessTokenListener- Acesss token listener
-
getAuthorization
Gets request interceptor based on authentication name- Parameters:
authName- Authentiation name- Returns:
- Request Interceptor
-
addAuthorization
Adds an authorization to be used by the client- Parameters:
authName- Authentication nameauthorization- Request interceptor
-