Class Connection


  • public class Connection
    extends Object
    The HTTP Connection adapter for FaunaDB drivers.

    Relies on HttpClient for the underlying implementation.

    • Method Detail

      • newSessionConnection

        public Connection newSessionConnection​(String authToken)
        Creates a new Connection sharing its underneath I/O resources. Queries submitted to a session connection will be authenticated with the token provided.
        Parameters:
        authToken - the token or key to be used to authenticate requests to the new Connection
        Returns:
        a new Connection
      • getLastTxnTime

        public long getLastTxnTime()
        Get the freshest timestamp reported to this client.
      • syncLastTxnTime

        public void syncLastTxnTime​(long newTxnTime)
        Sync the freshest timestamp seen by this client. This has no effect if more stale than the currently stored timestamp. WARNING: This should be used only when coordinating timestamps across multiple clients. Moving the timestamp arbitrarily forward into the future will cause transactions to stall.
      • get

        public CompletableFuture<HttpResponse<String>> get​(String path,
                                                           Map<String,​List<String>> params,
                                                           Optional<Duration> queryTimeout)
        Issues a GET request with the provided request parameters.
        Parameters:
        path - the relative path of the resource.
        params - a map containing the request parameters.
        queryTimeout - the query timeout for the current request.
        Returns:
        a CompletableFuture containing the HTTP response.
      • get

        public CompletableFuture<HttpResponse<String>> get​(String path,
                                                           Map<String,​List<String>> params,
                                                           RequestParameters requestParameters)
        Issues a GET request with the provided request parameters.
        Parameters:
        path - the relative path of the resource.
        params - a map containing the request parameters.
        requestParameters - Additional metadata to be passed along with the request.
        Returns:
        a CompletableFuture containing the HTTP response.
      • post

        public CompletableFuture<HttpResponse<String>> post​(String path,
                                                            com.fasterxml.jackson.databind.JsonNode body,
                                                            Optional<Duration> queryTimeout)
        Issues a POST request with the provided JSON request body.
        Parameters:
        path - the relative path of the resource.
        body - the JSON tree that will be serialized into the request body.
        queryTimeout - the query timeout for the current request.
        Returns:
        a CompletableFuture containing the HTTP response.
      • post

        public CompletableFuture<HttpResponse<String>> post​(String path,
                                                            com.fasterxml.jackson.databind.JsonNode body,
                                                            RequestParameters requestParameters)
        Issues a POST request with the provided JSON request body.
        Parameters:
        path - the relative path of the resource.
        body - the JSON tree that will be serialized into the request body.
        requestParameters - Additional metadata to be passed along with the request.
        Returns:
        a CompletableFuture containing the HTTP response.
      • put

        public CompletableFuture<HttpResponse<String>> put​(String path,
                                                           com.fasterxml.jackson.databind.JsonNode body,
                                                           Optional<Duration> queryTimeout)
        Issues a PUT request with the provided JSON request body.
        Parameters:
        path - the relative path of the resource.
        body - the JSON tree that will be serialized into the request body.
        queryTimeout - the query timeout for the current request.
        Returns:
        a CompletableFuture containing the HTTP response.
      • put

        public CompletableFuture<HttpResponse<String>> put​(String path,
                                                           com.fasterxml.jackson.databind.JsonNode body,
                                                           RequestParameters requestParameters)
        Issues a PUT request with the provided JSON request body.
        Parameters:
        path - the relative path of the resource.
        body - the JSON tree that will be serialized into the request body.
        requestParameters - Additional metadata to be passed along with the request.
        Returns:
        a CompletableFuture containing the HTTP response.
      • patch

        public CompletableFuture<HttpResponse<String>> patch​(String path,
                                                             com.fasterxml.jackson.databind.JsonNode body,
                                                             Optional<Duration> queryTimeout)
        Issues a PATCH request with the provided JSON request body.
        Parameters:
        path - the relative path of the resource.
        body - the JSON tree that will be serialized into the request body.
        queryTimeout - the query timeout for the current request.
        Returns:
        a CompletableFuture containing the HTTP response.
      • patch

        public CompletableFuture<HttpResponse<String>> patch​(String path,
                                                             com.fasterxml.jackson.databind.JsonNode body,
                                                             RequestParameters requestParameters)
        Issues a PATCH request with the provided JSON request body.
        Parameters:
        path - the relative path of the resource.
        body - the JSON tree that will be serialized into the request body.
        requestParameters - Additional metadata to be passed along with the request.
        Returns:
        a CompletableFuture containing the HTTP response.