Class ApiClient


  • public class ApiClient
    extends Object
    • Constructor Detail

      • ApiClient

        public ApiClient()
    • 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)