All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.cloud.firestore.v1.FirestoreClient Maven / Gradle / Ivy

There is a newer version: 3.29.1
Show newest version
/*
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.cloud.firestore.v1;

import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.firestore.v1.stub.FirestoreStub;
import com.google.cloud.firestore.v1.stub.FirestoreStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.firestore.v1.BatchGetDocumentsRequest;
import com.google.firestore.v1.BatchGetDocumentsResponse;
import com.google.firestore.v1.BatchWriteRequest;
import com.google.firestore.v1.BatchWriteResponse;
import com.google.firestore.v1.BeginTransactionRequest;
import com.google.firestore.v1.BeginTransactionResponse;
import com.google.firestore.v1.CommitRequest;
import com.google.firestore.v1.CommitResponse;
import com.google.firestore.v1.CreateDocumentRequest;
import com.google.firestore.v1.Cursor;
import com.google.firestore.v1.DeleteDocumentRequest;
import com.google.firestore.v1.Document;
import com.google.firestore.v1.DocumentMask;
import com.google.firestore.v1.GetDocumentRequest;
import com.google.firestore.v1.ListCollectionIdsRequest;
import com.google.firestore.v1.ListCollectionIdsResponse;
import com.google.firestore.v1.ListDocumentsRequest;
import com.google.firestore.v1.ListDocumentsResponse;
import com.google.firestore.v1.ListenRequest;
import com.google.firestore.v1.ListenResponse;
import com.google.firestore.v1.PartitionQueryRequest;
import com.google.firestore.v1.PartitionQueryResponse;
import com.google.firestore.v1.RollbackRequest;
import com.google.firestore.v1.RunAggregationQueryRequest;
import com.google.firestore.v1.RunAggregationQueryResponse;
import com.google.firestore.v1.RunQueryRequest;
import com.google.firestore.v1.RunQueryResponse;
import com.google.firestore.v1.UpdateDocumentRequest;
import com.google.firestore.v1.Write;
import com.google.firestore.v1.WriteRequest;
import com.google.firestore.v1.WriteResponse;
import com.google.protobuf.ByteString;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
 * 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: * *

{@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);
 * }
 * }
* *

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(). * *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Methods
MethodDescriptionMethod 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() *

*

RunAggregationQuery

Runs an aggregation query. *

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

High-Level Example: *

``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```

*

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][google.firestore.v1.BatchWriteResponse] for the success status of each write. *

If you require an atomically applied set of writes, use [Commit][google.firestore.v1.Firestore.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() *

*
* *

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: * *

{@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
 * FirestoreSettings firestoreSettings =
 *     FirestoreSettings.newBuilder()
 *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
 *         .build();
 * FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings);
 * }
* *

To customize the endpoint: * *

{@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
 * 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: * *

{@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
 * FirestoreSettings firestoreSettings = FirestoreSettings.newHttpJsonBuilder().build();
 * FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings);
 * }
* *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class FirestoreClient implements BackgroundResource { private final FirestoreSettings settings; private final FirestoreStub stub; /** Constructs an instance of FirestoreClient with default settings. */ public static final FirestoreClient create() throws IOException { return create(FirestoreSettings.newBuilder().build()); } /** * 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. */ public static final FirestoreClient create(FirestoreSettings settings) throws IOException { return new FirestoreClient(settings); } /** * Constructs an instance of FirestoreClient, using the given stub for making calls. This is for * advanced usage - prefer using create(FirestoreSettings). */ public static final FirestoreClient create(FirestoreStub stub) { return new FirestoreClient(stub); } /** * 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. */ protected FirestoreClient(FirestoreSettings settings) throws IOException { this.settings = settings; this.stub = ((FirestoreStubSettings) settings.getStubSettings()).createStub(); } protected FirestoreClient(FirestoreStub stub) { this.settings = null; this.stub = stub; } public final FirestoreSettings getSettings() { return settings; } public FirestoreStub getStub() { return stub; } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single document. * *

Sample code: * *

