# Class FirestoreClient (3.43.1)

3.43.1 (latest) 3.41.0 3.38.0 3.37.0 3.36.0 3.35.1 3.33.4 3.32.2 3.31.9 3.30.11 3.28.0 3.27.2 3.26.5 3.25.1 3.24.3 3.22.0 3.21.4 3.20.0 3.17.0 3.16.3 3.15.7 3.14.4 3.13.2 3.12.1 3.11.0 3.10.0 3.9.6 3.8.2 3.7.10 3.6.0 3.5.0 3.4.2 3.3.0 3.2.0 3.1.0 3.0.21

|---|---|
| [GitHub Repository](https://github.com/googleapis/google-cloud-java/tree/main/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java) | [Product Reference](https://cloud.google.com/firestore) |

Service Description: The Cloud Firestore service.

Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL document database
that simplifies storing, syncing, and querying data for your mobile, web, and IoT apps at global
scale. Its client libraries provide live synchronization and offline support, while its security
features and integrations with Firebase and Google Cloud Platform accelerate building truly
serverless apps.

This class provides the ability to make remote calls to the backing service through method
calls that map to API methods. Sample code to get started:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       GetDocumentRequest request =
           GetDocumentRequest.newBuilder()
               .setName("name3373707")
               .setMask(DocumentMask.newBuilder().build())
               .build();
       Document response = firestoreClient.getDocument(request);
     }
     
Note: close() needs to be called on the FirestoreClient object to clean up resources such as
threads. In the example above, try-with-resources is used, which automatically calls close().

