Class RequestBuilder


  • public final class RequestBuilder
    extends java.lang.Object
    The RequestBuilder class is responsible for building HTTP requests for communicating with Fauna.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  RequestBuilder.FieldNames
      Field names for HTTP requests.
    • Constructor Summary

      Constructors 
      Constructor Description
      RequestBuilder​(java.net.http.HttpRequest.Builder builder, java.time.Duration clientTimeoutBuffer, java.util.logging.Logger logger)
      Constructor for creating a RequestBuilder with an existing HttpRequest.Builder.
      RequestBuilder​(java.net.URI uri, java.lang.String token, int maxContentionRetries, java.time.Duration clientTimeoutBuffer, java.util.logging.Logger logger)
      Constructor for creating a RequestBuilder with the specified Fauna configuration.
    • Constructor Detail

      • RequestBuilder

        public RequestBuilder​(java.net.URI uri,
                              java.lang.String token,
                              int maxContentionRetries,
                              java.time.Duration clientTimeoutBuffer,
                              java.util.logging.Logger logger)
        Constructor for creating a RequestBuilder with the specified Fauna configuration.
        Parameters:
        uri - The URI for the Fauna endpoint.
        token - The secret key used for authorization.
        maxContentionRetries - The maximum retries for contention errors.
        clientTimeoutBuffer - The buffer for the client timeout.
        logger - The logger to log HTTP request details.
      • RequestBuilder

        public RequestBuilder​(java.net.http.HttpRequest.Builder builder,
                              java.time.Duration clientTimeoutBuffer,
                              java.util.logging.Logger logger)
        Constructor for creating a RequestBuilder with an existing HttpRequest.Builder.
        Parameters:
        builder - The HttpRequest.Builder to use.
        clientTimeoutBuffer - The buffer for the client timeout.
        logger - The logger to log HTTP request details.
    • Method Detail

      • queryRequestBuilder

        public static RequestBuilder queryRequestBuilder​(FaunaConfig config,
                                                         java.util.logging.Logger logger)
        Creates a new RequestBuilder for Fauna queries.
        Parameters:
        config - The FaunaConfig containing endpoint and secret.
        logger - The logger for logging HTTP request details.
        Returns:
        A new instance of RequestBuilder.
      • streamRequestBuilder

        public static RequestBuilder streamRequestBuilder​(FaunaConfig config,
                                                          java.util.logging.Logger logger)
        Creates a new RequestBuilder for Fauna streams.
        Parameters:
        config - The FaunaConfig containing endpoint and secret.
        logger - The logger for logging HTTP request details.
        Returns:
        A new instance of RequestBuilder.
      • feedRequestBuilder

        public static RequestBuilder feedRequestBuilder​(FaunaConfig config,
                                                        java.util.logging.Logger logger)
        Creates a new RequestBuilder for Fauna feed requests.
        Parameters:
        config - The FaunaConfig containing endpoint and secret.
        logger - The logger for logging HTTP request details.
        Returns:
        A new instance of RequestBuilder.
      • scopedRequestBuilder

        public RequestBuilder scopedRequestBuilder​(java.lang.String token)
        Creates a scoped request builder with the given token.
        Parameters:
        token - The token to be used for the request's authorization header.
        Returns:
        A new instance of RequestBuilder with the scoped token.
      • buildRequest

        public java.net.http.HttpRequest buildRequest​(Query fql,
                                                      QueryOptions options,
                                                      CodecProvider provider,
                                                      java.lang.Long lastTxnTs)
        Builds and returns an HTTP request for a given Fauna query string (FQL).
        Parameters:
        fql - The Fauna query string.
        options - The query options.
        provider - The codec provider to encode the query.
        lastTxnTs - The last transaction timestamp (optional).
        Returns:
        An HttpRequest object configured for the Fauna query.
      • buildStreamRequest

        public java.net.http.HttpRequest buildStreamRequest​(EventSource eventSource,
                                                            StreamOptions streamOptions)
        Builds and returns an HTTP request for a Fauna stream.
        Parameters:
        eventSource - The event source for the stream.
        streamOptions - The stream options.
        Returns:
        An HttpRequest object configured for the Fauna stream.
      • buildFeedRequest

        public java.net.http.HttpRequest buildFeedRequest​(EventSource eventSource,
                                                          FeedOptions options)
        Builds and returns an HTTP request for a Fauna feed.
        Parameters:
        eventSource - The event source for the feed.
        options - The feed options.
        Returns:
        An HttpRequest object configured for the Fauna feed.