{@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);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Document getDocument(GetDocumentRequest request) { return getDocumentCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single document. * *

Sample code: * *

{@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 future = firestoreClient.getDocumentCallable().futureCall(request);
   *   // Do something.
   *   Document response = future.get();
   * }
   * }
*/ public final UnaryCallable getDocumentCallable() { return stub.getDocumentCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists documents. * *

Sample code: * *

{@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);
   *   }
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request) { return listDocumentsPagedCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists documents. * *

Sample code: * *

{@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 future = firestoreClient.listDocumentsPagedCallable().futureCall(request);
   *   // Do something.
   *   for (Document element : future.get().iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }
*/ public final UnaryCallable listDocumentsPagedCallable() { return stub.listDocumentsPagedCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists documents. * *

Sample code: * *

{@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;
   *     }
   *   }
   * }
   * }
*/ public final UnaryCallable listDocumentsCallable() { return stub.listDocumentsCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates or inserts a document. * *

Sample code: * *

{@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);
   * }
   * }
* * @param document Required. The updated document. Creates the document if it does not already * exist. * @param updateMask 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. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Document updateDocument(Document document, DocumentMask updateMask) { UpdateDocumentRequest request = UpdateDocumentRequest.newBuilder().setDocument(document).setUpdateMask(updateMask).build(); return updateDocument(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates or inserts a document. * *

Sample code: * *

{@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);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Document updateDocument(UpdateDocumentRequest request) { return updateDocumentCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates or inserts a document. * *

Sample code: * *

{@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 future = firestoreClient.updateDocumentCallable().futureCall(request);
   *   // Do something.
   *   Document response = future.get();
   * }
   * }
*/ public final UnaryCallable updateDocumentCallable() { return stub.updateDocumentCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a document. * *

Sample code: * *

{@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);
   * }
   * }
* * @param name Required. The resource name of the Document to delete. In the format: * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteDocument(String name) { DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder().setName(name).build(); deleteDocument(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a document. * *

Sample code: * *

{@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);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteDocument(DeleteDocumentRequest request) { deleteDocumentCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a document. * *

Sample code: * *

{@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 future = firestoreClient.deleteDocumentCallable().futureCall(request);
   *   // Do something.
   *   future.get();
   * }
   * }
*/ public final UnaryCallable deleteDocumentCallable() { return stub.deleteDocumentCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets multiple documents. * *

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

Sample code: * *

{@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())
   *           .setMask(DocumentMask.newBuilder().build())
   *           .build();
   *   ServerStream stream =
   *       firestoreClient.batchGetDocumentsCallable().call(request);
   *   for (BatchGetDocumentsResponse response : stream) {
   *     // Do something when a response is received.
   *   }
   * }
   * }
*/ public final ServerStreamingCallable batchGetDocumentsCallable() { return stub.batchGetDocumentsCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Starts a new transaction. * *

Sample code: * *

{@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);
   * }
   * }
* * @param database Required. The database name. In the format: * `projects/{project_id}/databases/{database_id}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final BeginTransactionResponse beginTransaction(String database) { BeginTransactionRequest request = BeginTransactionRequest.newBuilder().setDatabase(database).build(); return beginTransaction(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Starts a new transaction. * *

Sample code: * *

{@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);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest request) { return beginTransactionCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Starts a new transaction. * *

Sample code: * *

{@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 future =
   *       firestoreClient.beginTransactionCallable().futureCall(request);
   *   // Do something.
   *   BeginTransactionResponse response = future.get();
   * }
   * }
*/ public final UnaryCallable beginTransactionCallable() { return stub.beginTransactionCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Commits a transaction, while optionally updating documents. * *

Sample code: * *

{@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 writes = new ArrayList<>();
   *   CommitResponse response = firestoreClient.commit(database, writes);
   * }
   * }
* * @param database Required. The database name. In the format: * `projects/{project_id}/databases/{database_id}`. * @param writes The writes to apply. *

Always executed atomically and in order. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final CommitResponse commit(String database, List writes) { CommitRequest request = CommitRequest.newBuilder().setDatabase(database).addAllWrites(writes).build(); return commit(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Commits a transaction, while optionally updating documents. * *

Sample code: * *

{@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())
   *           .setTransaction(ByteString.EMPTY)
   *           .build();
   *   CommitResponse response = firestoreClient.commit(request);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final CommitResponse commit(CommitRequest request) { return commitCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Commits a transaction, while optionally updating documents. * *

Sample code: * *

{@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())
   *           .setTransaction(ByteString.EMPTY)
   *           .build();
   *   ApiFuture future = firestoreClient.commitCallable().futureCall(request);
   *   // Do something.
   *   CommitResponse response = future.get();
   * }
   * }
*/ public final UnaryCallable commitCallable() { return stub.commitCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Rolls back a transaction. * *

Sample code: * *

{@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);
   * }
   * }
* * @param database Required. The database name. In the format: * `projects/{project_id}/databases/{database_id}`. * @param transaction Required. The transaction to roll back. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void rollback(String database, ByteString transaction) { RollbackRequest request = RollbackRequest.newBuilder().setDatabase(database).setTransaction(transaction).build(); rollback(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Rolls back a transaction. * *

Sample code: * *

{@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);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void rollback(RollbackRequest request) { rollbackCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Rolls back a transaction. * *

Sample code: * *

{@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 future = firestoreClient.rollbackCallable().futureCall(request);
   *   // Do something.
   *   future.get();
   * }
   * }
*/ public final UnaryCallable rollbackCallable() { return stub.rollbackCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Runs a query. * *

Sample code: * *

{@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 stream = firestoreClient.runQueryCallable().call(request);
   *   for (RunQueryResponse response : stream) {
   *     // Do something when a response is received.
   *   }
   * }
   * }
*/ public final ServerStreamingCallable runQueryCallable() { return stub.runQueryCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Runs an aggregation query. * *

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

High-Level Example: * *

``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( * SELECT * FROM k where a = true ); ``` * *

Sample code: * *

{@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 stream =
   *       firestoreClient.runAggregationQueryCallable().call(request);
   *   for (RunAggregationQueryResponse response : stream) {
   *     // Do something when a response is received.
   *   }
   * }
   * }
