Interface Client.HttpRequest

Enclosing interface:
Client

public static interface Client.HttpRequest
Instances of Client.HttpRequest are used to make direct HTTP requests to ksqlDB server's REST API.
  • Method Details

    • payload

      Client.HttpRequest payload(String key, Object value)
      Add a key and value in the payload map. If an entry already exists with this key, it is replaced.
      Parameters:
      key - a String key
      value - the value
      Returns:
      this instance of Client.HttpRequest
    • payload

      Client.HttpRequest payload(Map<String,Object> payload)
      Add all entries from the input map into the payload map. If any of the entries already exist, it is replaced with the new one.
      Parameters:
      payload - a non-null input map
      Returns:
      this instance of Client.HttpRequest
    • payload

      Map<String,Object> payload()
      Returns:
      a non-null payload map constructed so far for this request.
    • property

      Client.HttpRequest property(String key, Object value)
      Set a property. If an entry already exists with this key, it is replaced.
      Parameters:
      key - a String key
      value - the value
      Returns:
      this instance of Client.HttpRequest
    • properties

      Map<String,Object> properties()
      Returns:
      a non-null properties map constructed so far for this request.
    • properties

      Client.HttpRequest properties(Map<String,Object> properties)
      Add all properties from the given map. If an entry already exists with this key, it is replaced.
      Parameters:
      properties - a non-null input map
      Returns:
      this instance of Client.HttpRequest
    • propertiesKey

      Client.HttpRequest propertiesKey(String propertiesKey)
      Set the key to be used for properties map in the request. If not set, all properties are keyed to a "properties" when sent in the request body. This is useful as certain endpoints (for example, the /ksql endpoint) in ksqlDB's API look for properties in a top-level "streamProperties" object, whereas others look for this in this top-level "properties" object.
    • propertiesKey

      String propertiesKey()
      Returns:
      the key the properties are associated with in the final request payload.
    • path

      String path()
      Returns:
      the URL path for this request.
    • method

      String method()
      Returns:
      the HTTP method this request will execute.
    • send

      Complete the HTTP request. This method combines the payload key-value pairs, properties and session variables (set with Client.define(String, Object) above) into a json payload that is sent to the server in the request body. For example, invoking the API as follows:
         client.define("s1", "v1");
         client.request("POST", "/some/path")
           .payload("k1", "v1").
           .payload(singletonMap("k2", "v2"))
           .property("p1", "v1")
           .properties(singletonMap("p2", "v2"))
           .propertiesKey("streamProperties")
           .send().get();
       

      will create the following request body:

         {
           "k1": "v1",
           "streamProperties": {
             "p1": "v1",
             "p2": "v2"
           }, sessionVariables: {
             "s1": "v1"
           }
         }
       
      Returns:
      a future that completes once the server response is received and parsed into an Client.HttpResponse or with an exception if the request failed to complete.