Class CdpClient

java.lang.Object
com.cloudera.cdp.client.CdpClient
Direct Known Subclasses:
AuditClient, CloudprivatelinksClient, ComputeClient, ConsumptionClient, DatacatalogClient, DatahubClient, DatalakeClient, DeClient, DfClient, DfworkloadClient, DrscpClient, DwClient, EnvironmentsClient, IamClient, ImagecatalogClient, MlClient, OpdbClient, ReplicationmanagerClient

public abstract class CdpClient extends Object
Abstract base class for all API client classes. This should not be referenced directly. All subclasses of this class are intended to be generated code and are safe to share across threads. Each CdpClient instance has a dedicated HTTP connection pool used to back its requests. The properties of that pool are configured per-CdpClient using the CdpClientConfiguration passed at creation time. This class is not thread-safe.
  • Field Details

  • Constructor Details

    • CdpClient

      protected CdpClient(CdpCredentials credentials, String endpoint, CdpClientConfiguration config)
      Constructor.
      Parameters:
      credentials - the CDP credentials
      endpoint - the CDP service endpoint
      config - the client configuration
    • CdpClient

      protected CdpClient(CdpRequestContext<?> context)
      Constructor.
      Parameters:
      context - the CDP client context
  • Method Details

    • getServiceName

      protected abstract String getServiceName()
      Gets the service name.
      Returns:
      the service name
    • getRequestContentType

      protected String getRequestContentType()
      Gets the request Content-Type, used by 'Conent-Type' request header.
      Returns:
      the request Content-Type
    • getResponseContentType

      protected String getResponseContentType()
      Gets the expected response Content-Type, used by 'Accept' request header.
      Returns:
      the response Content-Type
    • invokeAPI

      protected <T extends CdpResponse> T invokeAPI(String operationName, String path, Object body, javax.ws.rs.core.GenericType<T> returnType, @Nullable List<Class<? extends CdpClientMiddleware>> extensions)
      Invoke API by sending HTTP request with the given options.
      Type Parameters:
      T - The type of the response
      Parameters:
      operationName - The operation name
      path - The subpath of the HTTP URL
      body - The request body object
      returnType - The return type as a GenericType
      extensions - The extensions for the operation
      Returns:
      The response body object
    • invokeAPI

      protected RestResponse invokeAPI(String operationName, String method, String path, List<Pair> queries, Map<String,String> headers, @Nullable Object body, @Nullable List<Class<? extends CdpClientMiddleware>> extensions)
      Invoke API by sending HTTP request with the given options.
      Parameters:
      operationName - The operation name
      method - The request method, one of "GET", "POST", "PUT", "PATCH" and "DELETE"
      path - The sub-path of the HTTP URL
      queries - The query parameters
      headers - The header parameters
      body - The request body object - if it is not binary, otherwise null
      extensions - The extensions for the operation
      Returns:
      The response body object
    • invokeAPI

      protected <T extends BaseResponse> T invokeAPI(String operationName, String method, String path, List<Pair> queries, Map<String,String> headers, @Nullable Object body, javax.ws.rs.core.GenericType<T> returnType, @Nullable List<Class<? extends CdpClientMiddleware>> extensions)
    • invokeAPI

      protected <T extends BaseResponse> void invokeAPI(CdpRequestContext<T> context, @Nullable List<Class<? extends CdpClientMiddleware>> extensions)
    • parameterToString

      protected String parameterToString(Object param)
      Format the given parameter object into string.
      Parameters:
      param - Object
      Returns:
      Object in string format
    • parameterToPair

      protected Pair parameterToPair(String name, Object value)
      Formats the specified parameter to a Pair object.
      Parameters:
      name - The name of the parameter.
      value - The value of the parameter.
      Returns:
      A Pair object.
    • parameterToPairs

      protected List<Pair> parameterToPairs(String collectionFormat, String name, Collection value)
      Formats the specified parameters to a list of Pair objects.
      Parameters:
      collectionFormat - The collection format of the parameter.
      name - The name of the parameter.
      value - The value of the parameter.
      Returns:
      A list of Pair objects.
    • shutdown

      public void shutdown()
      Releases resources held by this client object. Once a client has been shutdown, it should not be used to make any more requests. This is an optional method, and callers are not expected to call it, but can if they want to explicitly release any open resources.