*/ public final ServerStreamingCallable runAggregationQueryCallable() { return stub.runAggregationQueryCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * 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: * *

{@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);
   *   }
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final PartitionQueryPagedResponse partitionQuery(PartitionQueryRequest request) { return partitionQueryPagedCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * 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: * *

{@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 future = firestoreClient.partitionQueryPagedCallable().futureCall(request);
   *   // Do something.
   *   for (Cursor element : future.get().iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }
*/ public final UnaryCallable partitionQueryPagedCallable() { return stub.partitionQueryPagedCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * 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: * *

{@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;
   *     }
   *   }
   * }
   * }
*/ public final UnaryCallable partitionQueryCallable() { return stub.partitionQueryCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Streams batches of document updates and deletes, in order. This method is only available via * gRPC or WebChannel (not REST). * *

Sample code: * *

{@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 bidiStream = firestoreClient.writeCallable().call();
   *   WriteRequest request =
   *       WriteRequest.newBuilder()
   *           .setDatabase("database1789464955")
   *           .setStreamId("streamId1790933179")
   *           .addAllWrites(new ArrayList())
   *           .setStreamToken(ByteString.EMPTY)
   *           .putAllLabels(new HashMap())
   *           .build();
   *   bidiStream.send(request);
   *   for (WriteResponse response : bidiStream) {
   *     // Do something when a response is received.
   *   }
   * }
   * }
*/ public final BidiStreamingCallable writeCallable() { return stub.writeCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Listens to changes. This method is only available via gRPC or WebChannel (not REST). * *

Sample code: * *

{@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 bidiStream =
   *       firestoreClient.listenCallable().call();
   *   ListenRequest request =
   *       ListenRequest.newBuilder()
   *           .setDatabase("database1789464955")
   *           .putAllLabels(new HashMap())
   *           .build();
   *   bidiStream.send(request);
   *   for (ListenResponse response : bidiStream) {
   *     // Do something when a response is received.
   *   }
   * }
   * }
*/ public final BidiStreamingCallable listenCallable() { return stub.listenCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * *

{@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);
   *   }
   * }
   * }
