Class FaunaClient
- java.lang.Object
-
- com.fauna.client.FaunaClient
-
- Direct Known Subclasses:
BaseFaunaClient
,ScopedFaunaClient
public abstract class FaunaClient extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static RetryStrategy
DEFAULT_RETRY_STRATEGY
static RetryStrategy
NO_RETRY_STRATEGY
-
Constructor Summary
Constructors Constructor Description FaunaClient(java.lang.String secret)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<QuerySuccess<java.lang.Object>>
asyncQuery(Query fql)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.<E> java.util.concurrent.CompletableFuture<QuerySuccess<E>>
asyncQuery(Query fql, ParameterizedOf<E> parameterizedType)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.<E> java.util.concurrent.CompletableFuture<QuerySuccess<E>>
asyncQuery(Query fql, ParameterizedOf<E> parameterizedType, QueryOptions options)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.<T> java.util.concurrent.CompletableFuture<QuerySuccess<T>>
asyncQuery(Query fql, java.lang.Class<T> resultClass)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.<T> java.util.concurrent.CompletableFuture<QuerySuccess<T>>
asyncQuery(Query fql, java.lang.Class<T> resultClass, QueryOptions options)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.<E> java.util.concurrent.CompletableFuture<FaunaStream<E>>
asyncStream(Query fql, java.lang.Class<E> elementClass)
Start a Fauna stream based on an FQL query, and return a CompletableFuture of the resulting FaunaStream publisher.<E> java.util.concurrent.CompletableFuture<FaunaStream<E>>
asyncStream(StreamRequest streamRequest, java.lang.Class<E> elementClass)
Send a request to the Fauna stream endpoint, and return a CompletableFuture that completes with the FaunaStream publisher.protected java.lang.String
getFaunaSecret()
<E> PageIterator<E>
paginate(Query fql, java.lang.Class<E> elementClass)
Send a Fauna Query Language (FQL) query to Fauna and return a paginated result.<E> PageIterator<E>
paginate(Query fql, java.lang.Class<E> elementClass, QueryOptions options)
Send a Fauna Query Language (FQL) query to Fauna and return a paginated result.QuerySuccess<java.lang.Object>
query(Query fql)
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.<E> QuerySuccess<E>
query(Query fql, ParameterizedOf<E> parameterizedType)
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.<E> QuerySuccess<E>
query(Query fql, ParameterizedOf<E> parameterizedType, QueryOptions options)
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.<T> QuerySuccess<T>
query(Query fql, java.lang.Class<T> resultClass)
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.<T> QuerySuccess<T>
query(Query fql, java.lang.Class<T> resultClass, QueryOptions options)
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.<E> FaunaStream<E>
stream(Query fql, java.lang.Class<E> elementClass)
Start a Fauna stream based on an FQL query.<E> FaunaStream<E>
stream(StreamRequest streamRequest, java.lang.Class<E> elementClass)
Send a request to the Fauna stream endpoint to start a stream, and return a FaunaStream publisher.
-
-
-
Field Detail
-
DEFAULT_RETRY_STRATEGY
public static final RetryStrategy DEFAULT_RETRY_STRATEGY
-
NO_RETRY_STRATEGY
public static final RetryStrategy NO_RETRY_STRATEGY
-
-
Method Detail
-
getFaunaSecret
protected java.lang.String getFaunaSecret()
-
asyncQuery
public java.util.concurrent.CompletableFuture<QuerySuccess<java.lang.Object>> asyncQuery(Query fql)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.var future = client.asyncQuery(fql); ... do some other stuff ... var result = future.get().getData();
- Parameters:
fql
- The FQL query to be executed.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
asyncQuery
public <T> java.util.concurrent.CompletableFuture<QuerySuccess<T>> asyncQuery(Query fql, java.lang.Class<T> resultClass, QueryOptions options)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.CompletableFuture<QuerySuccess<Document>> future = client.asyncQuery(fql, Document.class, null); ... do some other stuff ... Document doc = future.get().getData();
- Parameters:
fql
- The FQL query to be executed.resultClass
- The expected class of the query result.options
- A (nullable) set of options to pass to the query.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
asyncQuery
public <E> java.util.concurrent.CompletableFuture<QuerySuccess<E>> asyncQuery(Query fql, ParameterizedOf<E> parameterizedType, QueryOptions options)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.CompletableFuture<QuerySuccess<List<int>>> future = client.asyncQuery(fql, Parameterized.listOf(int.class), null); ... do some other stuff ... List<int>> data = future.get().getData();
- Parameters:
fql
- The FQL query to be executed.parameterizedType
- The expected class of the query result.options
- A (nullable) set of options to pass to the query.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
asyncQuery
public <T> java.util.concurrent.CompletableFuture<QuerySuccess<T>> asyncQuery(Query fql, java.lang.Class<T> resultClass)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.CompletableFuture<QuerySuccess<Document>> future = client.asyncQuery(fql, Document.class); ... do some other stuff ... Document doc = future.get().getData();
- Parameters:
fql
- The FQL query to be executed.resultClass
- The expected class of the query result.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
asyncQuery
public <E> java.util.concurrent.CompletableFuture<QuerySuccess<E>> asyncQuery(Query fql, ParameterizedOf<E> parameterizedType)
Sends an asynchronous Fauna Query Language (FQL) query to Fauna.CompletableFuture<QuerySuccess<List<int>>> future = client.asyncQuery(fql, Parameterized.listOf(int.class)); ... do some other stuff ... List<int>> data = future.get().getData();
- Parameters:
fql
- The FQL query to be executed.parameterizedType
- The expected class of the query result.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
query
public QuerySuccess<java.lang.Object> query(Query fql) throws FaunaException
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.var result = client.query(fql); var data = result.getData();
- Parameters:
fql
- The FQL query to be executed.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
query
public <T> QuerySuccess<T> query(Query fql, java.lang.Class<T> resultClass) throws FaunaException
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.QuerySuccess<Document> result = client.query(fql, Document.class); Document doc = result.getData();
- Parameters:
fql
- The FQL query to be executed.resultClass
- The expected class of the query result.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
query
public <E> QuerySuccess<E> query(Query fql, ParameterizedOf<E> parameterizedType) throws FaunaException
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.QuerySuccess<List<int>>> result = client.query(fql, Parameterized.listOf(int.class)); List<int>> data = result.getData();
- Parameters:
fql
- The FQL query to be executed.parameterizedType
- The expected class of the query result.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
query
public <T> QuerySuccess<T> query(Query fql, java.lang.Class<T> resultClass, QueryOptions options) throws FaunaException
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.QuerySuccess
result = client.query(fql, Document.class, null); Document doc = result.getData(); - Parameters:
fql
- The FQL query to be executed.resultClass
- The expected class of the query result.options
- A (nullable) set of options to pass to the query.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
query
public <E> QuerySuccess<E> query(Query fql, ParameterizedOf<E> parameterizedType, QueryOptions options) throws FaunaException
Sends a Fauna Query Language (FQL) query to Fauna and returns the result.QuerySuccess<List<int>>> result = client.query(fql, Parameterized.listOf(int.class), null); List<int>> data = result.getData();
- Parameters:
fql
- The FQL query to be executed.parameterizedType
- The expected class of the query result.options
- A (nullable) set of options to pass to the query.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
paginate
public <E> PageIterator<E> paginate(Query fql, java.lang.Class<E> elementClass)
Send a Fauna Query Language (FQL) query to Fauna and return a paginated result.- Parameters:
fql
- The FQL query to be executed.elementClass
- The expected class of the query result.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
paginate
public <E> PageIterator<E> paginate(Query fql, java.lang.Class<E> elementClass, QueryOptions options)
Send a Fauna Query Language (FQL) query to Fauna and return a paginated result.- Parameters:
fql
- The FQL query to be executed.elementClass
- The expected class of the query result.options
- A (nullable) set of options to pass to the query.- Returns:
- QuerySuccess The successful query result.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
asyncStream
public <E> java.util.concurrent.CompletableFuture<FaunaStream<E>> asyncStream(StreamRequest streamRequest, java.lang.Class<E> elementClass)
Send a request to the Fauna stream endpoint, and return a CompletableFuture that completes with the FaunaStream publisher.- Parameters:
streamRequest
- The request object including a stream token, and optionally a cursor, or timestamp.elementClass
- The expected class <E> of the stream events.- Returns:
- CompletableFuture A CompletableFuture of FaunaStream
. - Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
stream
public <E> FaunaStream<E> stream(StreamRequest streamRequest, java.lang.Class<E> elementClass)
Send a request to the Fauna stream endpoint to start a stream, and return a FaunaStream publisher.- Parameters:
streamRequest
- The request object including a stream token, and optionally a cursor, or timestamp.elementClass
- The expected class <E> of the stream events.- Returns:
- FaunaStream A publisher, implementing Flow.Publisher<StreamEvent<E>> from the Java Flow API.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
asyncStream
public <E> java.util.concurrent.CompletableFuture<FaunaStream<E>> asyncStream(Query fql, java.lang.Class<E> elementClass)
Start a Fauna stream based on an FQL query, and return a CompletableFuture of the resulting FaunaStream publisher. This method sends two requests, one to the query endpoint to get the stream token, and then another to the stream endpoint. This method is equivalent to calling the query, then the stream methods on FaunaClient.- Parameters:
fql
- The FQL query to be executed. It must return a stream, e.g. ends in `.toStream()`.elementClass
- The expected class <E> of the stream events.- Returns:
- FaunaStream A publisher, implementing Flow.Publisher<StreamEvent<E>> from the Java Flow API.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
stream
public <E> FaunaStream<E> stream(Query fql, java.lang.Class<E> elementClass)
Start a Fauna stream based on an FQL query. This method sends two requests, one to the query endpoint to get the stream token, and then another request to the stream endpoint which return the FaunaStream publisher.Query = fql("Product.all().toStream()"); QuerySuccess<StreamTokenResponse> tokenResp = client.query(fql, StreamTokenResponse.class); FaunaStream<Product> faunaStream = client.stream(new StreamRequest(tokenResp.getData.getToken(), Product.class)
- Parameters:
fql
- The FQL query to be executed. It must return a stream, e.g. ends in `.toStream()`.elementClass
- The expected class <E> of the stream events.- Returns:
- FaunaStream A publisher, implementing Flow.Publisher<StreamEvent<E>> from the Java Flow API.
- Throws:
FaunaException
- If the query does not succeed, an exception will be thrown.
-
-