Class ApiClient
- java.lang.Object
-
- de.tsystems.mms.apm.performancesignature.dynatrace.rest.json.ApiClient
-
public class ApiClient extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
API_SUFFIX
static String
REST_DF
-
Constructor Summary
Constructors Constructor Description ApiClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S> S
createService(Class<S> serviceClass)
<T> ApiResponse<T>
execute(retrofit2.Call<T> call)
Execute HTTP call and deserialize the HTTP response body into the given return type.retrofit2.Retrofit.Builder
getAdapterBuilder()
okhttp3.OkHttpClient.Builder
getOkBuilder()
ApiClient
setAdapterBuilder(retrofit2.Retrofit.Builder adapterBuilder)
ApiClient
setBasePath(String basePath)
Set base pathApiClient
setCredentials(com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials creds)
Helper method to set credentials for the HTTP basic authentication.ApiClient
setDebugging(boolean debugging)
Enable/disable debugging for this API client.ApiClient
setProxy(Proxy proxy)
ApiClient
setReadTimeout(int timeout)
ApiClient
setVerifyingSsl(boolean verifyingSsl)
Configure whether to verify certificate and hostname when making https requests.
-
-
-
Field Detail
-
API_SUFFIX
public static final String API_SUFFIX
- See Also:
- Constant Field Values
-
REST_DF
public static final String REST_DF
- See Also:
- Constant Field Values
-
-
Method Detail
-
setBasePath
public ApiClient setBasePath(String basePath)
Set base path- Parameters:
basePath
- Base path of the URL (e.g https://localhost/api/v2- Returns:
- An instance of OkHttpClient
-
setVerifyingSsl
public ApiClient setVerifyingSsl(boolean verifyingSsl)
Configure whether to verify certificate and hostname when making https requests. Default to true. NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks.- Parameters:
verifyingSsl
- True to verify TLS/SSL connection- Returns:
- ApiClient
-
setDebugging
public ApiClient setDebugging(boolean debugging)
Enable/disable debugging for this API client.- Parameters:
debugging
- To enable (true) or disable (false) debugging- Returns:
- ApiClient
-
createService
public <S> S createService(Class<S> serviceClass)
-
setCredentials
public ApiClient setCredentials(com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials creds)
Helper method to set credentials for the HTTP basic authentication.- Parameters:
creds
- UsernamePasswordCredentials
-
getAdapterBuilder
public retrofit2.Retrofit.Builder getAdapterBuilder()
-
setAdapterBuilder
public ApiClient setAdapterBuilder(retrofit2.Retrofit.Builder adapterBuilder)
-
getOkBuilder
public okhttp3.OkHttpClient.Builder getOkBuilder()
-
execute
public <T> ApiResponse<T> execute(retrofit2.Call<T> call) throws ApiException
Execute HTTP call and deserialize the HTTP response body into the given return type.- Type Parameters:
T
- The return type corresponding to (same with) returnType- Parameters:
call
- Call- Returns:
- ApiResponse object containing response status, headers and data, which is a Java object deserialized from response body and would be null when returnType is null.
- Throws:
ApiException
- If fail to execute the call
-
setReadTimeout
public ApiClient setReadTimeout(int timeout)
-
-