* * @param parent 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` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListCollectionIdsPagedResponse listCollectionIds(String parent) { ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder().setParent(parent).build(); return listCollectionIds(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * *

{@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);
   *   }
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsRequest request) { return listCollectionIdsPagedCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * *

{@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 future =
   *       firestoreClient.listCollectionIdsPagedCallable().futureCall(request);
   *   // Do something.
   *   for (String element : future.get().iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }
*/ public final UnaryCallable listCollectionIdsPagedCallable() { return stub.listCollectionIdsPagedCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * *

{@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;
   *     }
   *   }
   * }
   * }
*/ public final UnaryCallable listCollectionIdsCallable() { return stub.listCollectionIdsCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * 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][google.firestore.v1.BatchWriteResponse] for the * success status of each write. * *

If you require an atomically applied set of writes, use * [Commit][google.firestore.v1.Firestore.Commit] instead. * *

Sample code: * *

{@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())
   *           .putAllLabels(new HashMap())
   *           .build();
   *   BatchWriteResponse response = firestoreClient.batchWrite(request);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final BatchWriteResponse batchWrite(BatchWriteRequest request) { return batchWriteCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * 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][google.firestore.v1.BatchWriteResponse] for the * success status of each write. * *

If you require an atomically applied set of writes, use * [Commit][google.firestore.v1.Firestore.Commit] instead. * *

Sample code: * *

{@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())
   *           .putAllLabels(new HashMap())
   *           .build();
   *   ApiFuture future =
   *       firestoreClient.batchWriteCallable().futureCall(request);
   *   // Do something.
   *   BatchWriteResponse response = future.get();
   * }
   * }
*/ public final UnaryCallable batchWriteCallable() { return stub.batchWriteCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new document. * *

Sample code: * *

{@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);
   * }
   * }
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Document createDocument(CreateDocumentRequest request) { return createDocumentCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new document. * *

Sample code: * *

{@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 future = firestoreClient.createDocumentCallable().futureCall(request);
   *   // Do something.
   *   Document response = future.get();
   * }
   * }
*/ public final UnaryCallable createDocumentCallable() { return stub.createDocumentCallable(); } @Override public final void close() { stub.close(); } @Override public void shutdown() { stub.shutdown(); } @Override public boolean isShutdown() { return stub.isShutdown(); } @Override public boolean isTerminated() { return stub.isTerminated(); } @Override public void shutdownNow() { stub.shutdownNow(); } @Override public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { return stub.awaitTermination(duration, unit); } public static class ListDocumentsPagedResponse extends AbstractPagedListResponse< ListDocumentsRequest, ListDocumentsResponse, Document, ListDocumentsPage, ListDocumentsFixedSizeCollection> { public static ApiFuture createAsync( PageContext context, ApiFuture futureResponse) { ApiFuture futurePage = ListDocumentsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, input -> new ListDocumentsPagedResponse(input), MoreExecutors.directExecutor()); } private ListDocumentsPagedResponse(ListDocumentsPage page) { super(page, ListDocumentsFixedSizeCollection.createEmptyCollection()); } } public static class ListDocumentsPage extends AbstractPage< ListDocumentsRequest, ListDocumentsResponse, Document, ListDocumentsPage> { private ListDocumentsPage( PageContext context, ListDocumentsResponse response) { super(context, response); } private static ListDocumentsPage createEmptyPage() { return new ListDocumentsPage(null, null); } @Override protected ListDocumentsPage createPage( PageContext context, ListDocumentsResponse response) { return new ListDocumentsPage(context, response); } @Override public ApiFuture createPageAsync( PageContext context, ApiFuture futureResponse) { return super.createPageAsync(context, futureResponse); } } public static class ListDocumentsFixedSizeCollection extends AbstractFixedSizeCollection< ListDocumentsRequest, ListDocumentsResponse, Document, ListDocumentsPage, ListDocumentsFixedSizeCollection> { private ListDocumentsFixedSizeCollection(List pages, int collectionSize) { super(pages, collectionSize); } private static ListDocumentsFixedSizeCollection createEmptyCollection() { return new ListDocumentsFixedSizeCollection(null, 0); } @Override protected ListDocumentsFixedSizeCollection createCollection( List pages, int collectionSize) { return new ListDocumentsFixedSizeCollection(pages, collectionSize); } } public static class PartitionQueryPagedResponse extends AbstractPagedListResponse< PartitionQueryRequest, PartitionQueryResponse, Cursor, PartitionQueryPage, PartitionQueryFixedSizeCollection> { public static ApiFuture createAsync( PageContext context, ApiFuture futureResponse) { ApiFuture futurePage = PartitionQueryPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, input -> new PartitionQueryPagedResponse(input), MoreExecutors.directExecutor()); } private PartitionQueryPagedResponse(PartitionQueryPage page) { super(page, PartitionQueryFixedSizeCollection.createEmptyCollection()); } } public static class PartitionQueryPage extends AbstractPage< PartitionQueryRequest, PartitionQueryResponse, Cursor, PartitionQueryPage> { private PartitionQueryPage( PageContext context, PartitionQueryResponse response) { super(context, response); } private static PartitionQueryPage createEmptyPage() { return new PartitionQueryPage(null, null); } @Override protected PartitionQueryPage createPage( PageContext context, PartitionQueryResponse response) { return new PartitionQueryPage(context, response); } @Override public ApiFuture createPageAsync( PageContext context, ApiFuture futureResponse) { return super.createPageAsync(context, futureResponse); } } public static class PartitionQueryFixedSizeCollection extends AbstractFixedSizeCollection< PartitionQueryRequest, PartitionQueryResponse, Cursor, PartitionQueryPage, PartitionQueryFixedSizeCollection> { private PartitionQueryFixedSizeCollection(List pages, int collectionSize) { super(pages, collectionSize); } private static PartitionQueryFixedSizeCollection createEmptyCollection() { return new PartitionQueryFixedSizeCollection(null, 0); } @Override protected PartitionQueryFixedSizeCollection createCollection( List pages, int collectionSize) { return new PartitionQueryFixedSizeCollection(pages, collectionSize); } } public static class ListCollectionIdsPagedResponse extends AbstractPagedListResponse< ListCollectionIdsRequest, ListCollectionIdsResponse, String, ListCollectionIdsPage, ListCollectionIdsFixedSizeCollection> { public static ApiFuture createAsync( PageContext context, ApiFuture futureResponse) { ApiFuture futurePage = ListCollectionIdsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, input -> new ListCollectionIdsPagedResponse(input), MoreExecutors.directExecutor()); } private ListCollectionIdsPagedResponse(ListCollectionIdsPage page) { super(page, ListCollectionIdsFixedSizeCollection.createEmptyCollection()); } } public static class ListCollectionIdsPage extends AbstractPage< ListCollectionIdsRequest, ListCollectionIdsResponse, String, ListCollectionIdsPage> { private ListCollectionIdsPage( PageContext context, ListCollectionIdsResponse response) { super(context, response); } private static ListCollectionIdsPage createEmptyPage() { return new ListCollectionIdsPage(null, null); } @Override protected ListCollectionIdsPage createPage( PageContext context, ListCollectionIdsResponse response) { return new ListCollectionIdsPage(context, response); } @Override public ApiFuture createPageAsync( PageContext context, ApiFuture futureResponse) { return super.createPageAsync(context, futureResponse); } } public static class ListCollectionIdsFixedSizeCollection extends AbstractFixedSizeCollection< ListCollectionIdsRequest, ListCollectionIdsResponse, String, ListCollectionIdsPage, ListCollectionIdsFixedSizeCollection> { private ListCollectionIdsFixedSizeCollection( List pages, int collectionSize) { super(pages, collectionSize); } private static ListCollectionIdsFixedSizeCollection createEmptyCollection() { return new ListCollectionIdsFixedSizeCollection(null, 0); } @Override protected ListCollectionIdsFixedSizeCollection createCollection( List pages, int collectionSize) { return new ListCollectionIdsFixedSizeCollection(pages, collectionSize); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy