Class CdpClient

    • Constructor Detail

      • 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 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 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
      • 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.