Package com.cloudera.cdp.client
Class CdpClient
- java.lang.Object
-
- com.cloudera.cdp.client.CdpClient
-
- Direct Known Subclasses:
AuditClient
,ComputeClient
,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 Summary
Fields Modifier and Type Field Description protected static List<Class<? extends CdpClientMiddleware>>
NO_EXTENSION
-
Constructor Summary
Constructors Modifier Constructor Description protected
CdpClient(CdpCredentials credentials, String endpoint, CdpClientConfiguration config)
Constructor.protected
CdpClient(CdpRequestContext<?> context)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
getRequestContentType()
Gets the request Content-Type, used by 'Conent-Type' request header.protected String
getResponseContentType()
Gets the expected response Content-Type, used by 'Accept' request header.protected abstract String
getServiceName()
Gets the service name.protected <T extends BaseResponse>
voidinvokeAPI(CdpRequestContext<T> context, List<Class<? extends CdpClientMiddleware>> extensions)
protected <T extends CdpResponse>
TinvokeAPI(String operationName, String path, Object body, javax.ws.rs.core.GenericType<T> returnType, List<Class<? extends CdpClientMiddleware>> extensions)
Invoke API by sending HTTP request with the given options.protected RestResponse
invokeAPI(String operationName, String method, String path, List<Pair> queries, Map<String,String> headers, Object body, List<Class<? extends CdpClientMiddleware>> extensions)
Invoke API by sending HTTP request with the given options.protected <T extends BaseResponse>
TinvokeAPI(String operationName, String method, String path, List<Pair> queries, Map<String,String> headers, Object body, javax.ws.rs.core.GenericType<T> returnType, List<Class<? extends CdpClientMiddleware>> extensions)
protected Pair
parameterToPair(String name, Object value)
Formats the specified parameter to aPair
object.protected List<Pair>
parameterToPairs(String collectionFormat, String name, Collection value)
Formats the specified parameters to a list ofPair
objects.protected String
parameterToString(Object param)
Format the given parameter object into string.void
shutdown()
Releases resources held by this client object.
-
-
-
Field Detail
-
NO_EXTENSION
protected static final List<Class<? extends CdpClientMiddleware>> NO_EXTENSION
-
-
Constructor Detail
-
CdpClient
protected CdpClient(CdpCredentials credentials, String endpoint, CdpClientConfiguration config)
Constructor.- Parameters:
credentials
- the CDP credentialsendpoint
- the CDP service endpointconfig
- the client configuration
-
CdpClient
protected CdpClient(CdpRequestContext<?> context)
Constructor.- Parameters:
context
- the CDP client context
-
-
Method Detail
-
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 namepath
- The subpath of the HTTP URLbody
- The request body objectreturnType
- The return type as a GenericTypeextensions
- 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 namemethod
- The request method, one of "GET", "POST", "PUT", "PATCH" and "DELETE"path
- The sub-path of the HTTP URLqueries
- The query parametersheaders
- The header parametersbody
- The request body object - if it is not binary, otherwise nullextensions
- 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 aPair
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 ofPair
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.
-
-