| Method | Description | Method Variants |
|---|---|---|
| GetDocument | Gets a single document. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getDocument(GetDocumentRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getDocumentCallable() |
| ListDocuments | Lists documents. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listDocuments(ListDocumentsRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listDocumentsPagedCallable() - listDocumentsCallable() |
| UpdateDocument | Updates or inserts a document. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - updateDocument(UpdateDocumentRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - updateDocument(Document document, DocumentMask updateMask) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - updateDocumentCallable() |
| DeleteDocument | Deletes a document. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - deleteDocument(DeleteDocumentRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - deleteDocument(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - deleteDocumentCallable() |
| BatchGetDocuments | Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested. | Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - batchGetDocumentsCallable() |
| BeginTransaction | Starts a new transaction. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - beginTransaction(BeginTransactionRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - beginTransaction(String database) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - beginTransactionCallable() |
| Commit | Commits a transaction, while optionally updating documents. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - commit(CommitRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - commit(String database, List\<Write\> writes) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - commitCallable() |
| Rollback | Rolls back a transaction. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - rollback(RollbackRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - rollback(String database, ByteString transaction) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - rollbackCallable() |
| RunQuery | Runs a query. | Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - runQueryCallable() |
| ExecutePipeline | Executes a pipeline query. | Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - executePipelineCallable() |
| RunAggregationQuery | Runs an aggregation query. Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side. High-Level Example: `<code><code> -- Return the number of documents in table given a filter. SELECT COUNT(&#42;) FROM ( SELECT &#42; FROM k where a = true ); </code></code>` | Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - runAggregationQueryCallable() |
| PartitionQuery | Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - partitionQuery(PartitionQueryRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - partitionQueryPagedCallable() - partitionQueryCallable() |
| Write | Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST). | Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - writeCallable() |
| Listen | Listens to changes. This method is only available via gRPC or WebChannel (not REST). | Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listenCallable() |
| ListCollectionIds | Lists all the collection IDs underneath a document. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listCollectionIds(ListCollectionIdsRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listCollectionIds(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listCollectionIdsPagedCallable() - listCollectionIdsCallable() |
| BatchWrite | Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write. If you require an atomically applied set of writes, use Commit instead. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - batchWrite(BatchWriteRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - batchWriteCallable() |
| CreateDocument | Creates a new document. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - createDocument(CreateDocumentRequest request) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - createDocumentCallable() |
[Methods]

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with
these names, this class includes a format method for each type of name, and additionally a parse
method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of FirestoreSettings to create().
For example:

To customize credentials:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     FirestoreSettings firestoreSettings =
         FirestoreSettings.newBuilder()
             .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
             .build();
     FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings);
     
To customize the endpoint:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     FirestoreSettings firestoreSettings =
         FirestoreSettings.newBuilder().setEndpoint(myEndpoint).build();
     FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings);
     
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
the wire:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     FirestoreSettings firestoreSettings = FirestoreSettings.newHttpJsonBuilder().build();
     FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings);
     
Please refer to the GitHub repository's samples for more quickstart code snippets.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> FirestoreClient

## Static Methods

### create()

    public static final FirestoreClient create()

Constructs an instance of FirestoreClient with default settings.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### create(FirestoreSettings settings)

    public static final FirestoreClient create(FirestoreSettings settings)

Constructs an instance of FirestoreClient, using the given settings. The channels are created
based on the settings passed in, or defaults for any settings that are not set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreSettings` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### create(FirestoreStub stub)

    public static final FirestoreClient create(FirestoreStub stub)

Constructs an instance of FirestoreClient, using the given stub for making calls. This is for
advanced usage - prefer using create(FirestoreSettings).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stub` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.stub.FirestoreStub` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient` |   |

## Constructors

### FirestoreClient(FirestoreSettings settings)

    protected FirestoreClient(FirestoreSettings settings)

Constructs an instance of FirestoreClient, using the given settings. This is protected so that
it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreSettings` |

### FirestoreClient(FirestoreStub stub)

    protected FirestoreClient(FirestoreStub stub)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stub` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.stub.FirestoreStub` |

## Methods

### awaitTermination(long duration, TimeUnit unit)

    public boolean awaitTermination(long duration, TimeUnit unit)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `unit` | `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |

### batchGetDocumentsCallable()

    public final ServerStreamingCallable<BatchGetDocumentsRequest,BatchGetDocumentsResponse> batchGetDocumentsCallable()

Gets multiple documents.

Documents returned by this method are not guaranteed to be returned in the same order that
they were requested.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       BatchGetDocumentsRequest request =
           BatchGetDocumentsRequest.newBuilder()
               .setDatabase("database1789464955")
               .addAllDocuments(new ArrayList<String>())
               .setMask(DocumentMask.newBuilder().build())
               .build();
       ServerStream<BatchGetDocumentsResponse> stream =
           firestoreClient.batchGetDocumentsCallable().call(request);
       for (BatchGetDocumentsResponse response : stream) {
         // Do something when a response is received.
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ServerStreamingCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BatchGetDocumentsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BatchGetDocumentsResponse>` |   |

### batchWrite(BatchWriteRequest request)

    public final BatchWriteResponse batchWrite(BatchWriteRequest request)

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically and can apply them out
of order. Method does not allow more than one write per document. Each write succeeds or fails
independently. See the BatchWriteResponse for the
success status of each write.

If you require an atomically applied set of writes, use
Commit instead.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       BatchWriteRequest request =
           BatchWriteRequest.newBuilder()
               .setDatabase("database1789464955")
               .addAllWrites(new ArrayList<Write>())
               .putAllLabels(new HashMap<String, String>())
               .build();
       BatchWriteResponse response = firestoreClient.batchWrite(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BatchWriteRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BatchWriteResponse` |   |

### batchWriteCallable()

    public final UnaryCallable<BatchWriteRequest,BatchWriteResponse> batchWriteCallable()

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically and can apply them out
of order. Method does not allow more than one write per document. Each write succeeds or fails
independently. See the BatchWriteResponse for the
success status of each write.

If you require an atomically applied set of writes, use
Commit instead.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       BatchWriteRequest request =
           BatchWriteRequest.newBuilder()
               .setDatabase("database1789464955")
               .addAllWrites(new ArrayList<Write>())
               .putAllLabels(new HashMap<String, String>())
               .build();
       ApiFuture<BatchWriteResponse> future =
           firestoreClient.batchWriteCallable().futureCall(request);
       // Do something.
       BatchWriteResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BatchWriteRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BatchWriteResponse>` |   |

### beginTransaction(BeginTransactionRequest request)

    public final BeginTransactionResponse beginTransaction(BeginTransactionRequest request)

Starts a new transaction.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       BeginTransactionRequest request =
           BeginTransactionRequest.newBuilder()
               .setDatabase("database1789464955")
               .setOptions(TransactionOptions.newBuilder().build())
               .build();
       BeginTransactionResponse response = firestoreClient.beginTransaction(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BeginTransactionRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BeginTransactionResponse` |   |

### beginTransaction(String database)

    public final BeginTransactionResponse beginTransaction(String database)

Starts a new transaction.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       String database = "database1789464955";
       BeginTransactionResponse response = firestoreClient.beginTransaction(database);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BeginTransactionResponse` |   |

### beginTransactionCallable()

    public final UnaryCallable<BeginTransactionRequest,BeginTransactionResponse> beginTransactionCallable()

Starts a new transaction.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       BeginTransactionRequest request =
           BeginTransactionRequest.newBuilder()
               .setDatabase("database1789464955")
               .setOptions(TransactionOptions.newBuilder().build())
               .build();
       ApiFuture<BeginTransactionResponse> future =
           firestoreClient.beginTransactionCallable().futureCall(request);
       // Do something.
       BeginTransactionResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BeginTransactionRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.BeginTransactionResponse>` |   |

### close()

    public final void close()

### commit(CommitRequest request)

    public final CommitResponse commit(CommitRequest request)

Commits a transaction, while optionally updating documents.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       CommitRequest request =
           CommitRequest.newBuilder()
               .setDatabase("database1789464955")
               .addAllWrites(new ArrayList<Write>())
               .setTransaction(ByteString.EMPTY)
               .build();
       CommitResponse response = firestoreClient.commit(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CommitRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CommitResponse` |   |

### commit(String database, List\<Write\> writes)

    public final CommitResponse commit(String database, List<Write> writes)

Commits a transaction, while optionally updating documents.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       String database = "database1789464955";
       List<Write> writes = new ArrayList<>();
       CommitResponse response = firestoreClient.commit(database, writes);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `writes` | `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Write>` The writes to apply. Always executed atomically and in order. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CommitResponse` |   |

### commitCallable()

    public final UnaryCallable<CommitRequest,CommitResponse> commitCallable()

Commits a transaction, while optionally updating documents.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       CommitRequest request =
           CommitRequest.newBuilder()
               .setDatabase("database1789464955")
               .addAllWrites(new ArrayList<Write>())
               .setTransaction(ByteString.EMPTY)
               .build();
       ApiFuture<CommitResponse> future = firestoreClient.commitCallable().futureCall(request);
       // Do something.
       CommitResponse response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CommitRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CommitResponse>` |   |

### createDocument(CreateDocumentRequest request)

    public final Document createDocument(CreateDocumentRequest request)

Creates a new document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       CreateDocumentRequest request =
           CreateDocumentRequest.newBuilder()
               .setParent("parent-995424086")
               .setCollectionId("collectionId1636075609")
               .setDocumentId("documentId-814940266")
               .setDocument(Document.newBuilder().build())
               .setMask(DocumentMask.newBuilder().build())
               .build();
       Document response = firestoreClient.createDocument(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CreateDocumentRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document` |   |

### createDocumentCallable()

    public final UnaryCallable<CreateDocumentRequest,Document> createDocumentCallable()

Creates a new document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       CreateDocumentRequest request =
           CreateDocumentRequest.newBuilder()
               .setParent("parent-995424086")
               .setCollectionId("collectionId1636075609")
               .setDocumentId("documentId-814940266")
               .setDocument(Document.newBuilder().build())
               .setMask(DocumentMask.newBuilder().build())
               .build();
       ApiFuture<Document> future = firestoreClient.createDocumentCallable().futureCall(request);
       // Do something.
       Document response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.CreateDocumentRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document>` |   |

### deleteDocument(DeleteDocumentRequest request)

    public final void deleteDocument(DeleteDocumentRequest request)

Deletes a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       DeleteDocumentRequest request =
           DeleteDocumentRequest.newBuilder()
               .setName("name3373707")
               .setCurrentDocument(Precondition.newBuilder().build())
               .build();
       firestoreClient.deleteDocument(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.DeleteDocumentRequest` The request object containing all of the parameters for the API call. |

### deleteDocument(String name)

    public final void deleteDocument(String name)

Deletes a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       String name = "name3373707";
       firestoreClient.deleteDocument(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The resource name of the Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. |

### deleteDocumentCallable()

    public final UnaryCallable<DeleteDocumentRequest,Empty> deleteDocumentCallable()

Deletes a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       DeleteDocumentRequest request =
           DeleteDocumentRequest.newBuilder()
               .setName("name3373707")
               .setCurrentDocument(Precondition.newBuilder().build())
               .build();
       ApiFuture<Empty> future = firestoreClient.deleteDocumentCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.DeleteDocumentRequest,https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html>` |   |

### executePipelineCallable()

    public final ServerStreamingCallable<ExecutePipelineRequest,ExecutePipelineResponse> executePipelineCallable()

Executes a pipeline query.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       ExecutePipelineRequest request =
           ExecutePipelineRequest.newBuilder()
               .setDatabase("database1789464955")
               .setAutoCommitTransaction(true)
               .build();
       ServerStream<ExecutePipelineResponse> stream =
           firestoreClient.executePipelineCallable().call(request);
       for (ExecutePipelineResponse response : stream) {
         // Do something when a response is received.
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ServerStreamingCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ExecutePipelineRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ExecutePipelineResponse>` |   |

### getDocument(GetDocumentRequest request)

    public final Document getDocument(GetDocumentRequest request)

Gets a single document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       GetDocumentRequest request =
           GetDocumentRequest.newBuilder()
               .setName("name3373707")
               .setMask(DocumentMask.newBuilder().build())
               .build();
       Document response = firestoreClient.getDocument(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.GetDocumentRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document` |   |

### getDocumentCallable()

    public final UnaryCallable<GetDocumentRequest,Document> getDocumentCallable()

Gets a single document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       GetDocumentRequest request =
           GetDocumentRequest.newBuilder()
               .setName("name3373707")
               .setMask(DocumentMask.newBuilder().build())
               .build();
       ApiFuture<Document> future = firestoreClient.getDocumentCallable().futureCall(request);
       // Do something.
       Document response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.GetDocumentRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document>` |   |

### getSettings()

    public final FirestoreSettings getSettings()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreSettings` |   |

### getStub()

    public FirestoreStub getStub()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.stub.FirestoreStub` |   |

### isShutdown()

    public boolean isShutdown()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### isTerminated()

    public boolean isTerminated()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### listCollectionIds(ListCollectionIdsRequest request)

    public final FirestoreClient.ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsRequest request)

Lists all the collection IDs underneath a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       ListCollectionIdsRequest request =
           ListCollectionIdsRequest.newBuilder()
               .setParent("parent-995424086")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       for (String element : firestoreClient.listCollectionIds(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListCollectionIdsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse` |   |

### listCollectionIds(String parent)

    public final FirestoreClient.ListCollectionIdsPagedResponse listCollectionIds(String parent)

Lists all the collection IDs underneath a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       String parent = "parent-995424086";
       for (String element : firestoreClient.listCollectionIds(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The parent document. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` Use `projects/{project_id}/databases/{database_id}/documents` to list top-level collections. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse` |   |

### listCollectionIdsCallable()

    public final UnaryCallable<ListCollectionIdsRequest,ListCollectionIdsResponse> listCollectionIdsCallable()

Lists all the collection IDs underneath a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       ListCollectionIdsRequest request =
           ListCollectionIdsRequest.newBuilder()
               .setParent("parent-995424086")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       while (true) {
         ListCollectionIdsResponse response =
             firestoreClient.listCollectionIdsCallable().call(request);
         for (String element : response.getCollectionIdsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListCollectionIdsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListCollectionIdsResponse>` |   |

### listCollectionIdsPagedCallable()

    public final UnaryCallable<ListCollectionIdsRequest,FirestoreClient.ListCollectionIdsPagedResponse> listCollectionIdsPagedCallable()

Lists all the collection IDs underneath a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       ListCollectionIdsRequest request =
           ListCollectionIdsRequest.newBuilder()
               .setParent("parent-995424086")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       ApiFuture<String> future =
           firestoreClient.listCollectionIdsPagedCallable().futureCall(request);
       // Do something.
       for (String element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListCollectionIdsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse>` |   |

### listDocuments(ListDocumentsRequest request)

    public final FirestoreClient.ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request)

Lists documents.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       ListDocumentsRequest request =
           ListDocumentsRequest.newBuilder()
               .setParent("parent-995424086")
               .setCollectionId("collectionId1636075609")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setOrderBy("orderBy-1207110587")
               .setMask(DocumentMask.newBuilder().build())
               .setShowMissing(true)
               .build();
       for (Document element : firestoreClient.listDocuments(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListDocumentsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse` |   |

### listDocumentsCallable()

    public final UnaryCallable<ListDocumentsRequest,ListDocumentsResponse> listDocumentsCallable()

Lists documents.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       ListDocumentsRequest request =
           ListDocumentsRequest.newBuilder()
               .setParent("parent-995424086")
               .setCollectionId("collectionId1636075609")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setOrderBy("orderBy-1207110587")
               .setMask(DocumentMask.newBuilder().build())
               .setShowMissing(true)
               .build();
       while (true) {
         ListDocumentsResponse response = firestoreClient.listDocumentsCallable().call(request);
         for (Document element : response.getDocumentsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListDocumentsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListDocumentsResponse>` |   |

### listDocumentsPagedCallable()

    public final UnaryCallable<ListDocumentsRequest,FirestoreClient.ListDocumentsPagedResponse> listDocumentsPagedCallable()

Lists documents.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       ListDocumentsRequest request =
           ListDocumentsRequest.newBuilder()
               .setParent("parent-995424086")
               .setCollectionId("collectionId1636075609")
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .setOrderBy("orderBy-1207110587")
               .setMask(DocumentMask.newBuilder().build())
               .setShowMissing(true)
               .build();
       ApiFuture<Document> future = firestoreClient.listDocumentsPagedCallable().futureCall(request);
       // Do something.
       for (Document element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListDocumentsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse>` |   |

### listenCallable()

    public final BidiStreamingCallable<ListenRequest,ListenResponse> listenCallable()

Listens to changes. This method is only available via gRPC or WebChannel (not REST).

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       BidiStream<ListenRequest, ListenResponse> bidiStream =
           firestoreClient.listenCallable().call();
       ListenRequest request =
           ListenRequest.newBuilder()
               .setDatabase("database1789464955")
               .putAllLabels(new HashMap<String, String>())
               .build();
       bidiStream.send(request);
       for (ListenResponse response : bidiStream) {
         // Do something when a response is received.
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.BidiStreamingCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListenRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.ListenResponse>` |   |

### partitionQuery(PartitionQueryRequest request)

    public final FirestoreClient.PartitionQueryPagedResponse partitionQuery(PartitionQueryRequest request)

Partitions a query by returning partition cursors that can be used to run the query in
parallel. The returned partition cursors are split points that can be used by RunQuery as
starting/end points for the query results.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       PartitionQueryRequest request =
           PartitionQueryRequest.newBuilder()
               .setParent("parent-995424086")
               .setPartitionCount(-1738969222)
               .setPageToken("pageToken873572522")
               .setPageSize(883849137)
               .build();
       for (Cursor element : firestoreClient.partitionQuery(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.PartitionQueryRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse` |   |

### partitionQueryCallable()

    public final UnaryCallable<PartitionQueryRequest,PartitionQueryResponse> partitionQueryCallable()

Partitions a query by returning partition cursors that can be used to run the query in
parallel. The returned partition cursors are split points that can be used by RunQuery as
starting/end points for the query results.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       PartitionQueryRequest request =
           PartitionQueryRequest.newBuilder()
               .setParent("parent-995424086")
               .setPartitionCount(-1738969222)
               .setPageToken("pageToken873572522")
               .setPageSize(883849137)
               .build();
       while (true) {
         PartitionQueryResponse response = firestoreClient.partitionQueryCallable().call(request);
         for (Cursor element : response.getPartitionsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.PartitionQueryRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.PartitionQueryResponse>` |   |

### partitionQueryPagedCallable()

    public final UnaryCallable<PartitionQueryRequest,FirestoreClient.PartitionQueryPagedResponse> partitionQueryPagedCallable()

Partitions a query by returning partition cursors that can be used to run the query in
parallel. The returned partition cursors are split points that can be used by RunQuery as
starting/end points for the query results.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       PartitionQueryRequest request =
           PartitionQueryRequest.newBuilder()
               .setParent("parent-995424086")
               .setPartitionCount(-1738969222)
               .setPageToken("pageToken873572522")
               .setPageSize(883849137)
               .build();
       ApiFuture<Cursor> future = firestoreClient.partitionQueryPagedCallable().futureCall(request);
       // Do something.
       for (Cursor element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.PartitionQueryRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse>` |   |

### rollback(RollbackRequest request)

    public final void rollback(RollbackRequest request)

Rolls back a transaction.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       RollbackRequest request =
           RollbackRequest.newBuilder()
               .setDatabase("database1789464955")
               .setTransaction(ByteString.EMPTY)
               .build();
       firestoreClient.rollback(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.RollbackRequest` The request object containing all of the parameters for the API call. |

### rollback(String database, ByteString transaction)

    public final void rollback(String database, ByteString transaction)

Rolls back a transaction.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       String database = "database1789464955";
       ByteString transaction = ByteString.EMPTY;
       firestoreClient.rollback(database, transaction);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `database` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. |
| `transaction` | `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` Required. The transaction to roll back. |

### rollbackCallable()

    public final UnaryCallable<RollbackRequest,Empty> rollbackCallable()

Rolls back a transaction.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       RollbackRequest request =
           RollbackRequest.newBuilder()
               .setDatabase("database1789464955")
               .setTransaction(ByteString.EMPTY)
               .build();
       ApiFuture<Empty> future = firestoreClient.rollbackCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.RollbackRequest,https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html>` |   |

### runAggregationQueryCallable()

    public final ServerStreamingCallable<RunAggregationQueryRequest,RunAggregationQueryResponse> runAggregationQueryCallable()

Runs an aggregation query.

Rather than producing Document results like
Firestore.RunQuery, this API allows running an
aggregation to produce a series of AggregationResult
server-side.

High-Level Example:

`<code><code> -- Return the number of documents in table given a filter. SELECT COUNT(&#42;) FROM (
SELECT &#42; FROM k where a = true ); </code></code>`

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       RunAggregationQueryRequest request =
           RunAggregationQueryRequest.newBuilder()
               .setParent("parent-995424086")
               .setExplainOptions(ExplainOptions.newBuilder().build())
               .build();
       ServerStream<RunAggregationQueryResponse> stream =
           firestoreClient.runAggregationQueryCallable().call(request);
       for (RunAggregationQueryResponse response : stream) {
         // Do something when a response is received.
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ServerStreamingCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.RunAggregationQueryRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.RunAggregationQueryResponse>` |   |

### runQueryCallable()

    public final ServerStreamingCallable<RunQueryRequest,RunQueryResponse> runQueryCallable()

Runs a query.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       RunQueryRequest request =
           RunQueryRequest.newBuilder()
               .setParent("parent-995424086")
               .setExplainOptions(ExplainOptions.newBuilder().build())
               .build();
       ServerStream<RunQueryResponse> stream = firestoreClient.runQueryCallable().call(request);
       for (RunQueryResponse response : stream) {
         // Do something when a response is received.
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.ServerStreamingCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.RunQueryRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.RunQueryResponse>` |   |

### shutdown()

    public void shutdown()

### shutdownNow()

    public void shutdownNow()

### updateDocument(Document document, DocumentMask updateMask)

    public final Document updateDocument(Document document, DocumentMask updateMask)

Updates or inserts a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       Document document = Document.newBuilder().build();
       DocumentMask updateMask = DocumentMask.newBuilder().build();
       Document response = firestoreClient.updateDocument(document, updateMask);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `document` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document` Required. The updated document. Creates the document if it does not already exist. |
| `updateMask` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.DocumentMask` The fields to update. None of the field paths in the mask may contain a reserved name. If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document` |   |

### updateDocument(UpdateDocumentRequest request)

    public final Document updateDocument(UpdateDocumentRequest request)

Updates or inserts a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       UpdateDocumentRequest request =
           UpdateDocumentRequest.newBuilder()
               .setDocument(Document.newBuilder().build())
               .setUpdateMask(DocumentMask.newBuilder().build())
               .setMask(DocumentMask.newBuilder().build())
               .setCurrentDocument(Precondition.newBuilder().build())
               .build();
       Document response = firestoreClient.updateDocument(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.UpdateDocumentRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document` |   |

### updateDocumentCallable()

    public final UnaryCallable<UpdateDocumentRequest,Document> updateDocumentCallable()

Updates or inserts a document.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       UpdateDocumentRequest request =
           UpdateDocumentRequest.newBuilder()
               .setDocument(Document.newBuilder().build())
               .setUpdateMask(DocumentMask.newBuilder().build())
               .setMask(DocumentMask.newBuilder().build())
               .setCurrentDocument(Precondition.newBuilder().build())
               .build();
       ApiFuture<Document> future = firestoreClient.updateDocumentCallable().futureCall(request);
       // Do something.
       Document response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.UpdateDocumentRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.Document>` |   |

### writeCallable()

    public final BidiStreamingCallable<WriteRequest,WriteResponse> writeCallable()

Streams batches of document updates and deletes, in order. This method is only available via
gRPC or WebChannel (not REST).

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (FirestoreClient firestoreClient = FirestoreClient.create()) {
       BidiStream<WriteRequest, WriteResponse> bidiStream = firestoreClient.writeCallable().call();
       WriteRequest request =
           WriteRequest.newBuilder()
               .setDatabase("database1789464955")
               .setStreamId("streamId1790933179")
               .addAllWrites(new ArrayList<Write>())
               .setStreamToken(ByteString.EMPTY)
               .putAllLabels(new HashMap<String, String>())
               .build();
       bidiStream.send(request);
       for (WriteResponse response : bidiStream) {
         // Do something when a response is received.
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.BidiStreamingCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.WriteRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.firestore.v1.WriteResponse>` |   |