Class RestClient

java.lang.Object
com.mindsdb.client.RestClient

public class RestClient extends Object
Utility class for sending HTTP requests using the Unirest library. This class provides methods to simplify making HTTP requests, including POST, PATCH, GET, and DELETE methods. Each method allows for the inclusion of a request body where applicable.

Note: Ensure that the Unirest library is included in your project dependencies to use this class effectively. Proper error handling should be implemented when processing the responses from the HTTP requests.

  • Constructor Details

    • RestClient

      public RestClient(String apiKey, String baseUrl)
    • RestClient

      public RestClient(String apiKey)
  • Method Details

    • sendPostRequest

      public kong.unirest.core.HttpResponse<String> sendPostRequest(String endPoint, String body) throws Exception
      Sends an HTTP POST request to the specified endpoint with the given request body.
      Parameters:
      endPoint - The URL endpoint to which the request is sent.
      body - The body of the POST request.
      Returns:
      An HttpResponse containing the response from the server.
      Throws:
      Exception
    • sendPatchRequest

      public kong.unirest.core.HttpResponse<String> sendPatchRequest(String endPoint, String body) throws Exception
      Sends an HTTP PATCH request to the specified endpoint with the given request body.
      Parameters:
      endPoint - The URL endpoint to which the request is sent.
      body - The body of the PATCH request.
      Returns:
      An HttpResponse containing the response from the server.
      Throws:
      Exception
    • sendGetRequest

      public kong.unirest.core.HttpResponse<String> sendGetRequest(String endPoint) throws Exception
      Sends an HTTP GET request to the specified endpoint.
      Parameters:
      endPoint - The URL endpoint to which the request is sent.
      Returns:
      An HttpResponse containing the response from the server.
      Throws:
      Exception
    • sendDeleteRequest

      public kong.unirest.core.HttpResponse<String> sendDeleteRequest(String endPoint) throws Exception
      Sends an HTTP DELETE request to the specified endpoint.
      Parameters:
      endPoint - The URL endpoint to which the request is sent.
      Returns:
      An HttpResponse containing the response from the server.
      Throws:
      Exception
    • shutDown

      public void shutDown()