diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata index 39f5494be..3c8c82d22 100644 --- a/.github/readme/synth.metadata/synth.metadata +++ b/.github/readme/synth.metadata/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-firestore.git", - "sha": "b5faa073ac5ef10ab1e1be1dab75599c0707c19e" + "sha": "2bff9d2b227b62ee9550cbd6d625d9424d314a9f" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "ff6b759fcb58f216f62b48d5be0bb85fafbc3bb2" + "sha": "4f4b1b9b8d8b52f1e9e4a76165896debce5ab7f1" } } ] diff --git a/.github/release-please.yml b/.github/release-please.yml index dce2c8450..8ca7f9cab 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,3 @@ +bumpMinorPreMajor: true +handleGHRelease: true releaseType: java-yoshi -bumpMinorPreMajor: true \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index def8b3a2c..0195b32f0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,10 +19,6 @@ jobs: - run: .kokoro/build.sh env: JOB_TYPE: test - - name: coverage - uses: codecov/codecov-action@v1 - with: - name: actions ${{matrix.java}} windows: runs-on: windows-latest steps: @@ -80,4 +76,4 @@ jobs: - run: java -version - run: .kokoro/build.sh env: - JOB_TYPE: clirr \ No newline at end of file + JOB_TYPE: clirr diff --git a/.kokoro/release/publish_javadoc11.sh b/.kokoro/release/publish_javadoc11.sh index fe94e4ace..ad9f27592 100755 --- a/.kokoro/release/publish_javadoc11.sh +++ b/.kokoro/release/publish_javadoc11.sh @@ -49,6 +49,13 @@ pushd target/docfx-yml python3 -m docuploader create-metadata \ --name ${NAME} \ --version ${VERSION} \ + --xrefs devsite://java/gax \ + --xrefs devsite://java/google-cloud-core \ + --xrefs devsite://java/api-common \ + --xrefs devsite://java/proto-google-common-protos \ + --xrefs devsite://java/google-api-client \ + --xrefs devsite://java/google-http-client \ + --xrefs devsite://java/protobuf \ --language java # upload yml to production bucket diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fcf84ee4..2c4334fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [2.4.0](https://www.github.com/googleapis/java-firestore/compare/v2.3.0...v2.4.0) (2021-05-17) + + +### Features + +* add buffering layer to BulkWriter ([#611](https://www.github.com/googleapis/java-firestore/issues/611)) ([a7caff2](https://www.github.com/googleapis/java-firestore/commit/a7caff2c15ad8ad4e98165bf4029d9615c079637)) + + +### Bug Fixes + +* add flush check in BulkWriter.sendBatchLocked() callback ([#631](https://www.github.com/googleapis/java-firestore/issues/631)) ([ac3db81](https://www.github.com/googleapis/java-firestore/commit/ac3db81741ac74614d9eeae70a3f2eae6dcc9548)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.1.0 ([#626](https://www.github.com/googleapis/java-firestore/issues/626)) ([00dbe33](https://www.github.com/googleapis/java-firestore/commit/00dbe33b426ea1509f9fb72181a36dd1a83b15cc)) + ## [2.3.0](https://www.github.com/googleapis/java-firestore/compare/v2.2.7...v2.3.0) (2021-04-23) diff --git a/README.md b/README.md index 236b1ebc6..9df50b05c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 20.1.0 + 20.4.0 pom import @@ -38,25 +38,25 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-firestore - 2.2.6 + 2.3.0 ``` If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -implementation platform('com.google.cloud:libraries-bom:20.1.0') +implementation platform('com.google.cloud:libraries-bom:20.4.0') compile 'com.google.cloud:google-cloud-firestore' ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -compile 'com.google.cloud:google-cloud-firestore:2.2.6' +compile 'com.google.cloud:google-cloud-firestore:2.3.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-firestore" % "2.2.6" +libraryDependencies += "com.google.cloud" % "google-cloud-firestore" % "2.3.0" ``` ## Authentication diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..8b58ae9c0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). + +The Google Security Team will respond within 5 working days of your report on g.co/vulnz. + +We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. diff --git a/google-cloud-firestore-admin/pom.xml b/google-cloud-firestore-admin/pom.xml index 74f6787cb..e0feca693 100644 --- a/google-cloud-firestore-admin/pom.xml +++ b/google-cloud-firestore-admin/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 google-cloud-firestore-admin - 2.3.0 + 2.4.0 jar Google Cloud Firestore Admin Client https://github.com/googleapis/java-firestore @@ -14,7 +14,7 @@ com.google.cloud google-cloud-firestore-parent - 2.3.0 + 2.4.0 diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java index d06056bbf..dbfa3a2a3 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * 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.ApiFunction; @@ -60,7 +61,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: Operations are created by service `FirestoreAdmin`, but are accessed via * service `google.longrunning.Operations`. @@ -68,16 +69,14 @@ *

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
  * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
  *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
- *   firestoreAdminClient.deleteIndex(name);
+ *   Index response = firestoreAdminClient.getIndex(name);
  * }
- * 
- * 
+ * }
* - *

Note: close() needs to be called on the firestoreAdminClient object to clean up resources such + *

Note: close() needs to be called on the FirestoreAdminClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * *

The surface of this class includes several types of Java methods for each of the API's @@ -105,30 +104,25 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * FirestoreAdminSettings firestoreAdminSettings =
  *     FirestoreAdminSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * FirestoreAdminClient firestoreAdminClient =
- *     FirestoreAdminClient.create(firestoreAdminSettings);
- * 
- * 
+ * FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings); + * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * FirestoreAdminSettings firestoreAdminSettings =
  *     FirestoreAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
- * FirestoreAdminClient firestoreAdminClient =
- *     FirestoreAdminClient.create(firestoreAdminSettings);
- * 
- * 
+ * FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings); + * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class FirestoreAdminClient implements BackgroundResource { private final FirestoreAdminSettings settings; private final FirestoreAdminStub stub; @@ -150,7 +144,7 @@ public static final FirestoreAdminClient create(FirestoreAdminSettings settings) /** * Constructs an instance of FirestoreAdminClient, using the given stub for making calls. This is - * for advanced usage - prefer to use FirestoreAdminSettings}. + * for advanced usage - prefer using create(FirestoreAdminSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final FirestoreAdminClient create(FirestoreAdminStub stub) { @@ -188,246 +182,11 @@ public FirestoreAdminStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient() { return operationsClient; } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a composite index. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
-   *   firestoreAdminClient.deleteIndex(name);
-   * }
-   * 
- * - * @param name Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteIndex(IndexName name) { - DeleteIndexRequest request = - DeleteIndexRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteIndex(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a composite index. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
-   *   firestoreAdminClient.deleteIndex(name.toString());
-   * }
-   * 
- * - * @param name Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteIndex(String name) { - DeleteIndexRequest request = DeleteIndexRequest.newBuilder().setName(name).build(); - deleteIndex(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a composite index. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
-   *   DeleteIndexRequest request = DeleteIndexRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   firestoreAdminClient.deleteIndex(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 deleteIndex(DeleteIndexRequest request) { - deleteIndexCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a composite index. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
-   *   DeleteIndexRequest request = DeleteIndexRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = firestoreAdminClient.deleteIndexCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable deleteIndexCallable() { - return stub.deleteIndexCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates a field configuration. Currently, field updates apply only to single field index - * configuration. However, calls to - * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should - * provide a field mask to avoid changing any configuration that the caller isn't aware of. The - * field mask should be specified as: `{ paths: "index_config" }`. - * - *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may - * be used to track the status of the field update. The metadata for the operation will be the - * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. - * - *

To configure the default field settings for the database, use the special `Field` with - * resource name: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   Field field = Field.newBuilder().build();
-   *   Field response = firestoreAdminClient.updateFieldAsync(field).get();
-   * }
-   * 
- * - * @param field Required. The field to be updated. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture updateFieldAsync(Field field) { - UpdateFieldRequest request = UpdateFieldRequest.newBuilder().setField(field).build(); - return updateFieldAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates a field configuration. Currently, field updates apply only to single field index - * configuration. However, calls to - * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should - * provide a field mask to avoid changing any configuration that the caller isn't aware of. The - * field mask should be specified as: `{ paths: "index_config" }`. - * - *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may - * be used to track the status of the field update. The metadata for the operation will be the - * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. - * - *

To configure the default field settings for the database, use the special `Field` with - * resource name: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   Field field = Field.newBuilder().build();
-   *   UpdateFieldRequest request = UpdateFieldRequest.newBuilder()
-   *     .setField(field)
-   *     .build();
-   *   Field response = firestoreAdminClient.updateFieldAsync(request).get();
-   * }
-   * 
- * - * @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 - */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public final OperationFuture updateFieldAsync( - UpdateFieldRequest request) { - return updateFieldOperationCallable().futureCall(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates a field configuration. Currently, field updates apply only to single field index - * configuration. However, calls to - * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should - * provide a field mask to avoid changing any configuration that the caller isn't aware of. The - * field mask should be specified as: `{ paths: "index_config" }`. - * - *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may - * be used to track the status of the field update. The metadata for the operation will be the - * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. - * - *

To configure the default field settings for the database, use the special `Field` with - * resource name: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   Field field = Field.newBuilder().build();
-   *   UpdateFieldRequest request = UpdateFieldRequest.newBuilder()
-   *     .setField(field)
-   *     .build();
-   *   OperationFuture<Field, FieldOperationMetadata> future = firestoreAdminClient.updateFieldOperationCallable().futureCall(request);
-   *   // Do something
-   *   Field response = future.get();
-   * }
-   * 
- */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public final OperationCallable - updateFieldOperationCallable() { - return stub.updateFieldOperationCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates a field configuration. Currently, field updates apply only to single field index - * configuration. However, calls to - * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should - * provide a field mask to avoid changing any configuration that the caller isn't aware of. The - * field mask should be specified as: `{ paths: "index_config" }`. - * - *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may - * be used to track the status of the field update. The metadata for the operation will be the - * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. - * - *

To configure the default field settings for the database, use the special `Field` with - * resource name: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - * - *

Sample code: - * - *


-   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   Field field = Field.newBuilder().build();
-   *   UpdateFieldRequest request = UpdateFieldRequest.newBuilder()
-   *     .setField(field)
-   *     .build();
-   *   ApiFuture<Operation> future = firestoreAdminClient.updateFieldCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable updateFieldCallable() { - return stub.updateFieldCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a composite index. This returns a * [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the @@ -436,21 +195,20 @@ public final UnaryCallable updateFieldCallable() * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
+   *   CollectionGroupName parent =
+   *       CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
    *   Index index = Index.newBuilder().build();
    *   Index response = firestoreAdminClient.createIndexAsync(parent, index).get();
    * }
-   * 
+ * }
* * @param parent Required. A parent name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` * @param index Required. The composite index to create. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createIndexAsync( CollectionGroupName parent, Index index) { CreateIndexRequest request = @@ -461,7 +219,7 @@ public final OperationFuture createIndexAsync( return createIndexAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a composite index. This returns a * [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the @@ -470,21 +228,19 @@ public final OperationFuture createIndexAsync( * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
+   *   String parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString();
    *   Index index = Index.newBuilder().build();
-   *   Index response = firestoreAdminClient.createIndexAsync(parent.toString(), index).get();
+   *   Index response = firestoreAdminClient.createIndexAsync(parent, index).get();
    * }
-   * 
+ * }
* * @param parent Required. A parent name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` * @param index Required. The composite index to create. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createIndexAsync( String parent, Index index) { CreateIndexRequest request = @@ -492,7 +248,7 @@ public final OperationFuture createIndexAsync( return createIndexAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a composite index. This returns a * [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the @@ -501,29 +257,27 @@ public final OperationFuture createIndexAsync( * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   Index index = Index.newBuilder().build();
-   *   CreateIndexRequest request = CreateIndexRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setIndex(index)
-   *     .build();
+   *   CreateIndexRequest request =
+   *       CreateIndexRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setIndex(Index.newBuilder().build())
+   *           .build();
    *   Index response = firestoreAdminClient.createIndexAsync(request).get();
    * }
-   * 
+ * }
* * @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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createIndexAsync( CreateIndexRequest request) { return createIndexOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a composite index. This returns a * [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the @@ -532,27 +286,27 @@ public final OperationFuture createIndexAsync( * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   Index index = Index.newBuilder().build();
-   *   CreateIndexRequest request = CreateIndexRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setIndex(index)
-   *     .build();
-   *   OperationFuture<Index, IndexOperationMetadata> future = firestoreAdminClient.createIndexOperationCallable().futureCall(request);
-   *   // Do something
+   *   CreateIndexRequest request =
+   *       CreateIndexRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setIndex(Index.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.createIndexOperationCallable().futureCall(request);
+   *   // Do something.
    *   Index response = future.get();
    * }
-   * 
+ * }
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable createIndexOperationCallable() { return stub.createIndexOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a composite index. This returns a * [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the @@ -561,38 +315,39 @@ public final OperationFuture createIndexAsync( * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   Index index = Index.newBuilder().build();
-   *   CreateIndexRequest request = CreateIndexRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setIndex(index)
-   *     .build();
-   *   ApiFuture<Operation> future = firestoreAdminClient.createIndexCallable().futureCall(request);
-   *   // Do something
+   *   CreateIndexRequest request =
+   *       CreateIndexRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setIndex(Index.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.createIndexCallable().futureCall(request);
+   *   // Do something.
    *   Operation response = future.get();
    * }
-   * 
+ * }
*/ public final UnaryCallable createIndexCallable() { return stub.createIndexCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists composite indexes. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
+   *   CollectionGroupName parent =
+   *       CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
    *   for (Index element : firestoreAdminClient.listIndexes(parent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
-   * 
+ * }
* * @param parent Required. A parent name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` @@ -606,20 +361,20 @@ public final ListIndexesPagedResponse listIndexes(CollectionGroupName parent) { return listIndexes(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists composite indexes. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   for (Index element : firestoreAdminClient.listIndexes(parent.toString()).iterateAll()) {
+   *   String parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString();
+   *   for (Index element : firestoreAdminClient.listIndexes(parent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
-   * 
+ * }
* * @param parent Required. A parent name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` @@ -630,23 +385,27 @@ public final ListIndexesPagedResponse listIndexes(String parent) { return listIndexes(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists composite indexes. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   ListIndexesRequest request = ListIndexesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
+   *   ListIndexesRequest request =
+   *       ListIndexesRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
    *   for (Index element : firestoreAdminClient.listIndexes(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 @@ -655,46 +414,54 @@ public final ListIndexesPagedResponse listIndexes(ListIndexesRequest request) { return listIndexesPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists composite indexes. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   ListIndexesRequest request = ListIndexesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListIndexesPagedResponse> future = firestoreAdminClient.listIndexesPagedCallable().futureCall(request);
-   *   // Do something
+   *   ListIndexesRequest request =
+   *       ListIndexesRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.listIndexesPagedCallable().futureCall(request);
+   *   // Do something.
    *   for (Index element : future.get().iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
-   * 
+ * }
*/ public final UnaryCallable listIndexesPagedCallable() { return stub.listIndexesPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists composite indexes. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   ListIndexesRequest request = ListIndexesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
+   *   ListIndexesRequest request =
+   *       ListIndexesRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
    *   while (true) {
    *     ListIndexesResponse response = firestoreAdminClient.listIndexesCallable().call(request);
-   *     for (Index element : response.getIndexesList()) {
+   *     for (Index element : response.getResponsesList()) {
    *       // doThingsWith(element);
    *     }
    *     String nextPageToken = response.getNextPageToken();
@@ -705,24 +472,24 @@ public final ListIndexesPagedResponse listIndexes(ListIndexesRequest request) {
    *     }
    *   }
    * }
-   * 
+ * }
*/ public final UnaryCallable listIndexesCallable() { return stub.listIndexesCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a composite index. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
    *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
    *   Index response = firestoreAdminClient.getIndex(name);
    * }
-   * 
+ * }
* * @param name Required. A name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` @@ -734,18 +501,18 @@ public final Index getIndex(IndexName name) { return getIndex(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a composite index. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
-   *   Index response = firestoreAdminClient.getIndex(name.toString());
+   *   String name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString();
+   *   Index response = firestoreAdminClient.getIndex(name);
    * }
-   * 
+ * }
* * @param name Required. A name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` @@ -756,21 +523,22 @@ public final Index getIndex(String name) { return getIndex(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a composite index. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
-   *   GetIndexRequest request = GetIndexRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
+   *   GetIndexRequest request =
+   *       GetIndexRequest.newBuilder()
+   *           .setName(
+   *               IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString())
+   *           .build();
    *   Index response = firestoreAdminClient.getIndex(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 @@ -779,40 +547,133 @@ public final Index getIndex(GetIndexRequest request) { return getIndexCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a composite index. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
-   *   GetIndexRequest request = GetIndexRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Index> future = firestoreAdminClient.getIndexCallable().futureCall(request);
-   *   // Do something
+   *   GetIndexRequest request =
+   *       GetIndexRequest.newBuilder()
+   *           .setName(
+   *               IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.getIndexCallable().futureCall(request);
+   *   // Do something.
    *   Index response = future.get();
    * }
-   * 
+ * }
*/ public final UnaryCallable getIndexCallable() { return stub.getIndexCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a composite index. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
+   *   firestoreAdminClient.deleteIndex(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteIndex(IndexName name) { + DeleteIndexRequest request = + DeleteIndexRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteIndex(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a composite index. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString();
+   *   firestoreAdminClient.deleteIndex(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteIndex(String name) { + DeleteIndexRequest request = DeleteIndexRequest.newBuilder().setName(name).build(); + deleteIndex(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a composite index. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteIndexRequest request =
+   *       DeleteIndexRequest.newBuilder()
+   *           .setName(
+   *               IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString())
+   *           .build();
+   *   firestoreAdminClient.deleteIndex(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 deleteIndex(DeleteIndexRequest request) { + deleteIndexCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a composite index. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteIndexRequest request =
+   *       DeleteIndexRequest.newBuilder()
+   *           .setName(
+   *               IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.deleteIndexCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteIndexCallable() { + return stub.deleteIndexCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the metadata and configuration for a Field. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
    *   FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]");
    *   Field response = firestoreAdminClient.getField(name);
    * }
-   * 
+ * }
* * @param name Required. A name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` @@ -824,18 +685,18 @@ public final Field getField(FieldName name) { return getField(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the metadata and configuration for a Field. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]");
-   *   Field response = firestoreAdminClient.getField(name.toString());
+   *   String name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString();
+   *   Field response = firestoreAdminClient.getField(name);
    * }
-   * 
+ * }
* * @param name Required. A name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` @@ -846,21 +707,22 @@ public final Field getField(String name) { return getField(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the metadata and configuration for a Field. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]");
-   *   GetFieldRequest request = GetFieldRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
+   *   GetFieldRequest request =
+   *       GetFieldRequest.newBuilder()
+   *           .setName(
+   *               FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString())
+   *           .build();
    *   Field response = firestoreAdminClient.getField(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 @@ -869,29 +731,172 @@ public final Field getField(GetFieldRequest request) { return getFieldCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the metadata and configuration for a Field. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]");
-   *   GetFieldRequest request = GetFieldRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Field> future = firestoreAdminClient.getFieldCallable().futureCall(request);
-   *   // Do something
+   *   GetFieldRequest request =
+   *       GetFieldRequest.newBuilder()
+   *           .setName(
+   *               FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.getFieldCallable().futureCall(request);
+   *   // Do something.
    *   Field response = future.get();
    * }
-   * 
+ * }
*/ public final UnaryCallable getFieldCallable() { return stub.getFieldCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a field configuration. Currently, field updates apply only to single field index + * configuration. However, calls to + * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should + * provide a field mask to avoid changing any configuration that the caller isn't aware of. The + * field mask should be specified as: `{ paths: "index_config" }`. + * + *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may + * be used to track the status of the field update. The metadata for the operation will be the + * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + * + *

To configure the default field settings for the database, use the special `Field` with + * resource name: + * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   Field field = Field.newBuilder().build();
+   *   Field response = firestoreAdminClient.updateFieldAsync(field).get();
+   * }
+   * }
+ * + * @param field Required. The field to be updated. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture updateFieldAsync(Field field) { + UpdateFieldRequest request = UpdateFieldRequest.newBuilder().setField(field).build(); + return updateFieldAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a field configuration. Currently, field updates apply only to single field index + * configuration. However, calls to + * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should + * provide a field mask to avoid changing any configuration that the caller isn't aware of. The + * field mask should be specified as: `{ paths: "index_config" }`. + * + *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may + * be used to track the status of the field update. The metadata for the operation will be the + * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + * + *

To configure the default field settings for the database, use the special `Field` with + * resource name: + * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateFieldRequest request =
+   *       UpdateFieldRequest.newBuilder()
+   *           .setField(Field.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Field response = firestoreAdminClient.updateFieldAsync(request).get();
+   * }
+   * }
+ * + * @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 OperationFuture updateFieldAsync( + UpdateFieldRequest request) { + return updateFieldOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a field configuration. Currently, field updates apply only to single field index + * configuration. However, calls to + * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should + * provide a field mask to avoid changing any configuration that the caller isn't aware of. The + * field mask should be specified as: `{ paths: "index_config" }`. + * + *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may + * be used to track the status of the field update. The metadata for the operation will be the + * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + * + *

To configure the default field settings for the database, use the special `Field` with + * resource name: + * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateFieldRequest request =
+   *       UpdateFieldRequest.newBuilder()
+   *           .setField(Field.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.updateFieldOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Field response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + updateFieldOperationCallable() { + return stub.updateFieldOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a field configuration. Currently, field updates apply only to single field index + * configuration. However, calls to + * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should + * provide a field mask to avoid changing any configuration that the caller isn't aware of. The + * field mask should be specified as: `{ paths: "index_config" }`. + * + *

This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may + * be used to track the status of the field update. The metadata for the operation will be the + * type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + * + *

To configure the default field settings for the database, use the special `Field` with + * resource name: + * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + * + *

Sample code: + * + *

{@code
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateFieldRequest request =
+   *       UpdateFieldRequest.newBuilder()
+   *           .setField(Field.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.updateFieldCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable updateFieldCallable() { + return stub.updateFieldCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the field configuration and metadata for this database. * @@ -902,14 +907,15 @@ public final UnaryCallable getFieldCallable() { * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
+   *   CollectionGroupName parent =
+   *       CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
    *   for (Field element : firestoreAdminClient.listFields(parent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
-   * 
+ * }
* * @param parent Required. A parent name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` @@ -921,7 +927,7 @@ public final ListFieldsPagedResponse listFields(CollectionGroupName parent) { return listFields(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the field configuration and metadata for this database. * @@ -932,14 +938,14 @@ public final ListFieldsPagedResponse listFields(CollectionGroupName parent) { * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   for (Field element : firestoreAdminClient.listFields(parent.toString()).iterateAll()) {
+   *   String parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString();
+   *   for (Field element : firestoreAdminClient.listFields(parent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
-   * 
+ * }
* * @param parent Required. A parent name of the form * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` @@ -950,7 +956,7 @@ public final ListFieldsPagedResponse listFields(String parent) { return listFields(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the field configuration and metadata for this database. * @@ -961,17 +967,21 @@ public final ListFieldsPagedResponse listFields(String parent) { * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   ListFieldsRequest request = ListFieldsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
+   *   ListFieldsRequest request =
+   *       ListFieldsRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
    *   for (Field element : firestoreAdminClient.listFields(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 @@ -980,7 +990,7 @@ public final ListFieldsPagedResponse listFields(ListFieldsRequest request) { return listFieldsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the field configuration and metadata for this database. * @@ -991,25 +1001,29 @@ public final ListFieldsPagedResponse listFields(ListFieldsRequest request) { * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   ListFieldsRequest request = ListFieldsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListFieldsPagedResponse> future = firestoreAdminClient.listFieldsPagedCallable().futureCall(request);
-   *   // Do something
+   *   ListFieldsRequest request =
+   *       ListFieldsRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.listFieldsPagedCallable().futureCall(request);
+   *   // Do something.
    *   for (Field element : future.get().iterateAll()) {
    *     // doThingsWith(element);
    *   }
    * }
-   * 
+ * }
*/ public final UnaryCallable listFieldsPagedCallable() { return stub.listFieldsPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the field configuration and metadata for this database. * @@ -1020,15 +1034,19 @@ public final UnaryCallable listField * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
-   *   ListFieldsRequest request = ListFieldsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
+   *   ListFieldsRequest request =
+   *       ListFieldsRequest.newBuilder()
+   *           .setParent(
+   *               CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
    *   while (true) {
    *     ListFieldsResponse response = firestoreAdminClient.listFieldsCallable().call(request);
-   *     for (Field element : response.getFieldsList()) {
+   *     for (Field element : response.getResponsesList()) {
    *       // doThingsWith(element);
    *     }
    *     String nextPageToken = response.getNextPageToken();
@@ -1039,13 +1057,13 @@ public final UnaryCallable listField
    *     }
    *   }
    * }
-   * 
+ * }
*/ public final UnaryCallable listFieldsCallable() { return stub.listFieldsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage * system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the @@ -1056,19 +1074,17 @@ public final UnaryCallable listFieldsCall * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
    *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
    *   ExportDocumentsResponse response = firestoreAdminClient.exportDocumentsAsync(name).get();
    * }
-   * 
+ * }
* * @param name Required. Database to export. Should be of the form: * `projects/{project_id}/databases/{database_id}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture exportDocumentsAsync(DatabaseName name) { ExportDocumentsRequest request = @@ -1076,7 +1092,7 @@ public final UnaryCallable listFieldsCall return exportDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage * system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the @@ -1087,26 +1103,24 @@ public final UnaryCallable listFieldsCall * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   ExportDocumentsResponse response = firestoreAdminClient.exportDocumentsAsync(name.toString()).get();
+   *   String name = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   ExportDocumentsResponse response = firestoreAdminClient.exportDocumentsAsync(name).get();
    * }
-   * 
+ * }
* * @param name Required. Database to export. Should be of the form: * `projects/{project_id}/databases/{database_id}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture exportDocumentsAsync(String name) { ExportDocumentsRequest request = ExportDocumentsRequest.newBuilder().setName(name).build(); return exportDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage * system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the @@ -1117,27 +1131,27 @@ public final UnaryCallable listFieldsCall * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   ExportDocumentsRequest request = ExportDocumentsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
+   *   ExportDocumentsRequest request =
+   *       ExportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setOutputUriPrefix("outputUriPrefix499858205")
+   *           .build();
    *   ExportDocumentsResponse response = firestoreAdminClient.exportDocumentsAsync(request).get();
    * }
-   * 
+ * }
* * @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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture exportDocumentsAsync(ExportDocumentsRequest request) { return exportDocumentsOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage * system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the @@ -1148,26 +1162,28 @@ public final UnaryCallable listFieldsCall * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   ExportDocumentsRequest request = ExportDocumentsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   OperationFuture<ExportDocumentsResponse, ExportDocumentsMetadata> future = firestoreAdminClient.exportDocumentsOperationCallable().futureCall(request);
-   *   // Do something
+   *   ExportDocumentsRequest request =
+   *       ExportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setOutputUriPrefix("outputUriPrefix499858205")
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.exportDocumentsOperationCallable().futureCall(request);
+   *   // Do something.
    *   ExportDocumentsResponse response = future.get();
    * }
-   * 
+ * }
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable< ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> exportDocumentsOperationCallable() { return stub.exportDocumentsOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage * system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the @@ -1178,23 +1194,26 @@ public final UnaryCallable listFieldsCall * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   ExportDocumentsRequest request = ExportDocumentsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Operation> future = firestoreAdminClient.exportDocumentsCallable().futureCall(request);
-   *   // Do something
+   *   ExportDocumentsRequest request =
+   *       ExportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setOutputUriPrefix("outputUriPrefix499858205")
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.exportDocumentsCallable().futureCall(request);
+   *   // Do something.
    *   Operation response = future.get();
    * }
-   * 
+ * }
*/ public final UnaryCallable exportDocumentsCallable() { return stub.exportDocumentsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Imports documents into Google Cloud Firestore. Existing documents with the same name are * overwritten. The import occurs in the background and its progress can be monitored and managed @@ -1203,19 +1222,17 @@ public final UnaryCallable exportDocumentsCal * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
    *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
    *   firestoreAdminClient.importDocumentsAsync(name).get();
    * }
-   * 
+ * }
* * @param name Required. Database to import into. Should be of the form: * `projects/{project_id}/databases/{database_id}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture importDocumentsAsync( DatabaseName name) { ImportDocumentsRequest request = @@ -1223,7 +1240,7 @@ public final OperationFuture importDocumentsAsyn return importDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Imports documents into Google Cloud Firestore. Existing documents with the same name are * overwritten. The import occurs in the background and its progress can be monitored and managed @@ -1232,25 +1249,23 @@ public final OperationFuture importDocumentsAsyn * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   firestoreAdminClient.importDocumentsAsync(name.toString()).get();
+   *   String name = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   firestoreAdminClient.importDocumentsAsync(name).get();
    * }
-   * 
+ * }
* * @param name Required. Database to import into. Should be of the form: * `projects/{project_id}/databases/{database_id}`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture importDocumentsAsync(String name) { ImportDocumentsRequest request = ImportDocumentsRequest.newBuilder().setName(name).build(); return importDocumentsAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Imports documents into Google Cloud Firestore. Existing documents with the same name are * overwritten. The import occurs in the background and its progress can be monitored and managed @@ -1259,27 +1274,27 @@ public final OperationFuture importDocumentsAsyn * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   ImportDocumentsRequest request = ImportDocumentsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
+   *   ImportDocumentsRequest request =
+   *       ImportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setInputUriPrefix("inputUriPrefix-97481100")
+   *           .build();
    *   firestoreAdminClient.importDocumentsAsync(request).get();
    * }
-   * 
+ * }
* * @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 */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture importDocumentsAsync( ImportDocumentsRequest request) { return importDocumentsOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Imports documents into Google Cloud Firestore. Existing documents with the same name are * overwritten. The import occurs in the background and its progress can be monitored and managed @@ -1288,25 +1303,27 @@ public final OperationFuture importDocumentsAsyn * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   ImportDocumentsRequest request = ImportDocumentsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   OperationFuture<Empty, ImportDocumentsMetadata> future = firestoreAdminClient.importDocumentsOperationCallable().futureCall(request);
-   *   // Do something
+   *   ImportDocumentsRequest request =
+   *       ImportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setInputUriPrefix("inputUriPrefix-97481100")
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.importDocumentsOperationCallable().futureCall(request);
+   *   // Do something.
    *   future.get();
    * }
-   * 
+ * }
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable importDocumentsOperationCallable() { return stub.importDocumentsOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Imports documents into Google Cloud Firestore. Existing documents with the same name are * overwritten. The import occurs in the background and its progress can be monitored and managed @@ -1315,17 +1332,20 @@ public final OperationFuture importDocumentsAsyn * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
-   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
-   *   ImportDocumentsRequest request = ImportDocumentsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Operation> future = firestoreAdminClient.importDocumentsCallable().futureCall(request);
-   *   // Do something
+   *   ImportDocumentsRequest request =
+   *       ImportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setInputUriPrefix("inputUriPrefix-97481100")
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.importDocumentsCallable().futureCall(request);
+   *   // Do something.
    *   future.get();
    * }
-   * 
+ * }
*/ public final UnaryCallable importDocumentsCallable() { return stub.importDocumentsCallable(); diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java index 0f295bac1..3a101473c 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1; import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; @@ -55,7 +56,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link FirestoreAdminClient}. * @@ -70,42 +71,25 @@ *

The builder of this class is recursive, so contained classes are themselves builders. When * build() is called, the tree of builders is called to create the complete settings object. * - *

For example, to set the total timeout of deleteIndex to 30 seconds: + *

For example, to set the total timeout of getIndex to 30 seconds: * - *

- * 
+ * 
{@code
  * FirestoreAdminSettings.Builder firestoreAdminSettingsBuilder =
  *     FirestoreAdminSettings.newBuilder();
  * firestoreAdminSettingsBuilder
- *     .deleteIndexSettings()
+ *     .getIndexSettings()
  *     .setRetrySettings(
- *         firestoreAdminSettingsBuilder.deleteIndexSettings().getRetrySettings().toBuilder()
+ *         firestoreAdminSettingsBuilder
+ *             .getIndexSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * FirestoreAdminSettings firestoreAdminSettings = firestoreAdminSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class FirestoreAdminSettings extends ClientSettings { - /** Returns the object with the settings used for calls to deleteIndex. */ - public UnaryCallSettings deleteIndexSettings() { - return ((FirestoreAdminStubSettings) getStubSettings()).deleteIndexSettings(); - } - - /** Returns the object with the settings used for calls to updateField. */ - public UnaryCallSettings updateFieldSettings() { - return ((FirestoreAdminStubSettings) getStubSettings()).updateFieldSettings(); - } - - /** Returns the object with the settings used for calls to updateField. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings - updateFieldOperationSettings() { - return ((FirestoreAdminStubSettings) getStubSettings()).updateFieldOperationSettings(); - } /** Returns the object with the settings used for calls to createIndex. */ public UnaryCallSettings createIndexSettings() { @@ -113,8 +97,6 @@ public UnaryCallSettings createIndexSettings() { } /** Returns the object with the settings used for calls to createIndex. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings createIndexOperationSettings() { return ((FirestoreAdminStubSettings) getStubSettings()).createIndexOperationSettings(); @@ -131,11 +113,27 @@ public UnaryCallSettings getIndexSettings() { return ((FirestoreAdminStubSettings) getStubSettings()).getIndexSettings(); } + /** Returns the object with the settings used for calls to deleteIndex. */ + public UnaryCallSettings deleteIndexSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteIndexSettings(); + } + /** Returns the object with the settings used for calls to getField. */ public UnaryCallSettings getFieldSettings() { return ((FirestoreAdminStubSettings) getStubSettings()).getFieldSettings(); } + /** Returns the object with the settings used for calls to updateField. */ + public UnaryCallSettings updateFieldSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).updateFieldSettings(); + } + + /** Returns the object with the settings used for calls to updateField. */ + public OperationCallSettings + updateFieldOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).updateFieldOperationSettings(); + } + /** Returns the object with the settings used for calls to listFields. */ public PagedCallSettings listFieldsSettings() { @@ -148,8 +146,6 @@ public UnaryCallSettings exportDocumentsSetti } /** Returns the object with the settings used for calls to exportDocuments. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings< ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> exportDocumentsOperationSettings() { @@ -162,8 +158,6 @@ public UnaryCallSettings importDocumentsSetti } /** Returns the object with the settings used for calls to importDocuments. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings importDocumentsOperationSettings() { return ((FirestoreAdminStubSettings) getStubSettings()).importDocumentsOperationSettings(); @@ -229,18 +223,15 @@ protected FirestoreAdminSettings(Builder settingsBuilder) throws IOException { /** Builder for FirestoreAdminSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(FirestoreAdminStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(FirestoreAdminStubSettings.newBuilder()); - } - protected Builder(FirestoreAdminSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -249,11 +240,15 @@ protected Builder(FirestoreAdminStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(FirestoreAdminStubSettings.newBuilder()); + } + public FirestoreAdminStubSettings.Builder getStubSettingsBuilder() { return ((FirestoreAdminStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -266,32 +261,12 @@ public Builder applyToAllUnaryMethods( return this; } - /** Returns the builder for the settings used for calls to deleteIndex. */ - public UnaryCallSettings.Builder deleteIndexSettings() { - return getStubSettingsBuilder().deleteIndexSettings(); - } - - /** Returns the builder for the settings used for calls to updateField. */ - public UnaryCallSettings.Builder updateFieldSettings() { - return getStubSettingsBuilder().updateFieldSettings(); - } - - /** Returns the builder for the settings used for calls to updateField. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - public OperationCallSettings.Builder - updateFieldOperationSettings() { - return getStubSettingsBuilder().updateFieldOperationSettings(); - } - /** Returns the builder for the settings used for calls to createIndex. */ public UnaryCallSettings.Builder createIndexSettings() { return getStubSettingsBuilder().createIndexSettings(); } /** Returns the builder for the settings used for calls to createIndex. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder createIndexOperationSettings() { return getStubSettingsBuilder().createIndexOperationSettings(); @@ -309,11 +284,27 @@ public UnaryCallSettings.Builder getIndexSettings() { return getStubSettingsBuilder().getIndexSettings(); } + /** Returns the builder for the settings used for calls to deleteIndex. */ + public UnaryCallSettings.Builder deleteIndexSettings() { + return getStubSettingsBuilder().deleteIndexSettings(); + } + /** Returns the builder for the settings used for calls to getField. */ public UnaryCallSettings.Builder getFieldSettings() { return getStubSettingsBuilder().getFieldSettings(); } + /** Returns the builder for the settings used for calls to updateField. */ + public UnaryCallSettings.Builder updateFieldSettings() { + return getStubSettingsBuilder().updateFieldSettings(); + } + + /** Returns the builder for the settings used for calls to updateField. */ + public OperationCallSettings.Builder + updateFieldOperationSettings() { + return getStubSettingsBuilder().updateFieldOperationSettings(); + } + /** Returns the builder for the settings used for calls to listFields. */ public PagedCallSettings.Builder listFieldsSettings() { @@ -326,8 +317,6 @@ public UnaryCallSettings.Builder exportDocume } /** Returns the builder for the settings used for calls to exportDocuments. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder< ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> exportDocumentsOperationSettings() { @@ -340,8 +329,6 @@ public UnaryCallSettings.Builder importDocume } /** Returns the builder for the settings used for calls to importDocuments. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder importDocumentsOperationSettings() { return getStubSettingsBuilder().importDocumentsOperationSettings(); diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json new file mode 100644 index 000000000..8feb86fd9 --- /dev/null +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json @@ -0,0 +1,45 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.firestore.admin.v1", + "libraryPackage": "com.google.cloud.firestore.v1", + "services": { + "FirestoreAdmin": { + "clients": { + "grpc": { + "libraryClient": "FirestoreAdminClient", + "rpcs": { + "CreateIndex": { + "methods": ["createIndexAsync", "createIndexAsync", "createIndexAsync", "createIndexOperationCallable", "createIndexCallable"] + }, + "DeleteIndex": { + "methods": ["deleteIndex", "deleteIndex", "deleteIndex", "deleteIndexCallable"] + }, + "ExportDocuments": { + "methods": ["exportDocumentsAsync", "exportDocumentsAsync", "exportDocumentsAsync", "exportDocumentsOperationCallable", "exportDocumentsCallable"] + }, + "GetField": { + "methods": ["getField", "getField", "getField", "getFieldCallable"] + }, + "GetIndex": { + "methods": ["getIndex", "getIndex", "getIndex", "getIndexCallable"] + }, + "ImportDocuments": { + "methods": ["importDocumentsAsync", "importDocumentsAsync", "importDocumentsAsync", "importDocumentsOperationCallable", "importDocumentsCallable"] + }, + "ListFields": { + "methods": ["listFields", "listFields", "listFields", "listFieldsPagedCallable", "listFieldsCallable"] + }, + "ListIndexes": { + "methods": ["listIndexes", "listIndexes", "listIndexes", "listIndexesPagedCallable", "listIndexesCallable"] + }, + "UpdateField": { + "methods": ["updateFieldAsync", "updateFieldAsync", "updateFieldOperationCallable", "updateFieldCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java index 3b9c59cb7..8eee824d3 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -15,27 +15,23 @@ */ /** - * A client to Google Cloud Firestore Admin API. + * The interfaces provided are listed below, along with usage samples. * - *

The interfaces provided are listed below, along with usage samples. - * - *

==================== FirestoreAdminClient ==================== + *

======================= FirestoreAdminClient ======================= * *

Service Description: Operations are created by service `FirestoreAdmin`, but are accessed via * service `google.longrunning.Operations`. * *

Sample for FirestoreAdminClient: * - *

- * 
+ * 
{@code
  * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
  *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
- *   firestoreAdminClient.deleteIndex(name);
+ *   Index response = firestoreAdminClient.getIndex(name);
  * }
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.firestore.v1; import javax.annotation.Generated; diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java index 579adc2c3..03764d639 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; @@ -45,36 +45,19 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Google Cloud Firestore Admin API. + * Base stub class for the FirestoreAdmin service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public abstract class FirestoreAdminStub implements BackgroundResource { - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationsStub getOperationsStub() { throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); } - public UnaryCallable deleteIndexCallable() { - throw new UnsupportedOperationException("Not implemented: deleteIndexCallable()"); - } - - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - updateFieldOperationCallable() { - throw new UnsupportedOperationException("Not implemented: updateFieldOperationCallable()"); - } - - public UnaryCallable updateFieldCallable() { - throw new UnsupportedOperationException("Not implemented: updateFieldCallable()"); - } - - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable createIndexOperationCallable() { throw new UnsupportedOperationException("Not implemented: createIndexOperationCallable()"); @@ -96,10 +79,23 @@ public UnaryCallable getIndexCallable() { throw new UnsupportedOperationException("Not implemented: getIndexCallable()"); } + public UnaryCallable deleteIndexCallable() { + throw new UnsupportedOperationException("Not implemented: deleteIndexCallable()"); + } + public UnaryCallable getFieldCallable() { throw new UnsupportedOperationException("Not implemented: getFieldCallable()"); } + public OperationCallable + updateFieldOperationCallable() { + throw new UnsupportedOperationException("Not implemented: updateFieldOperationCallable()"); + } + + public UnaryCallable updateFieldCallable() { + throw new UnsupportedOperationException("Not implemented: updateFieldCallable()"); + } + public UnaryCallable listFieldsPagedCallable() { throw new UnsupportedOperationException("Not implemented: listFieldsPagedCallable()"); } @@ -108,7 +104,6 @@ public UnaryCallable listFieldsCallable() throw new UnsupportedOperationException("Not implemented: listFieldsCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable exportDocumentsOperationCallable() { throw new UnsupportedOperationException("Not implemented: exportDocumentsOperationCallable()"); @@ -118,7 +113,6 @@ public UnaryCallable exportDocumentsCallable( throw new UnsupportedOperationException("Not implemented: exportDocumentsCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable importDocumentsOperationCallable() { throw new UnsupportedOperationException("Not implemented: importDocumentsOperationCallable()"); diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java index e681e64fb..ae1dbe22f 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; @@ -73,7 +74,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link FirestoreAdminStub}. * @@ -88,24 +89,24 @@ *

The builder of this class is recursive, so contained classes are themselves builders. When * build() is called, the tree of builders is called to create the complete settings object. * - *

For example, to set the total timeout of deleteIndex to 30 seconds: + *

For example, to set the total timeout of getIndex to 30 seconds: * - *

- * 
+ * 
{@code
  * FirestoreAdminStubSettings.Builder firestoreAdminSettingsBuilder =
  *     FirestoreAdminStubSettings.newBuilder();
  * firestoreAdminSettingsBuilder
- *     .deleteIndexSettings()
+ *     .getIndexSettings()
  *     .setRetrySettings(
- *         firestoreAdminSettingsBuilder.deleteIndexSettings().getRetrySettings().toBuilder()
+ *         firestoreAdminSettingsBuilder
+ *             .getIndexSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * FirestoreAdminStubSettings firestoreAdminSettings = firestoreAdminSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class FirestoreAdminStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -114,17 +115,17 @@ public class FirestoreAdminStubSettings extends StubSettings deleteIndexSettings; - private final UnaryCallSettings updateFieldSettings; - private final OperationCallSettings - updateFieldOperationSettings; private final UnaryCallSettings createIndexSettings; private final OperationCallSettings createIndexOperationSettings; private final PagedCallSettings listIndexesSettings; private final UnaryCallSettings getIndexSettings; + private final UnaryCallSettings deleteIndexSettings; private final UnaryCallSettings getFieldSettings; + private final UnaryCallSettings updateFieldSettings; + private final OperationCallSettings + updateFieldOperationSettings; private final PagedCallSettings listFieldsSettings; private final UnaryCallSettings exportDocumentsSettings; @@ -135,22 +136,111 @@ public class FirestoreAdminStubSettings extends StubSettings importDocumentsOperationSettings; - /** Returns the object with the settings used for calls to deleteIndex. */ - public UnaryCallSettings deleteIndexSettings() { - return deleteIndexSettings; - } + private static final PagedListDescriptor + LIST_INDEXES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } - /** Returns the object with the settings used for calls to updateField. */ - public UnaryCallSettings updateFieldSettings() { - return updateFieldSettings; - } + @Override + public ListIndexesRequest injectToken(ListIndexesRequest payload, String token) { + return ListIndexesRequest.newBuilder(payload).setPageToken(token).build(); + } - /** Returns the object with the settings used for calls to updateField. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings - updateFieldOperationSettings() { - return updateFieldOperationSettings; - } + @Override + public ListIndexesRequest injectPageSize(ListIndexesRequest payload, int pageSize) { + return ListIndexesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListIndexesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListIndexesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListIndexesResponse payload) { + return payload.getIndexesList() == null + ? ImmutableList.of() + : payload.getIndexesList(); + } + }; + + private static final PagedListDescriptor + LIST_FIELDS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListFieldsRequest injectToken(ListFieldsRequest payload, String token) { + return ListFieldsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListFieldsRequest injectPageSize(ListFieldsRequest payload, int pageSize) { + return ListFieldsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListFieldsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListFieldsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListFieldsResponse payload) { + return payload.getFieldsList() == null + ? ImmutableList.of() + : payload.getFieldsList(); + } + }; + + private static final PagedListResponseFactory< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> + LIST_INDEXES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListIndexesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_INDEXES_PAGE_STR_DESC, request, context); + return ListIndexesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListFieldsRequest, ListFieldsResponse, ListFieldsPagedResponse> + LIST_FIELDS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListFieldsRequest, ListFieldsResponse, ListFieldsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListFieldsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_FIELDS_PAGE_STR_DESC, request, context); + return ListFieldsPagedResponse.createAsync(pageContext, futureResponse); + } + }; /** Returns the object with the settings used for calls to createIndex. */ public UnaryCallSettings createIndexSettings() { @@ -158,7 +248,6 @@ public UnaryCallSettings createIndexSettings() { } /** Returns the object with the settings used for calls to createIndex. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings createIndexOperationSettings() { return createIndexOperationSettings; @@ -175,11 +264,27 @@ public UnaryCallSettings getIndexSettings() { return getIndexSettings; } + /** Returns the object with the settings used for calls to deleteIndex. */ + public UnaryCallSettings deleteIndexSettings() { + return deleteIndexSettings; + } + /** Returns the object with the settings used for calls to getField. */ public UnaryCallSettings getFieldSettings() { return getFieldSettings; } + /** Returns the object with the settings used for calls to updateField. */ + public UnaryCallSettings updateFieldSettings() { + return updateFieldSettings; + } + + /** Returns the object with the settings used for calls to updateField. */ + public OperationCallSettings + updateFieldOperationSettings() { + return updateFieldOperationSettings; + } + /** Returns the object with the settings used for calls to listFields. */ public PagedCallSettings listFieldsSettings() { @@ -192,7 +297,6 @@ public UnaryCallSettings exportDocumentsSetti } /** Returns the object with the settings used for calls to exportDocuments. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings< ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> exportDocumentsOperationSettings() { @@ -205,7 +309,6 @@ public UnaryCallSettings importDocumentsSetti } /** Returns the object with the settings used for calls to importDocuments. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings importDocumentsOperationSettings() { return importDocumentsOperationSettings; @@ -217,10 +320,10 @@ public FirestoreAdminStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcFirestoreAdminStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -280,14 +383,14 @@ public Builder toBuilder() { protected FirestoreAdminStubSettings(Builder settingsBuilder) throws IOException { super(settingsBuilder); - deleteIndexSettings = settingsBuilder.deleteIndexSettings().build(); - updateFieldSettings = settingsBuilder.updateFieldSettings().build(); - updateFieldOperationSettings = settingsBuilder.updateFieldOperationSettings().build(); createIndexSettings = settingsBuilder.createIndexSettings().build(); createIndexOperationSettings = settingsBuilder.createIndexOperationSettings().build(); listIndexesSettings = settingsBuilder.listIndexesSettings().build(); getIndexSettings = settingsBuilder.getIndexSettings().build(); + deleteIndexSettings = settingsBuilder.deleteIndexSettings().build(); getFieldSettings = settingsBuilder.getFieldSettings().build(); + updateFieldSettings = settingsBuilder.updateFieldSettings().build(); + updateFieldOperationSettings = settingsBuilder.updateFieldOperationSettings().build(); listFieldsSettings = settingsBuilder.listFieldsSettings().build(); exportDocumentsSettings = settingsBuilder.exportDocumentsSettings().build(); exportDocumentsOperationSettings = settingsBuilder.exportDocumentsOperationSettings().build(); @@ -295,120 +398,9 @@ protected FirestoreAdminStubSettings(Builder settingsBuilder) throws IOException importDocumentsOperationSettings = settingsBuilder.importDocumentsOperationSettings().build(); } - private static final PagedListDescriptor - LIST_INDEXES_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListIndexesRequest injectToken(ListIndexesRequest payload, String token) { - return ListIndexesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListIndexesRequest injectPageSize(ListIndexesRequest payload, int pageSize) { - return ListIndexesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListIndexesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListIndexesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListIndexesResponse payload) { - return payload.getIndexesList() != null - ? payload.getIndexesList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor - LIST_FIELDS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListFieldsRequest injectToken(ListFieldsRequest payload, String token) { - return ListFieldsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListFieldsRequest injectPageSize(ListFieldsRequest payload, int pageSize) { - return ListFieldsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListFieldsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListFieldsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListFieldsResponse payload) { - return payload.getFieldsList() != null - ? payload.getFieldsList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> - LIST_INDEXES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListIndexesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_INDEXES_PAGE_STR_DESC, request, context); - return ListIndexesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListFieldsRequest, ListFieldsResponse, ListFieldsPagedResponse> - LIST_FIELDS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListFieldsRequest, ListFieldsResponse, ListFieldsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListFieldsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_FIELDS_PAGE_STR_DESC, request, context); - return ListFieldsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - /** Builder for FirestoreAdminStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - - private final UnaryCallSettings.Builder deleteIndexSettings; - private final UnaryCallSettings.Builder updateFieldSettings; - private final OperationCallSettings.Builder - updateFieldOperationSettings; private final UnaryCallSettings.Builder createIndexSettings; private final OperationCallSettings.Builder createIndexOperationSettings; @@ -416,7 +408,11 @@ public static class Builder extends StubSettings.Builder listIndexesSettings; private final UnaryCallSettings.Builder getIndexSettings; + private final UnaryCallSettings.Builder deleteIndexSettings; private final UnaryCallSettings.Builder getFieldSettings; + private final UnaryCallSettings.Builder updateFieldSettings; + private final OperationCallSettings.Builder + updateFieldOperationSettings; private final PagedCallSettings.Builder< ListFieldsRequest, ListFieldsResponse, ListFieldsPagedResponse> listFieldsSettings; @@ -430,7 +426,6 @@ public static class Builder extends StubSettings.Builder importDocumentsOperationSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -438,18 +433,14 @@ public static class Builder extends StubSettings.Builder> definitions = ImmutableMap.builder(); definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, - StatusCode.Code.INTERNAL, - StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put( - "idempotent2", + "retry_policy_0_codes", ImmutableSet.copyOf( Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + StatusCode.Code.UNAVAILABLE, + StatusCode.Code.INTERNAL, + StatusCode.Code.DEADLINE_EXCEEDED))); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -458,6 +449,14 @@ public static class Builder extends StubSettings.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("no_retry_1_params", settings); settings = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(100L)) @@ -466,166 +465,187 @@ public static class Builder extends StubSettings.Builder>of( + createIndexSettings, + listIndexesSettings, + getIndexSettings, deleteIndexSettings, + getFieldSettings, updateFieldSettings, + listFieldsSettings, + exportDocumentsSettings, + importDocumentsSettings); + initDefaults(this); + } + + protected Builder(FirestoreAdminStubSettings settings) { + super(settings); + + createIndexSettings = settings.createIndexSettings.toBuilder(); + createIndexOperationSettings = settings.createIndexOperationSettings.toBuilder(); + listIndexesSettings = settings.listIndexesSettings.toBuilder(); + getIndexSettings = settings.getIndexSettings.toBuilder(); + deleteIndexSettings = settings.deleteIndexSettings.toBuilder(); + getFieldSettings = settings.getFieldSettings.toBuilder(); + updateFieldSettings = settings.updateFieldSettings.toBuilder(); + updateFieldOperationSettings = settings.updateFieldOperationSettings.toBuilder(); + listFieldsSettings = settings.listFieldsSettings.toBuilder(); + exportDocumentsSettings = settings.exportDocumentsSettings.toBuilder(); + exportDocumentsOperationSettings = settings.exportDocumentsOperationSettings.toBuilder(); + importDocumentsSettings = settings.importDocumentsSettings.toBuilder(); + importDocumentsOperationSettings = settings.importDocumentsOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( createIndexSettings, listIndexesSettings, getIndexSettings, + deleteIndexSettings, getFieldSettings, + updateFieldSettings, listFieldsSettings, exportDocumentsSettings, importDocumentsSettings); - - initDefaults(this); } private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); } private static Builder initDefaults(Builder builder) { - - builder - .deleteIndexSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateFieldSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - builder .createIndexSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder .listIndexesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .getIndexSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .deleteIndexSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .getFieldSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .updateFieldSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder .listFieldsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .exportDocumentsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder .importDocumentsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + builder - .updateFieldOperationSettings() + .createIndexOperationSettings() .setInitialCallSettings( - UnaryCallSettings.newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( - ProtoOperationTransformers.ResponseTransformer.create(Field.class)) + ProtoOperationTransformers.ResponseTransformer.create(Index.class)) .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(FieldOperationMetadata.class)) + ProtoOperationTransformers.MetadataTransformer.create(IndexOperationMetadata.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder - .createIndexOperationSettings() + .updateFieldOperationSettings() .setInitialCallSettings( - UnaryCallSettings.newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( - ProtoOperationTransformers.ResponseTransformer.create(Index.class)) + ProtoOperationTransformers.ResponseTransformer.create(Field.class)) .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(IndexOperationMetadata.class)) + ProtoOperationTransformers.MetadataTransformer.create(FieldOperationMetadata.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder .exportDocumentsOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(ExportDocumentsResponse.class)) @@ -634,21 +654,22 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder .importDocumentsOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")) .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) @@ -657,49 +678,19 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); return builder; } - protected Builder(FirestoreAdminStubSettings settings) { - super(settings); - - deleteIndexSettings = settings.deleteIndexSettings.toBuilder(); - updateFieldSettings = settings.updateFieldSettings.toBuilder(); - updateFieldOperationSettings = settings.updateFieldOperationSettings.toBuilder(); - createIndexSettings = settings.createIndexSettings.toBuilder(); - createIndexOperationSettings = settings.createIndexOperationSettings.toBuilder(); - listIndexesSettings = settings.listIndexesSettings.toBuilder(); - getIndexSettings = settings.getIndexSettings.toBuilder(); - getFieldSettings = settings.getFieldSettings.toBuilder(); - listFieldsSettings = settings.listFieldsSettings.toBuilder(); - exportDocumentsSettings = settings.exportDocumentsSettings.toBuilder(); - exportDocumentsOperationSettings = settings.exportDocumentsOperationSettings.toBuilder(); - importDocumentsSettings = settings.importDocumentsSettings.toBuilder(); - importDocumentsOperationSettings = settings.importDocumentsOperationSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - deleteIndexSettings, - updateFieldSettings, - createIndexSettings, - listIndexesSettings, - getIndexSettings, - getFieldSettings, - listFieldsSettings, - exportDocumentsSettings, - importDocumentsSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -715,24 +706,6 @@ public Builder applyToAllUnaryMethods( return unaryMethodSettingsBuilders; } - /** Returns the builder for the settings used for calls to deleteIndex. */ - public UnaryCallSettings.Builder deleteIndexSettings() { - return deleteIndexSettings; - } - - /** Returns the builder for the settings used for calls to updateField. */ - public UnaryCallSettings.Builder updateFieldSettings() { - return updateFieldSettings; - } - - /** Returns the builder for the settings used for calls to updateField. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder - updateFieldOperationSettings() { - return updateFieldOperationSettings; - } - /** Returns the builder for the settings used for calls to createIndex. */ public UnaryCallSettings.Builder createIndexSettings() { return createIndexSettings; @@ -758,11 +731,29 @@ public UnaryCallSettings.Builder getIndexSettings() { return getIndexSettings; } + /** Returns the builder for the settings used for calls to deleteIndex. */ + public UnaryCallSettings.Builder deleteIndexSettings() { + return deleteIndexSettings; + } + /** Returns the builder for the settings used for calls to getField. */ public UnaryCallSettings.Builder getFieldSettings() { return getFieldSettings; } + /** Returns the builder for the settings used for calls to updateField. */ + public UnaryCallSettings.Builder updateFieldSettings() { + return updateFieldSettings; + } + + /** Returns the builder for the settings used for calls to updateField. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + updateFieldOperationSettings() { + return updateFieldOperationSettings; + } + /** Returns the builder for the settings used for calls to listFields. */ public PagedCallSettings.Builder listFieldsSettings() { diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java index 206ee091a..d5e49d0a4 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,18 +31,19 @@ import com.google.api.gax.rpc.StreamingCallSettings; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Google Cloud Firestore Admin API. + * gRPC callable factory implementation for the FirestoreAdmin service API. * *

This class is for advanced usage. */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +@Generated("by gapic-generator-java") public class GrpcFirestoreAdminCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java index 010701dc9..b8c6919c0 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -56,30 +56,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Google Cloud Firestore Admin API. + * gRPC stub implementation for the FirestoreAdmin service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public class GrpcFirestoreAdminStub extends FirestoreAdminStub { - - private static final MethodDescriptor deleteIndexMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteIndex") - .setRequestMarshaller(ProtoUtils.marshaller(DeleteIndexRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor updateFieldMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateField") - .setRequestMarshaller(ProtoUtils.marshaller(UpdateFieldRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) - .build(); private static final MethodDescriptor createIndexMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -87,6 +71,7 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { .setRequestMarshaller(ProtoUtils.marshaller(CreateIndexRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor listIndexesMethodDescriptor = MethodDescriptor.newBuilder() @@ -96,6 +81,7 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { .setResponseMarshaller( ProtoUtils.marshaller(ListIndexesResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getIndexMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -103,6 +89,15 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { .setRequestMarshaller(ProtoUtils.marshaller(GetIndexRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Index.getDefaultInstance())) .build(); + + private static final MethodDescriptor deleteIndexMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteIndex") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteIndexRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + private static final MethodDescriptor getFieldMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -110,6 +105,15 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { .setRequestMarshaller(ProtoUtils.marshaller(GetFieldRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Field.getDefaultInstance())) .build(); + + private static final MethodDescriptor updateFieldMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateField") + .setRequestMarshaller(ProtoUtils.marshaller(UpdateFieldRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + private static final MethodDescriptor listFieldsMethodDescriptor = MethodDescriptor.newBuilder() @@ -118,6 +122,7 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { .setRequestMarshaller(ProtoUtils.marshaller(ListFieldsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(ListFieldsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor exportDocumentsMethodDescriptor = MethodDescriptor.newBuilder() @@ -127,6 +132,7 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { ProtoUtils.marshaller(ExportDocumentsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor importDocumentsMethodDescriptor = MethodDescriptor.newBuilder() @@ -137,13 +143,6 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final GrpcOperationsStub operationsStub; - - private final UnaryCallable deleteIndexCallable; - private final UnaryCallable updateFieldCallable; - private final OperationCallable - updateFieldOperationCallable; private final UnaryCallable createIndexCallable; private final OperationCallable createIndexOperationCallable; @@ -151,7 +150,11 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { private final UnaryCallable listIndexesPagedCallable; private final UnaryCallable getIndexCallable; + private final UnaryCallable deleteIndexCallable; private final UnaryCallable getFieldCallable; + private final UnaryCallable updateFieldCallable; + private final OperationCallable + updateFieldOperationCallable; private final UnaryCallable listFieldsCallable; private final UnaryCallable listFieldsPagedCallable; private final UnaryCallable exportDocumentsCallable; @@ -162,6 +165,8 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { private final OperationCallable importDocumentsOperationCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcFirestoreAdminStub create(FirestoreAdminStubSettings settings) @@ -204,32 +209,6 @@ protected GrpcFirestoreAdminStub( this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); - GrpcCallSettings deleteIndexTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteIndexMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteIndexRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings updateFieldTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateFieldMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateFieldRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("field.name", String.valueOf(request.getField().getName())); - return params.build(); - } - }) - .build(); GrpcCallSettings createIndexTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createIndexMethodDescriptor) @@ -269,6 +248,19 @@ public Map extract(GetIndexRequest request) { } }) .build(); + GrpcCallSettings deleteIndexTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteIndexMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(DeleteIndexRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); GrpcCallSettings getFieldTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getFieldMethodDescriptor) @@ -282,6 +274,19 @@ public Map extract(GetFieldRequest request) { } }) .build(); + GrpcCallSettings updateFieldTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateFieldMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateFieldRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("field.name", String.valueOf(request.getField().getName())); + return params.build(); + } + }) + .build(); GrpcCallSettings listFieldsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listFieldsMethodDescriptor) @@ -322,18 +327,6 @@ public Map extract(ImportDocumentsRequest request) { }) .build(); - this.deleteIndexCallable = - callableFactory.createUnaryCallable( - deleteIndexTransportSettings, settings.deleteIndexSettings(), clientContext); - this.updateFieldCallable = - callableFactory.createUnaryCallable( - updateFieldTransportSettings, settings.updateFieldSettings(), clientContext); - this.updateFieldOperationCallable = - callableFactory.createOperationCallable( - updateFieldTransportSettings, - settings.updateFieldOperationSettings(), - clientContext, - this.operationsStub); this.createIndexCallable = callableFactory.createUnaryCallable( createIndexTransportSettings, settings.createIndexSettings(), clientContext); @@ -342,7 +335,7 @@ public Map extract(ImportDocumentsRequest request) { createIndexTransportSettings, settings.createIndexOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.listIndexesCallable = callableFactory.createUnaryCallable( listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); @@ -352,9 +345,21 @@ public Map extract(ImportDocumentsRequest request) { this.getIndexCallable = callableFactory.createUnaryCallable( getIndexTransportSettings, settings.getIndexSettings(), clientContext); + this.deleteIndexCallable = + callableFactory.createUnaryCallable( + deleteIndexTransportSettings, settings.deleteIndexSettings(), clientContext); this.getFieldCallable = callableFactory.createUnaryCallable( getFieldTransportSettings, settings.getFieldSettings(), clientContext); + this.updateFieldCallable = + callableFactory.createUnaryCallable( + updateFieldTransportSettings, settings.updateFieldSettings(), clientContext); + this.updateFieldOperationCallable = + callableFactory.createOperationCallable( + updateFieldTransportSettings, + settings.updateFieldOperationSettings(), + clientContext, + operationsStub); this.listFieldsCallable = callableFactory.createUnaryCallable( listFieldsTransportSettings, settings.listFieldsSettings(), clientContext); @@ -369,7 +374,7 @@ public Map extract(ImportDocumentsRequest request) { exportDocumentsTransportSettings, settings.exportDocumentsOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.importDocumentsCallable = callableFactory.createUnaryCallable( importDocumentsTransportSettings, settings.importDocumentsSettings(), clientContext); @@ -378,84 +383,95 @@ public Map extract(ImportDocumentsRequest request) { importDocumentsTransportSettings, settings.importDocumentsOperationSettings(), clientContext, - this.operationsStub); + operationsStub); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public GrpcOperationsStub getOperationsStub() { return operationsStub; } - public UnaryCallable deleteIndexCallable() { - return deleteIndexCallable; - } - - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - updateFieldOperationCallable() { - return updateFieldOperationCallable; - } - - public UnaryCallable updateFieldCallable() { - return updateFieldCallable; + @Override + public UnaryCallable createIndexCallable() { + return createIndexCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + @Override public OperationCallable createIndexOperationCallable() { return createIndexOperationCallable; } - public UnaryCallable createIndexCallable() { - return createIndexCallable; + @Override + public UnaryCallable listIndexesCallable() { + return listIndexesCallable; } + @Override public UnaryCallable listIndexesPagedCallable() { return listIndexesPagedCallable; } - public UnaryCallable listIndexesCallable() { - return listIndexesCallable; - } - + @Override public UnaryCallable getIndexCallable() { return getIndexCallable; } + @Override + public UnaryCallable deleteIndexCallable() { + return deleteIndexCallable; + } + + @Override public UnaryCallable getFieldCallable() { return getFieldCallable; } - public UnaryCallable listFieldsPagedCallable() { - return listFieldsPagedCallable; + @Override + public UnaryCallable updateFieldCallable() { + return updateFieldCallable; } + @Override + public OperationCallable + updateFieldOperationCallable() { + return updateFieldOperationCallable; + } + + @Override public UnaryCallable listFieldsCallable() { return listFieldsCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - exportDocumentsOperationCallable() { - return exportDocumentsOperationCallable; + @Override + public UnaryCallable listFieldsPagedCallable() { + return listFieldsPagedCallable; } + @Override public UnaryCallable exportDocumentsCallable() { return exportDocumentsCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallable - importDocumentsOperationCallable() { - return importDocumentsOperationCallable; + @Override + public OperationCallable + exportDocumentsOperationCallable() { + return exportDocumentsOperationCallable; } + @Override public UnaryCallable importDocumentsCallable() { return importDocumentsCallable; } + @Override + public OperationCallable + importDocumentsOperationCallable() { + return importDocumentsOperationCallable; + } + @Override public final void close() { shutdown(); diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java index 818da5f6b..4372bd480 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1; import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; @@ -49,13 +50,14 @@ import com.google.protobuf.AbstractMessage; import com.google.protobuf.Any; import com.google.protobuf.Empty; -import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -63,31 +65,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class FirestoreAdminClientTest { - private static MockFirestoreAdmin mockFirestoreAdmin; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private FirestoreAdminClient client; private LocalChannelProvider channelProvider; + private static MockFirestoreAdmin mockFirestoreAdmin; @BeforeClass public static void startStaticServer() { mockFirestoreAdmin = new MockFirestoreAdmin(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockFirestoreAdmin)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); FirestoreAdminSettings settings = FirestoreAdminSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -102,20 +104,32 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void deleteIndexTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockFirestoreAdmin.addResponse(expectedResponse); + public void createIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); - IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + Index index = Index.newBuilder().build(); - client.deleteIndex(name); + Index actualResponse = client.createIndexAsync(parent, index).get(); + Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteIndexRequest actualRequest = (DeleteIndexRequest) actualRequests.get(0); + CreateIndexRequest actualRequest = ((CreateIndexRequest) actualRequests.get(0)); - Assert.assertEquals(name, IndexName.parse(actualRequest.getName())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(index, actualRequest.getIndex()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -123,44 +137,50 @@ public void deleteIndexTest() { } @Test - @SuppressWarnings("all") - public void deleteIndexExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + public void createIndexExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { - IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); - - client.deleteIndex(name); + CollectionGroupName parent = + CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + Index index = Index.newBuilder().build(); + client.createIndexAsync(parent, index).get(); Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") - public void updateFieldTest() throws Exception { - FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); - Field expectedResponse = Field.newBuilder().setName(name.toString()).build(); + public void createIndexTest2() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); Operation resultOperation = Operation.newBuilder() - .setName("updateFieldTest") + .setName("createIndexTest") .setDone(true) .setResponse(Any.pack(expectedResponse)) .build(); mockFirestoreAdmin.addResponse(resultOperation); - Field field = Field.newBuilder().build(); + String parent = "parent-995424086"; + Index index = Index.newBuilder().build(); - Field actualResponse = client.updateFieldAsync(field).get(); + Index actualResponse = client.createIndexAsync(parent, index).get(); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateFieldRequest actualRequest = (UpdateFieldRequest) actualRequests.get(0); + CreateIndexRequest actualRequest = ((CreateIndexRequest) actualRequests.get(0)); - Assert.assertEquals(field, actualRequest.getField()); + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(index, actualRequest.getIndex()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -168,48 +188,46 @@ public void updateFieldTest() throws Exception { } @Test - @SuppressWarnings("all") - public void updateFieldExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + public void createIndexExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { - Field field = Field.newBuilder().build(); - - client.updateFieldAsync(field).get(); + String parent = "parent-995424086"; + Index index = Index.newBuilder().build(); + client.createIndexAsync(parent, index).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") - public void createIndexTest() throws Exception { - IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); - Index expectedResponse = Index.newBuilder().setName(name.toString()).build(); - Operation resultOperation = - Operation.newBuilder() - .setName("createIndexTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) + public void listIndexesTest() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) .build(); - mockFirestoreAdmin.addResponse(resultOperation); + mockFirestoreAdmin.addResponse(expectedResponse); CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); - Index index = Index.newBuilder().build(); - Index actualResponse = client.createIndexAsync(parent, index).get(); - Assert.assertEquals(expectedResponse, actualResponse); + ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0)); List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateIndexRequest actualRequest = (CreateIndexRequest) actualRequests.get(0); + ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0)); - Assert.assertEquals(parent, CollectionGroupName.parse(actualRequest.getParent())); - Assert.assertEquals(index, actualRequest.getIndex()); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -217,51 +235,44 @@ public void createIndexTest() throws Exception { } @Test - @SuppressWarnings("all") - public void createIndexExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + public void listIndexesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); - Index index = Index.newBuilder().build(); - - client.createIndexAsync(parent, index).get(); + client.listIndexes(parent); Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } catch (InvalidArgumentException e) { + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listIndexesTest() { - String nextPageToken = ""; - Index indexesElement = Index.newBuilder().build(); - List indexes = Arrays.asList(indexesElement); + public void listIndexesTest2() throws Exception { + Index responsesElement = Index.newBuilder().build(); ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllIndexes(indexes) + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) .build(); mockFirestoreAdmin.addResponse(expectedResponse); - CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + String parent = "parent-995424086"; ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0)); List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListIndexesRequest actualRequest = (ListIndexesRequest) actualRequests.get(0); + ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0)); - Assert.assertEquals(parent, CollectionGroupName.parse(actualRequest.getParent())); + Assert.assertEquals(parent, actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -269,27 +280,26 @@ public void listIndexesTest() { } @Test - @SuppressWarnings("all") - public void listIndexesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + public void listIndexesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { - CollectionGroupName parent = - CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); - + String parent = "parent-995424086"; client.listIndexes(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getIndexTest() { - IndexName name2 = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); - Index expectedResponse = Index.newBuilder().setName(name2.toString()).build(); + public void getIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); mockFirestoreAdmin.addResponse(expectedResponse); IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); @@ -299,9 +309,9 @@ public void getIndexTest() { List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetIndexRequest actualRequest = (GetIndexRequest) actualRequests.get(0); + GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0)); - Assert.assertEquals(name, IndexName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -309,26 +319,133 @@ public void getIndexTest() { } @Test - @SuppressWarnings("all") public void getIndexExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + client.getIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIndexTest2() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + Index actualResponse = client.getIndex(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void getIndexExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; client.getIndex(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. + } + } + + @Test + public void deleteIndexTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + + client.deleteIndex(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteIndexExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + client.deleteIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getFieldTest() { - FieldName name2 = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); - Field expectedResponse = Field.newBuilder().setName(name2.toString()).build(); + public void deleteIndexTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteIndex(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteIndexExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFieldTest() throws Exception { + Field expectedResponse = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .build(); mockFirestoreAdmin.addResponse(expectedResponse); FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); @@ -338,9 +455,9 @@ public void getFieldTest() { List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetFieldRequest actualRequest = (GetFieldRequest) actualRequests.get(0); + GetFieldRequest actualRequest = ((GetFieldRequest) actualRequests.get(0)); - Assert.assertEquals(name, FieldName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -348,31 +465,112 @@ public void getFieldTest() { } @Test - @SuppressWarnings("all") public void getFieldExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); + client.getField(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFieldTest2() throws Exception { + Field expectedResponse = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + Field actualResponse = client.getField(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetFieldRequest actualRequest = ((GetFieldRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getFieldExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + try { + String name = "name3373707"; client.getField(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. + } + } + + @Test + public void updateFieldTest() throws Exception { + Field expectedResponse = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateFieldTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + Field field = Field.newBuilder().build(); + + Field actualResponse = client.updateFieldAsync(field).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateFieldRequest actualRequest = ((UpdateFieldRequest) actualRequests.get(0)); + + Assert.assertEquals(field, actualRequest.getField()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updateFieldExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + Field field = Field.newBuilder().build(); + client.updateFieldAsync(field).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") - public void listFieldsTest() { - String nextPageToken = ""; - Field fieldsElement = Field.newBuilder().build(); - List fields = Arrays.asList(fieldsElement); + public void listFieldsTest() throws Exception { + Field responsesElement = Field.newBuilder().build(); ListFieldsResponse expectedResponse = ListFieldsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllFields(fields) + .setNextPageToken("") + .addAllFields(Arrays.asList(responsesElement)) .build(); mockFirestoreAdmin.addResponse(expectedResponse); @@ -381,14 +579,15 @@ public void listFieldsTest() { ListFieldsPagedResponse pagedListResponse = client.listFields(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getFieldsList().get(0), resources.get(0)); List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListFieldsRequest actualRequest = (ListFieldsRequest) actualRequests.get(0); + ListFieldsRequest actualRequest = ((ListFieldsRequest) actualRequests.get(0)); - Assert.assertEquals(parent, CollectionGroupName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -396,28 +595,68 @@ public void listFieldsTest() { } @Test - @SuppressWarnings("all") public void listFieldsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + client.listFields(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFieldsTest2() throws Exception { + Field responsesElement = Field.newBuilder().build(); + ListFieldsResponse expectedResponse = + ListFieldsResponse.newBuilder() + .setNextPageToken("") + .addAllFields(Arrays.asList(responsesElement)) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListFieldsPagedResponse pagedListResponse = client.listFields(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFieldsList().get(0), resources.get(0)); + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListFieldsRequest actualRequest = ((ListFieldsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listFieldsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; client.listFields(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") public void exportDocumentsTest() throws Exception { - String outputUriPrefix = "outputUriPrefix124746435"; ExportDocumentsResponse expectedResponse = - ExportDocumentsResponse.newBuilder().setOutputUriPrefix(outputUriPrefix).build(); + ExportDocumentsResponse.newBuilder().setOutputUriPrefix("outputUriPrefix499858205").build(); Operation resultOperation = Operation.newBuilder() .setName("exportDocumentsTest") @@ -433,9 +672,9 @@ public void exportDocumentsTest() throws Exception { List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ExportDocumentsRequest actualRequest = (ExportDocumentsRequest) actualRequests.get(0); + ExportDocumentsRequest actualRequest = ((ExportDocumentsRequest) actualRequests.get(0)); - Assert.assertEquals(name, DatabaseName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -443,25 +682,66 @@ public void exportDocumentsTest() throws Exception { } @Test - @SuppressWarnings("all") public void exportDocumentsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.exportDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void exportDocumentsTest2() throws Exception { + ExportDocumentsResponse expectedResponse = + ExportDocumentsResponse.newBuilder().setOutputUriPrefix("outputUriPrefix499858205").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + String name = "name3373707"; + + ExportDocumentsResponse actualResponse = client.exportDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ExportDocumentsRequest actualRequest = ((ExportDocumentsRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void exportDocumentsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; client.exportDocumentsAsync(name).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") public void importDocumentsTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); Operation resultOperation = @@ -474,14 +754,13 @@ public void importDocumentsTest() throws Exception { DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); - Empty actualResponse = client.importDocumentsAsync(name).get(); - Assert.assertEquals(expectedResponse, actualResponse); + client.importDocumentsAsync(name).get(); List actualRequests = mockFirestoreAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ImportDocumentsRequest actualRequest = (ImportDocumentsRequest) actualRequests.get(0); + ImportDocumentsRequest actualRequest = ((ImportDocumentsRequest) actualRequests.get(0)); - Assert.assertEquals(name, DatabaseName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -489,19 +768,59 @@ public void importDocumentsTest() throws Exception { } @Test - @SuppressWarnings("all") public void importDocumentsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestoreAdmin.addException(exception); try { DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.importDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void importDocumentsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + String name = "name3373707"; + + client.importDocumentsAsync(name).get(); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ImportDocumentsRequest actualRequest = ((ImportDocumentsRequest) actualRequests.get(0)); + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void importDocumentsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; client.importDocumentsAsync(name).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java index 9f5bfa8ff..f413ce159 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * 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.BetaApi; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockFirestoreAdmin implements MockGrpcService { private final MockFirestoreAdminImpl serviceImpl; diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java index 186a4606d..dc4c54e55 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * 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.BetaApi; @@ -38,9 +39,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockFirestoreAdminImpl extends FirestoreAdminImplBase { private List requests; private Queue responses; @@ -73,131 +75,185 @@ public void reset() { @Override public void createIndex(CreateIndexRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateIndex, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); } } @Override public void listIndexes( ListIndexesRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof ListIndexesResponse) { requests.add(request); - responseObserver.onNext((ListIndexesResponse) response); + responseObserver.onNext(((ListIndexesResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListIndexes, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListIndexesResponse.class.getName(), + Exception.class.getName()))); } } @Override public void getIndex(GetIndexRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Index) { requests.add(request); - responseObserver.onNext((Index) response); + responseObserver.onNext(((Index) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetIndex, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Index.class.getName(), + Exception.class.getName()))); } } @Override public void deleteIndex(DeleteIndexRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteIndex, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); } } @Override public void getField(GetFieldRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Field) { requests.add(request); - responseObserver.onNext((Field) response); + responseObserver.onNext(((Field) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetField, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Field.class.getName(), + Exception.class.getName()))); } } @Override public void updateField(UpdateFieldRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdateField, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); } } @Override public void listFields( ListFieldsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof ListFieldsResponse) { requests.add(request); - responseObserver.onNext((ListFieldsResponse) response); + responseObserver.onNext(((ListFieldsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListFields, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListFieldsResponse.class.getName(), + Exception.class.getName()))); } } @Override public void exportDocuments( ExportDocumentsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ExportDocuments, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); } } @Override public void importDocuments( ImportDocumentsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ImportDocuments, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); } } } diff --git a/google-cloud-firestore-bom/pom.xml b/google-cloud-firestore-bom/pom.xml index a17406ff0..21876b126 100644 --- a/google-cloud-firestore-bom/pom.xml +++ b/google-cloud-firestore-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-firestore-bom - 2.3.0 + 2.4.0 pom com.google.cloud @@ -63,37 +63,37 @@ com.google.cloud google-cloud-firestore - 2.3.0 + 2.4.0 com.google.api.grpc proto-google-cloud-firestore-admin-v1 - 2.3.0 + 2.4.0 com.google.cloud proto-google-cloud-firestore-bundle-v1 - 2.3.0 + 2.4.0 com.google.api.grpc proto-google-cloud-firestore-v1 - 2.3.0 + 2.4.0 com.google.api.grpc grpc-google-cloud-firestore-admin-v1 - 2.3.0 + 2.4.0 com.google.api.grpc grpc-google-cloud-firestore-v1 - 2.3.0 + 2.4.0 com.google.cloud google-cloud-firestore-admin - 2.3.0 + 2.4.0 diff --git a/google-cloud-firestore/pom.xml b/google-cloud-firestore/pom.xml index 2f29d3939..f113a0685 100644 --- a/google-cloud-firestore/pom.xml +++ b/google-cloud-firestore/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 google-cloud-firestore - 2.3.0 + 2.4.0 jar Google Cloud Firestore https://github.com/googleapis/java-firestore @@ -14,7 +14,7 @@ com.google.cloud google-cloud-firestore-parent - 2.3.0 + 2.4.0 google-cloud-firestore diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java index 6f6bf755b..bb9d75090 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java @@ -25,10 +25,13 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ApiException; import com.google.api.gax.rpc.StatusCode.Code; import com.google.cloud.firestore.v1.FirestoreSettings; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.MoreExecutors; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; @@ -110,6 +113,14 @@ enum OperationType { */ private static final int RATE_LIMITER_MULTIPLIER_MILLIS = 5 * 60 * 1000; + /** + * The default maximum number of pending operations that can be enqueued onto a BulkWriter + * instance. An operation is considered pending if BulkWriter has sent it via RPC and is awaiting + * the result. BulkWriter buffers additional writes after this many pending operations in order to + * avoiding going OOM. + */ + private static final int DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT = 500; + /** * The default jitter to apply to the exponential backoff used in retries. For example, a factor * of 0.3 means a 30% jitter is applied. @@ -158,6 +169,26 @@ public boolean onError(BulkWriterException error) { @GuardedBy("lock") private final RateLimiter rateLimiter; + /** + * The number of pending operations enqueued on this BulkWriter instance. An operation is + * considered pending if BulkWriter has sent it via RPC and is awaiting the result. + */ + @GuardedBy("lock") + private int pendingOpsCount = 0; + + /** + * An array containing buffered BulkWriter operations after the maximum number of pending + * operations has been enqueued. + */ + @GuardedBy("lock") + private final List bufferedOperations = new ArrayList<>(); + + /** + * The maximum number of pending operations that can be enqueued onto this BulkWriter instance. + * Once the this number of writes have been enqueued, subsequent writes are buffered. + */ + private int maxPendingOpCount = DEFAULT_MAXIMUM_PENDING_OPERATIONS_COUNT; + /** * The batch that is currently used to schedule operations. Once this batch reaches maximum * capacity, a new batch is created. @@ -627,7 +658,7 @@ private ApiFuture executeWrite( final DocumentReference documentReference, final OperationType operationType, final ApiFunction> enqueueOperationOnBatchCallback) { - BulkWriterOperation operation = + final BulkWriterOperation operation = new BulkWriterOperation( documentReference, operationType, @@ -660,10 +691,73 @@ public ApiFuture apply(BulkWriterException e) { synchronized (lock) { verifyNotClosedLocked(); writesEnqueued = true; - sendOperationLocked(enqueueOperationOnBatchCallback, operation); + + // Advance the lastOperation pointer. This ensures that lastOperation only completes when + // both the previous and the current write complete. + lastOperation = + ApiFutures.transformAsync( + lastOperation, + new ApiAsyncFunction() { + @Override + public ApiFuture apply(Void aVoid) { + return silenceFuture(operation.getFuture()); + } + }, + MoreExecutors.directExecutor()); + + // Schedule the operation if the BulkWriter has fewer than the maximum number of allowed + // pending operations, or add the operation to the buffer. + if (pendingOpsCount < maxPendingOpCount) { + pendingOpsCount++; + sendOperationLocked(enqueueOperationOnBatchCallback, operation); + } else { + bufferedOperations.add( + new Runnable() { + @Override + public void run() { + synchronized (lock) { + pendingOpsCount++; + sendOperationLocked(enqueueOperationOnBatchCallback, operation); + } + } + }); + } } - return operation.getFuture(); + ApiFuture processedOperationFuture = + ApiFutures.transformAsync( + operation.getFuture(), + new ApiAsyncFunction() { + public ApiFuture apply(WriteResult result) throws Exception { + pendingOpsCount--; + processBufferedOperations(); + return ApiFutures.immediateFuture(result); + } + }, + MoreExecutors.directExecutor()); + + return ApiFutures.catchingAsync( + processedOperationFuture, + ApiException.class, + new ApiAsyncFunction() { + public ApiFuture apply(ApiException e) throws Exception { + pendingOpsCount--; + processBufferedOperations(); + throw e; + } + }, + MoreExecutors.directExecutor()); + } + + /** + * Manages the pending operation counter and schedules the next BulkWriter operation if we're + * under the maximum limit. + */ + private void processBufferedOperations() { + if (pendingOpsCount < maxPendingOpCount && bufferedOperations.size() > 0) { + Runnable nextOp = bufferedOperations.remove(0); + nextOp.run(); + } } /** @@ -894,8 +988,10 @@ private void sendBatchLocked(final BulkCommitBatch batch, final boolean flush) { new Runnable() { @Override public void run() { - synchronized (lock) { - scheduleCurrentBatchLocked(flush); + if (flush) { + synchronized (lock) { + scheduleCurrentBatchLocked(/* flush= */ true); + } } } }, @@ -927,6 +1023,16 @@ RateLimiter getRateLimiter() { return rateLimiter; } + @VisibleForTesting + int getBufferedOperationsCount() { + return bufferedOperations.size(); + } + + @VisibleForTesting + void setMaxPendingOpCount(int newMax) { + maxPendingOpCount = newMax; + } + /** * Schedules the provided operations on the current BulkCommitBatch. Sends the BulkCommitBatch if * it reaches maximum capacity. @@ -946,17 +1052,6 @@ private void sendOperationLocked( bulkCommitBatch.enqueueOperation(op); enqueueOperationOnBatchCallback.apply(bulkCommitBatch); - lastOperation = - ApiFutures.transformAsync( - lastOperation, - new ApiAsyncFunction() { - @Override - public ApiFuture apply(Void aVoid) { - return silenceFuture(op.getFuture()); - } - }, - MoreExecutors.directExecutor()); - if (bulkCommitBatch.getMutationsSize() == maxBatchSize) { scheduleCurrentBatchLocked(/* flush= */ false); } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java index 81925e3a4..c0abfa15d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * 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.ApiFunction; @@ -66,7 +67,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: The Cloud Firestore service. * @@ -79,17 +80,18 @@ *

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
  * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- *   Document document = Document.newBuilder().build();
- *   DocumentMask updateMask = DocumentMask.newBuilder().build();
- *   Document response = firestoreClient.updateDocument(document, updateMask);
+ *   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 + *

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

The surface of this class includes several types of Java methods for each of the API's @@ -117,29 +119,25 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * FirestoreSettings firestoreSettings =
  *     FirestoreSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * FirestoreClient firestoreClient =
- *     FirestoreClient.create(firestoreSettings);
- * 
- * 
+ * FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings); + * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * FirestoreSettings firestoreSettings =
  *     FirestoreSettings.newBuilder().setEndpoint(myEndpoint).build();
- * FirestoreClient firestoreClient =
- *     FirestoreClient.create(firestoreSettings);
- * 
- * 
+ * FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings); + * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class FirestoreClient implements BackgroundResource { private final FirestoreSettings settings; private final FirestoreStub stub; @@ -159,7 +157,7 @@ public static final FirestoreClient create(FirestoreSettings settings) throws IO /** * Constructs an instance of FirestoreClient, using the given stub for making calls. This is for - * advanced usage - prefer to use FirestoreSettings}. + * advanced usage - prefer using create(FirestoreSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final FirestoreClient create(FirestoreStub stub) { @@ -190,21 +188,22 @@ public FirestoreStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String name = "";
-   *   GetDocumentRequest request = GetDocumentRequest.newBuilder()
-   *     .setName(name)
-   *     .build();
+   *   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 @@ -213,47 +212,52 @@ public final Document getDocument(GetDocumentRequest request) { return getDocumentCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String name = "";
-   *   GetDocumentRequest request = GetDocumentRequest.newBuilder()
-   *     .setName(name)
-   *     .build();
-   *   ApiFuture<Document> future = firestoreClient.getDocumentCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists documents. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   String collectionId = "";
-   *   ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
-   *     .setParent(parent)
-   *     .setCollectionId(collectionId)
-   *     .build();
+   *   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 @@ -262,50 +266,58 @@ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest reque return listDocumentsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists documents. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   String collectionId = "";
-   *   ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
-   *     .setParent(parent)
-   *     .setCollectionId(collectionId)
-   *     .build();
-   *   ApiFuture<ListDocumentsPagedResponse> future = firestoreClient.listDocumentsPagedCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists documents. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   String collectionId = "";
-   *   ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
-   *     .setParent(parent)
-   *     .setCollectionId(collectionId)
-   *     .build();
+   *   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()) {
+   *     for (Document element : response.getResponsesList()) {
    *       // doThingsWith(element);
    *     }
    *     String nextPageToken = response.getNextPageToken();
@@ -316,78 +328,25 @@ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest reque
    *     }
    *   }
    * }
-   * 
+ * }
*/ public final UnaryCallable listDocumentsCallable() { return stub.listDocumentsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new document. - * - *

Sample code: - * - *


-   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   String collectionId = "";
-   *   Document document = Document.newBuilder().build();
-   *   CreateDocumentRequest request = CreateDocumentRequest.newBuilder()
-   *     .setParent(parent)
-   *     .setCollectionId(collectionId)
-   *     .setDocument(document)
-   *     .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: - * - *


-   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   String collectionId = "";
-   *   Document document = Document.newBuilder().build();
-   *   CreateDocumentRequest request = CreateDocumentRequest.newBuilder()
-   *     .setParent(parent)
-   *     .setCollectionId(collectionId)
-   *     .setDocument(document)
-   *     .build();
-   *   ApiFuture<Document> future = firestoreClient.createDocumentCallable().futureCall(request);
-   *   // Do something
-   *   Document response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable createDocumentCallable() { - return stub.createDocumentCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates or inserts a document. * *

Sample code: * - *


+   * 
{@code
    * 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. @@ -404,21 +363,24 @@ public final Document updateDocument(Document document, DocumentMask updateMask) return updateDocument(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates or inserts a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   Document document = Document.newBuilder().build();
-   *   UpdateDocumentRequest request = UpdateDocumentRequest.newBuilder()
-   *     .setDocument(document)
-   *     .build();
+   *   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 @@ -427,40 +389,43 @@ public final Document updateDocument(UpdateDocumentRequest request) { return updateDocumentCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates or inserts a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   Document document = Document.newBuilder().build();
-   *   UpdateDocumentRequest request = UpdateDocumentRequest.newBuilder()
-   *     .setDocument(document)
-   *     .build();
-   *   ApiFuture<Document> future = firestoreClient.updateDocumentCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String name = "";
+   *   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}`. @@ -471,21 +436,22 @@ public final void deleteDocument(String name) { deleteDocument(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String name = "";
-   *   DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder()
-   *     .setName(name)
-   *     .build();
+   *   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 @@ -494,29 +460,30 @@ public final void deleteDocument(DeleteDocumentRequest request) { deleteDocumentCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String name = "";
-   *   DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder()
-   *     .setName(name)
-   *     .build();
-   *   ApiFuture<Void> future = firestoreClient.deleteDocumentCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets multiple documents. * @@ -525,98 +492,39 @@ public final UnaryCallable deleteDocumentCallable( * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   BatchGetDocumentsRequest request = BatchGetDocumentsRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .build();
-   *
-   *   ServerStream<BatchGetDocumentsResponse> stream = firestoreClient.batchGetDocumentsCallable().call(request);
+   *   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 receive a response
+   *     // Do something when a response is received.
    *   }
    * }
-   * 
+ * }
*/ public final ServerStreamingCallable batchGetDocumentsCallable() { return stub.batchGetDocumentsCallable(); } - // 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: - * - *


-   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   BatchWriteRequest request = BatchWriteRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .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: - * - *


-   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   BatchWriteRequest request = BatchWriteRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .build();
-   *   ApiFuture<BatchWriteResponse> future = firestoreClient.batchWriteCallable().futureCall(request);
-   *   // Do something
-   *   BatchWriteResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable batchWriteCallable() { - return stub.batchWriteCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Starts a new transaction. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
+   *   String database = "database1789464955";
    *   BeginTransactionResponse response = firestoreClient.beginTransaction(database);
    * }
-   * 
+ * }
* * @param database Required. The database name. In the format: * `projects/{project_id}/databases/{database_id}`. @@ -628,21 +536,22 @@ public final BeginTransactionResponse beginTransaction(String database) { return beginTransaction(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Starts a new transaction. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   BeginTransactionRequest request = BeginTransactionRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .build();
+   *   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 @@ -651,42 +560,44 @@ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest r return beginTransactionCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Starts a new transaction. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   BeginTransactionRequest request = BeginTransactionRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .build();
-   *   ApiFuture<BeginTransactionResponse> future = firestoreClient.beginTransactionCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Commits a transaction, while optionally updating documents. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   List<Write> writes = new ArrayList<>();
+   *   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}`. @@ -700,21 +611,23 @@ public final CommitResponse commit(String database, List writes) { return commit(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Commits a transaction, while optionally updating documents. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   CommitRequest request = CommitRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .build();
+   *   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 @@ -723,41 +636,43 @@ public final CommitResponse commit(CommitRequest request) { return commitCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Commits a transaction, while optionally updating documents. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   CommitRequest request = CommitRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .build();
-   *   ApiFuture<CommitResponse> future = firestoreClient.commitCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Rolls back a transaction. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   ByteString transaction = ByteString.copyFromUtf8("");
+   *   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}`. @@ -770,23 +685,22 @@ public final void rollback(String database, ByteString transaction) { rollback(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Rolls back a transaction. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   ByteString transaction = ByteString.copyFromUtf8("");
-   *   RollbackRequest request = RollbackRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .setTransaction(transaction)
-   *     .build();
+   *   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 @@ -795,120 +709,214 @@ public final void rollback(RollbackRequest request) { rollbackCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Rolls back a transaction. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String database = "";
-   *   ByteString transaction = ByteString.copyFromUtf8("");
-   *   RollbackRequest request = RollbackRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .setTransaction(transaction)
-   *     .build();
-   *   ApiFuture<Void> future = firestoreClient.rollbackCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Runs a query. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   RunQueryRequest request = RunQueryRequest.newBuilder()
-   *     .setParent(parent)
-   *     .build();
-   *
-   *   ServerStream<RunQueryResponse> stream = firestoreClient.runQueryCallable().call(request);
+   *   RunQueryRequest request = RunQueryRequest.newBuilder().setParent("parent-995424086").build();
+   *   ServerStream stream = firestoreClient.runQueryCallable().call(request);
    *   for (RunQueryResponse response : stream) {
-   *     // Do something when receive a response
+   *     // Do something when a response is received.
    *   }
    * }
-   * 
+ * }
*/ public final ServerStreamingCallable runQueryCallable() { return stub.runQueryCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Streams batches of document updates and deletes, in order. + * 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
+   * 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
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   BidiStream<WriteRequest, WriteResponse> bidiStream =
-   *       firestoreClient.writeCallable().call();
+   *   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
+   * 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.getResponsesList()) {
+   *       // 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. + * + *

Sample code: * - * String database = ""; - * WriteRequest request = WriteRequest.newBuilder() - * .setDatabase(database) - * .build(); + *

{@code
+   * 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 receive a response
+   *     // Do something when a response is received.
    *   }
    * }
-   * 
+ * }
*/ public final BidiStreamingCallable writeCallable() { return stub.writeCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Listens to changes. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   BidiStream<ListenRequest, ListenResponse> bidiStream =
+   *   BidiStream bidiStream =
    *       firestoreClient.listenCallable().call();
-   *
-   *   String database = "";
-   *   ListenRequest request = ListenRequest.newBuilder()
-   *     .setDatabase(database)
-   *     .build();
+   *   ListenRequest request =
+   *       ListenRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .putAllLabels(new HashMap())
+   *           .build();
    *   bidiStream.send(request);
    *   for (ListenResponse response : bidiStream) {
-   *     // Do something when receive a response
+   *     // Do something when a response is received.
    *   }
    * }
-   * 
+ * }
*/ public final BidiStreamingCallable listenCallable() { return stub.listenCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
+   *   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: @@ -921,23 +929,25 @@ public final ListCollectionIdsPagedResponse listCollectionIds(String parent) { return listCollectionIds(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
-   *     .setParent(parent)
-   *     .build();
+   *   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 @@ -946,46 +956,52 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR return listCollectionIdsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
-   *     .setParent(parent)
-   *     .build();
-   *   ApiFuture<ListCollectionIdsPagedResponse> future = firestoreClient.listCollectionIdsPagedCallable().futureCall(request);
-   *   // Do something
+   *   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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the collection IDs underneath a document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
-   *     .setParent(parent)
-   *     .build();
+   *   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()) {
+   *     ListCollectionIdsResponse response =
+   *         firestoreClient.listCollectionIdsCallable().call(request);
+   *     for (String element : response.getResponsesList()) {
    *       // doThingsWith(element);
    *     }
    *     String nextPageToken = response.getNextPageToken();
@@ -996,99 +1012,130 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR
    *     }
    *   }
    * }
-   * 
+ * }
*/ public final UnaryCallable listCollectionIdsCallable() { return stub.listCollectionIdsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. + * 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
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   PartitionQueryRequest request = PartitionQueryRequest.newBuilder()
-   *     .setParent(parent)
-   *     .build();
-   *   for (Cursor element : firestoreClient.partitionQuery(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
+   *   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 PartitionQueryPagedResponse partitionQuery(PartitionQueryRequest request) { - return partitionQueryPagedCallable().call(request); + public final BatchWriteResponse batchWrite(BatchWriteRequest request) { + return batchWriteCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. + * 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
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   PartitionQueryRequest request = PartitionQueryRequest.newBuilder()
-   *     .setParent(parent)
-   *     .build();
-   *   ApiFuture<PartitionQueryPagedResponse> future = firestoreClient.partitionQueryPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Cursor element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
+   *   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 - partitionQueryPagedCallable() { - return stub.partitionQueryPagedCallable(); + public final UnaryCallable batchWriteCallable() { + return stub.batchWriteCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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. + * Creates a new document. * *

Sample code: * - *


+   * 
{@code
    * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
-   *   String parent = "";
-   *   PartitionQueryRequest request = PartitionQueryRequest.newBuilder()
-   *     .setParent(parent)
-   *     .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;
-   *     }
-   *   }
+   *   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 UnaryCallable - partitionQueryCallable() { - return stub.partitionQueryCallable(); + public final Document createDocument(CreateDocumentRequest request) { + return createDocumentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new document. + * + *

Sample code: + * + *

{@code
+   * 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 @@ -1202,6 +1249,87 @@ protected ListDocumentsFixedSizeCollection createCollection( } } + 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, + new ApiFunction() { + @Override + public PartitionQueryPagedResponse apply(PartitionQueryPage input) { + return 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, @@ -1283,85 +1411,4 @@ protected ListCollectionIdsFixedSizeCollection createCollection( return new ListCollectionIdsFixedSizeCollection(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, - new ApiFunction() { - @Override - public PartitionQueryPagedResponse apply(PartitionQueryPage input) { - return 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); - } - } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java index a6e012bc4..fcbe1d60b 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1; import static com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; @@ -64,7 +65,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link FirestoreClient}. * @@ -79,24 +80,25 @@ *

The builder of this class is recursive, so contained classes are themselves builders. When * build() is called, the tree of builders is called to create the complete settings object. * - *

For example, to set the total timeout of updateDocument to 30 seconds: + *

For example, to set the total timeout of getDocument to 30 seconds: * - *

- * 
- * FirestoreSettings.Builder firestoreSettingsBuilder =
- *     FirestoreSettings.newBuilder();
+ * 
{@code
+ * FirestoreSettings.Builder firestoreSettingsBuilder = FirestoreSettings.newBuilder();
  * firestoreSettingsBuilder
- *     .updateDocumentSettings()
+ *     .getDocumentSettings()
  *     .setRetrySettings(
- *         firestoreSettingsBuilder.updateDocumentSettings().getRetrySettings().toBuilder()
+ *         firestoreSettingsBuilder
+ *             .getDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * FirestoreSettings firestoreSettings = firestoreSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class FirestoreSettings extends ClientSettings { + /** Returns the object with the settings used for calls to getDocument. */ public UnaryCallSettings getDocumentSettings() { return ((FirestoreStubSettings) getStubSettings()).getDocumentSettings(); @@ -108,11 +110,6 @@ public UnaryCallSettings getDocumentSettings() { return ((FirestoreStubSettings) getStubSettings()).listDocumentsSettings(); } - /** Returns the object with the settings used for calls to createDocument. */ - public UnaryCallSettings createDocumentSettings() { - return ((FirestoreStubSettings) getStubSettings()).createDocumentSettings(); - } - /** Returns the object with the settings used for calls to updateDocument. */ public UnaryCallSettings updateDocumentSettings() { return ((FirestoreStubSettings) getStubSettings()).updateDocumentSettings(); @@ -129,11 +126,6 @@ public UnaryCallSettings deleteDocumentSettings() return ((FirestoreStubSettings) getStubSettings()).batchGetDocumentsSettings(); } - /** Returns the object with the settings used for calls to batchWrite. */ - public UnaryCallSettings batchWriteSettings() { - return ((FirestoreStubSettings) getStubSettings()).batchWriteSettings(); - } - /** Returns the object with the settings used for calls to beginTransaction. */ public UnaryCallSettings beginTransactionSettings() { @@ -155,6 +147,13 @@ public ServerStreamingCallSettings runQuerySe return ((FirestoreStubSettings) getStubSettings()).runQuerySettings(); } + /** Returns the object with the settings used for calls to partitionQuery. */ + public PagedCallSettings< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> + partitionQuerySettings() { + return ((FirestoreStubSettings) getStubSettings()).partitionQuerySettings(); + } + /** Returns the object with the settings used for calls to write. */ public StreamingCallSettings writeSettings() { return ((FirestoreStubSettings) getStubSettings()).writeSettings(); @@ -172,11 +171,14 @@ public StreamingCallSettings listenSettings() { return ((FirestoreStubSettings) getStubSettings()).listCollectionIdsSettings(); } - /** Returns the object with the settings used for calls to partitionQuery. */ - public PagedCallSettings< - PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> - partitionQuerySettings() { - return ((FirestoreStubSettings) getStubSettings()).partitionQuerySettings(); + /** Returns the object with the settings used for calls to batchWrite. */ + public UnaryCallSettings batchWriteSettings() { + return ((FirestoreStubSettings) getStubSettings()).batchWriteSettings(); + } + + /** Returns the object with the settings used for calls to createDocument. */ + public UnaryCallSettings createDocumentSettings() { + return ((FirestoreStubSettings) getStubSettings()).createDocumentSettings(); } public static final FirestoreSettings create(FirestoreStubSettings stub) throws IOException { @@ -238,18 +240,15 @@ protected FirestoreSettings(Builder settingsBuilder) throws IOException { /** Builder for FirestoreSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(FirestoreStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(FirestoreStubSettings.newBuilder()); - } - protected Builder(FirestoreSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -258,11 +257,15 @@ protected Builder(FirestoreStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(FirestoreStubSettings.newBuilder()); + } + public FirestoreStubSettings.Builder getStubSettingsBuilder() { return ((FirestoreStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -287,11 +290,6 @@ public UnaryCallSettings.Builder getDocumentSettin return getStubSettingsBuilder().listDocumentsSettings(); } - /** Returns the builder for the settings used for calls to createDocument. */ - public UnaryCallSettings.Builder createDocumentSettings() { - return getStubSettingsBuilder().createDocumentSettings(); - } - /** Returns the builder for the settings used for calls to updateDocument. */ public UnaryCallSettings.Builder updateDocumentSettings() { return getStubSettingsBuilder().updateDocumentSettings(); @@ -308,11 +306,6 @@ public UnaryCallSettings.Builder deleteDocumentSet return getStubSettingsBuilder().batchGetDocumentsSettings(); } - /** Returns the builder for the settings used for calls to batchWrite. */ - public UnaryCallSettings.Builder batchWriteSettings() { - return getStubSettingsBuilder().batchWriteSettings(); - } - /** Returns the builder for the settings used for calls to beginTransaction. */ public UnaryCallSettings.Builder beginTransactionSettings() { @@ -335,6 +328,13 @@ public UnaryCallSettings.Builder rollbackSettings() { return getStubSettingsBuilder().runQuerySettings(); } + /** Returns the builder for the settings used for calls to partitionQuery. */ + public PagedCallSettings.Builder< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> + partitionQuerySettings() { + return getStubSettingsBuilder().partitionQuerySettings(); + } + /** Returns the builder for the settings used for calls to write. */ public StreamingCallSettings.Builder writeSettings() { return getStubSettingsBuilder().writeSettings(); @@ -352,11 +352,14 @@ public StreamingCallSettings.Builder listenSettin return getStubSettingsBuilder().listCollectionIdsSettings(); } - /** Returns the builder for the settings used for calls to partitionQuery. */ - public PagedCallSettings.Builder< - PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> - partitionQuerySettings() { - return getStubSettingsBuilder().partitionQuerySettings(); + /** Returns the builder for the settings used for calls to batchWrite. */ + public UnaryCallSettings.Builder batchWriteSettings() { + return getStubSettingsBuilder().batchWriteSettings(); + } + + /** Returns the builder for the settings used for calls to createDocument. */ + public UnaryCallSettings.Builder createDocumentSettings() { + return getStubSettingsBuilder().createDocumentSettings(); } @Override diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json new file mode 100644 index 000000000..fc351054c --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json @@ -0,0 +1,63 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.firestore.v1", + "libraryPackage": "com.google.cloud.firestore.v1", + "services": { + "Firestore": { + "clients": { + "grpc": { + "libraryClient": "FirestoreClient", + "rpcs": { + "BatchGetDocuments": { + "methods": ["batchGetDocumentsCallable"] + }, + "BatchWrite": { + "methods": ["batchWrite", "batchWriteCallable"] + }, + "BeginTransaction": { + "methods": ["beginTransaction", "beginTransaction", "beginTransactionCallable"] + }, + "Commit": { + "methods": ["commit", "commit", "commitCallable"] + }, + "CreateDocument": { + "methods": ["createDocument", "createDocumentCallable"] + }, + "DeleteDocument": { + "methods": ["deleteDocument", "deleteDocument", "deleteDocumentCallable"] + }, + "GetDocument": { + "methods": ["getDocument", "getDocumentCallable"] + }, + "ListCollectionIds": { + "methods": ["listCollectionIds", "listCollectionIds", "listCollectionIdsPagedCallable", "listCollectionIdsCallable"] + }, + "ListDocuments": { + "methods": ["listDocuments", "listDocumentsPagedCallable", "listDocumentsCallable"] + }, + "Listen": { + "methods": ["listenCallable"] + }, + "PartitionQuery": { + "methods": ["partitionQuery", "partitionQueryPagedCallable", "partitionQueryCallable"] + }, + "Rollback": { + "methods": ["rollback", "rollback", "rollbackCallable"] + }, + "RunQuery": { + "methods": ["runQueryCallable"] + }, + "UpdateDocument": { + "methods": ["updateDocument", "updateDocument", "updateDocumentCallable"] + }, + "Write": { + "methods": ["writeCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java index c34bfe838..28aa2f7d8 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -15,11 +15,9 @@ */ /** - * A client to Google Cloud Firestore API. + * The interfaces provided are listed below, along with usage samples. * - *

The interfaces provided are listed below, along with usage samples. - * - *

=============== FirestoreClient =============== + *

======================= FirestoreClient ======================= * *

Service Description: The Cloud Firestore service. * @@ -31,17 +29,18 @@ * *

Sample for FirestoreClient: * - *

- * 
+ * 
{@code
  * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- *   Document document = Document.newBuilder().build();
- *   DocumentMask updateMask = DocumentMask.newBuilder().build();
- *   Document response = firestoreClient.updateDocument(document, updateMask);
+ *   GetDocumentRequest request =
+ *       GetDocumentRequest.newBuilder()
+ *           .setName("name3373707")
+ *           .setMask(DocumentMask.newBuilder().build())
+ *           .build();
+ *   Document response = firestoreClient.getDocument(request);
  * }
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.firestore.v1; import javax.annotation.Generated; diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java index 83f0613fb..ef46fb0c0 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; import static com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; import static com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; import static com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.BidiStreamingCallable; import com.google.api.gax.rpc.ServerStreamingCallable; @@ -53,14 +53,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Google Cloud Firestore API. + * Base stub class for the Firestore service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public abstract class FirestoreStub implements BackgroundResource { public UnaryCallable getDocumentCallable() { @@ -76,10 +75,6 @@ public UnaryCallable listDocumentsC throw new UnsupportedOperationException("Not implemented: listDocumentsCallable()"); } - public UnaryCallable createDocumentCallable() { - throw new UnsupportedOperationException("Not implemented: createDocumentCallable()"); - } - public UnaryCallable updateDocumentCallable() { throw new UnsupportedOperationException("Not implemented: updateDocumentCallable()"); } @@ -93,10 +88,6 @@ public UnaryCallable deleteDocumentCallable() { throw new UnsupportedOperationException("Not implemented: batchGetDocumentsCallable()"); } - public UnaryCallable batchWriteCallable() { - throw new UnsupportedOperationException("Not implemented: batchWriteCallable()"); - } - public UnaryCallable beginTransactionCallable() { throw new UnsupportedOperationException("Not implemented: beginTransactionCallable()"); @@ -114,6 +105,15 @@ public ServerStreamingCallable runQueryCallab throw new UnsupportedOperationException("Not implemented: runQueryCallable()"); } + public UnaryCallable + partitionQueryPagedCallable() { + throw new UnsupportedOperationException("Not implemented: partitionQueryPagedCallable()"); + } + + public UnaryCallable partitionQueryCallable() { + throw new UnsupportedOperationException("Not implemented: partitionQueryCallable()"); + } + public BidiStreamingCallable writeCallable() { throw new UnsupportedOperationException("Not implemented: writeCallable()"); } @@ -132,13 +132,12 @@ public BidiStreamingCallable listenCallable() { throw new UnsupportedOperationException("Not implemented: listCollectionIdsCallable()"); } - public UnaryCallable - partitionQueryPagedCallable() { - throw new UnsupportedOperationException("Not implemented: partitionQueryPagedCallable()"); + public UnaryCallable batchWriteCallable() { + throw new UnsupportedOperationException("Not implemented: batchWriteCallable()"); } - public UnaryCallable partitionQueryCallable() { - throw new UnsupportedOperationException("Not implemented: partitionQueryCallable()"); + public UnaryCallable createDocumentCallable() { + throw new UnsupportedOperationException("Not implemented: createDocumentCallable()"); } @Override diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java index 394df8ca8..9b3560334 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; import static com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; @@ -80,7 +81,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link FirestoreStub}. * @@ -95,23 +96,23 @@ *

The builder of this class is recursive, so contained classes are themselves builders. When * build() is called, the tree of builders is called to create the complete settings object. * - *

For example, to set the total timeout of updateDocument to 30 seconds: + *

For example, to set the total timeout of getDocument to 30 seconds: * - *

- * 
- * FirestoreStubSettings.Builder firestoreSettingsBuilder =
- *     FirestoreStubSettings.newBuilder();
+ * 
{@code
+ * FirestoreStubSettings.Builder firestoreSettingsBuilder = FirestoreStubSettings.newBuilder();
  * firestoreSettingsBuilder
- *     .updateDocumentSettings()
+ *     .getDocumentSettings()
  *     .setRetrySettings(
- *         firestoreSettingsBuilder.updateDocumentSettings().getRetrySettings().toBuilder()
+ *         firestoreSettingsBuilder
+ *             .getDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * FirestoreStubSettings firestoreSettings = firestoreSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class FirestoreStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -124,25 +125,190 @@ public class FirestoreStubSettings extends StubSettings { private final PagedCallSettings< ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> listDocumentsSettings; - private final UnaryCallSettings createDocumentSettings; private final UnaryCallSettings updateDocumentSettings; private final UnaryCallSettings deleteDocumentSettings; private final ServerStreamingCallSettings batchGetDocumentsSettings; - private final UnaryCallSettings batchWriteSettings; private final UnaryCallSettings beginTransactionSettings; private final UnaryCallSettings commitSettings; private final UnaryCallSettings rollbackSettings; private final ServerStreamingCallSettings runQuerySettings; + private final PagedCallSettings< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> + partitionQuerySettings; private final StreamingCallSettings writeSettings; private final StreamingCallSettings listenSettings; private final PagedCallSettings< ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> listCollectionIdsSettings; - private final PagedCallSettings< + private final UnaryCallSettings batchWriteSettings; + private final UnaryCallSettings createDocumentSettings; + + private static final PagedListDescriptor + LIST_DOCUMENTS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListDocumentsRequest injectToken(ListDocumentsRequest payload, String token) { + return ListDocumentsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListDocumentsRequest injectPageSize(ListDocumentsRequest payload, int pageSize) { + return ListDocumentsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListDocumentsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListDocumentsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListDocumentsResponse payload) { + return payload.getDocumentsList() == null + ? ImmutableList.of() + : payload.getDocumentsList(); + } + }; + + private static final PagedListDescriptor + PARTITION_QUERY_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public PartitionQueryRequest injectToken(PartitionQueryRequest payload, String token) { + return PartitionQueryRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public PartitionQueryRequest injectPageSize( + PartitionQueryRequest payload, int pageSize) { + return PartitionQueryRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(PartitionQueryRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(PartitionQueryResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(PartitionQueryResponse payload) { + return payload.getPartitionsList() == null + ? ImmutableList.of() + : payload.getPartitionsList(); + } + }; + + private static final PagedListDescriptor< + ListCollectionIdsRequest, ListCollectionIdsResponse, String> + LIST_COLLECTION_IDS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListCollectionIdsRequest injectToken( + ListCollectionIdsRequest payload, String token) { + return ListCollectionIdsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListCollectionIdsRequest injectPageSize( + ListCollectionIdsRequest payload, int pageSize) { + return ListCollectionIdsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListCollectionIdsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListCollectionIdsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListCollectionIdsResponse payload) { + return payload.getCollectionIdsList() == null + ? ImmutableList.of() + : payload.getCollectionIdsList(); + } + }; + + private static final PagedListResponseFactory< + ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> + LIST_DOCUMENTS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListDocumentsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_DOCUMENTS_PAGE_STR_DESC, request, context); + return ListDocumentsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> - partitionQuerySettings; + PARTITION_QUERY_PAGE_STR_FACT = + new PagedListResponseFactory< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + PartitionQueryRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, PARTITION_QUERY_PAGE_STR_DESC, request, context); + return PartitionQueryPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> + LIST_COLLECTION_IDS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListCollectionIdsRequest, + ListCollectionIdsResponse, + ListCollectionIdsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListCollectionIdsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_COLLECTION_IDS_PAGE_STR_DESC, request, context); + return ListCollectionIdsPagedResponse.createAsync(pageContext, futureResponse); + } + }; /** Returns the object with the settings used for calls to getDocument. */ public UnaryCallSettings getDocumentSettings() { @@ -155,11 +321,6 @@ public UnaryCallSettings getDocumentSettings() { return listDocumentsSettings; } - /** Returns the object with the settings used for calls to createDocument. */ - public UnaryCallSettings createDocumentSettings() { - return createDocumentSettings; - } - /** Returns the object with the settings used for calls to updateDocument. */ public UnaryCallSettings updateDocumentSettings() { return updateDocumentSettings; @@ -176,11 +337,6 @@ public UnaryCallSettings deleteDocumentSettings() return batchGetDocumentsSettings; } - /** Returns the object with the settings used for calls to batchWrite. */ - public UnaryCallSettings batchWriteSettings() { - return batchWriteSettings; - } - /** Returns the object with the settings used for calls to beginTransaction. */ public UnaryCallSettings beginTransactionSettings() { @@ -202,6 +358,13 @@ public ServerStreamingCallSettings runQuerySe return runQuerySettings; } + /** Returns the object with the settings used for calls to partitionQuery. */ + public PagedCallSettings< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> + partitionQuerySettings() { + return partitionQuerySettings; + } + /** Returns the object with the settings used for calls to write. */ public StreamingCallSettings writeSettings() { return writeSettings; @@ -219,11 +382,14 @@ public StreamingCallSettings listenSettings() { return listCollectionIdsSettings; } - /** Returns the object with the settings used for calls to partitionQuery. */ - public PagedCallSettings< - PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> - partitionQuerySettings() { - return partitionQuerySettings; + /** Returns the object with the settings used for calls to batchWrite. */ + public UnaryCallSettings batchWriteSettings() { + return batchWriteSettings; + } + + /** Returns the object with the settings used for calls to createDocument. */ + public UnaryCallSettings createDocumentSettings() { + return createDocumentSettings; } @BetaApi("A restructuring of stub classes is planned, so this may break in the future") @@ -232,10 +398,10 @@ public FirestoreStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcFirestoreStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -296,241 +462,94 @@ protected FirestoreStubSettings(Builder settingsBuilder) throws IOException { getDocumentSettings = settingsBuilder.getDocumentSettings().build(); listDocumentsSettings = settingsBuilder.listDocumentsSettings().build(); - createDocumentSettings = settingsBuilder.createDocumentSettings().build(); updateDocumentSettings = settingsBuilder.updateDocumentSettings().build(); deleteDocumentSettings = settingsBuilder.deleteDocumentSettings().build(); batchGetDocumentsSettings = settingsBuilder.batchGetDocumentsSettings().build(); - batchWriteSettings = settingsBuilder.batchWriteSettings().build(); beginTransactionSettings = settingsBuilder.beginTransactionSettings().build(); commitSettings = settingsBuilder.commitSettings().build(); rollbackSettings = settingsBuilder.rollbackSettings().build(); runQuerySettings = settingsBuilder.runQuerySettings().build(); + partitionQuerySettings = settingsBuilder.partitionQuerySettings().build(); writeSettings = settingsBuilder.writeSettings().build(); listenSettings = settingsBuilder.listenSettings().build(); listCollectionIdsSettings = settingsBuilder.listCollectionIdsSettings().build(); - partitionQuerySettings = settingsBuilder.partitionQuerySettings().build(); + batchWriteSettings = settingsBuilder.batchWriteSettings().build(); + createDocumentSettings = settingsBuilder.createDocumentSettings().build(); } - private static final PagedListDescriptor - LIST_DOCUMENTS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListDocumentsRequest injectToken(ListDocumentsRequest payload, String token) { - return ListDocumentsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListDocumentsRequest injectPageSize(ListDocumentsRequest payload, int pageSize) { - return ListDocumentsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListDocumentsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListDocumentsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListDocumentsResponse payload) { - return payload.getDocumentsList() != null - ? payload.getDocumentsList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListCollectionIdsRequest, ListCollectionIdsResponse, String> - LIST_COLLECTION_IDS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListCollectionIdsRequest injectToken( - ListCollectionIdsRequest payload, String token) { - return ListCollectionIdsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListCollectionIdsRequest injectPageSize( - ListCollectionIdsRequest payload, int pageSize) { - return ListCollectionIdsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListCollectionIdsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListCollectionIdsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListCollectionIdsResponse payload) { - return payload.getCollectionIdsList() != null - ? payload.getCollectionIdsList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor - PARTITION_QUERY_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public PartitionQueryRequest injectToken(PartitionQueryRequest payload, String token) { - return PartitionQueryRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public PartitionQueryRequest injectPageSize( - PartitionQueryRequest payload, int pageSize) { - return PartitionQueryRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(PartitionQueryRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(PartitionQueryResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(PartitionQueryResponse payload) { - return payload.getPartitionsList() != null - ? payload.getPartitionsList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> - LIST_DOCUMENTS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListDocumentsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_DOCUMENTS_PAGE_STR_DESC, request, context); - return ListDocumentsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> - LIST_COLLECTION_IDS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListCollectionIdsRequest, - ListCollectionIdsResponse, - ListCollectionIdsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListCollectionIdsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_COLLECTION_IDS_PAGE_STR_DESC, request, context); - return ListCollectionIdsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> - PARTITION_QUERY_PAGE_STR_FACT = - new PagedListResponseFactory< - PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - PartitionQueryRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, PARTITION_QUERY_PAGE_STR_DESC, request, context); - return PartitionQueryPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Builder for FirestoreStubSettings. */ - public static class Builder extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final UnaryCallSettings.Builder getDocumentSettings; - private final PagedCallSettings.Builder< - ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> - listDocumentsSettings; - private final UnaryCallSettings.Builder createDocumentSettings; - private final UnaryCallSettings.Builder updateDocumentSettings; - private final UnaryCallSettings.Builder deleteDocumentSettings; - private final ServerStreamingCallSettings.Builder< - BatchGetDocumentsRequest, BatchGetDocumentsResponse> - batchGetDocumentsSettings; - private final UnaryCallSettings.Builder - batchWriteSettings; - private final UnaryCallSettings.Builder - beginTransactionSettings; - private final UnaryCallSettings.Builder commitSettings; - private final UnaryCallSettings.Builder rollbackSettings; - private final ServerStreamingCallSettings.Builder - runQuerySettings; - private final StreamingCallSettings.Builder writeSettings; - private final StreamingCallSettings.Builder listenSettings; - private final PagedCallSettings.Builder< - ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> - listCollectionIdsSettings; - private final PagedCallSettings.Builder< - PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> - partitionQuerySettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; + /** Builder for FirestoreStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder getDocumentSettings; + private final PagedCallSettings.Builder< + ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> + listDocumentsSettings; + private final UnaryCallSettings.Builder updateDocumentSettings; + private final UnaryCallSettings.Builder deleteDocumentSettings; + private final ServerStreamingCallSettings.Builder< + BatchGetDocumentsRequest, BatchGetDocumentsResponse> + batchGetDocumentsSettings; + private final UnaryCallSettings.Builder + beginTransactionSettings; + private final UnaryCallSettings.Builder commitSettings; + private final UnaryCallSettings.Builder rollbackSettings; + private final ServerStreamingCallSettings.Builder + runQuerySettings; + private final PagedCallSettings.Builder< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> + partitionQuerySettings; + private final StreamingCallSettings.Builder writeSettings; + private final StreamingCallSettings.Builder listenSettings; + private final PagedCallSettings.Builder< + ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> + listCollectionIdsSettings; + private final UnaryCallSettings.Builder + batchWriteSettings; + private final UnaryCallSettings.Builder createDocumentSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( - "idempotent", + "retry_policy_4_codes", ImmutableSet.copyOf( Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, + StatusCode.Code.RESOURCE_EXHAUSTED, + StatusCode.Code.UNAVAILABLE, StatusCode.Code.INTERNAL, - StatusCode.Code.UNAVAILABLE))); + StatusCode.Code.DEADLINE_EXCEEDED))); definitions.put( - "aborted_unavailable", + "retry_policy_0_codes", ImmutableSet.copyOf( Lists.newArrayList( - StatusCode.Code.ABORTED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); + StatusCode.Code.RESOURCE_EXHAUSTED, StatusCode.Code.UNAVAILABLE))); definitions.put( - "idempotent2", + "retry_policy_1_codes", ImmutableSet.copyOf( Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + StatusCode.Code.RESOURCE_EXHAUSTED, + StatusCode.Code.UNAVAILABLE, + StatusCode.Code.INTERNAL, + StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put( + "retry_policy_2_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.RESOURCE_EXHAUSTED, + StatusCode.Code.UNAVAILABLE, + StatusCode.Code.INTERNAL, + StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "retry_policy_5_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.RESOURCE_EXHAUSTED, + StatusCode.Code.UNAVAILABLE, + StatusCode.Code.ABORTED))); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -547,9 +566,50 @@ public static class Builder extends StubSettings.Builder>of( getDocumentSettings, listDocumentsSettings, - createDocumentSettings, updateDocumentSettings, deleteDocumentSettings, - batchWriteSettings, beginTransactionSettings, commitSettings, rollbackSettings, + partitionQuerySettings, listCollectionIdsSettings, - partitionQuerySettings); - + batchWriteSettings, + createDocumentSettings); initDefaults(this); } + protected Builder(FirestoreStubSettings settings) { + super(settings); + + getDocumentSettings = settings.getDocumentSettings.toBuilder(); + listDocumentsSettings = settings.listDocumentsSettings.toBuilder(); + updateDocumentSettings = settings.updateDocumentSettings.toBuilder(); + deleteDocumentSettings = settings.deleteDocumentSettings.toBuilder(); + batchGetDocumentsSettings = settings.batchGetDocumentsSettings.toBuilder(); + beginTransactionSettings = settings.beginTransactionSettings.toBuilder(); + commitSettings = settings.commitSettings.toBuilder(); + rollbackSettings = settings.rollbackSettings.toBuilder(); + runQuerySettings = settings.runQuerySettings.toBuilder(); + partitionQuerySettings = settings.partitionQuerySettings.toBuilder(); + writeSettings = settings.writeSettings.toBuilder(); + listenSettings = settings.listenSettings.toBuilder(); + listCollectionIdsSettings = settings.listCollectionIdsSettings.toBuilder(); + batchWriteSettings = settings.batchWriteSettings.toBuilder(); + createDocumentSettings = settings.createDocumentSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + getDocumentSettings, + listDocumentsSettings, + updateDocumentSettings, + deleteDocumentSettings, + beginTransactionSettings, + commitSettings, + rollbackSettings, + partitionQuerySettings, + listCollectionIdsSettings, + batchWriteSettings, + createDocumentSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); } private static Builder initDefaults(Builder builder) { - builder .getDocumentSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .listDocumentsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createDocumentSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .updateDocumentSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .deleteDocumentSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .batchGetDocumentsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("streaming")); - - builder - .batchWriteSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("aborted_unavailable")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .beginTransactionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .commitSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); builder .rollbackSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .runQuerySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("streaming")); - - builder - .listCollectionIdsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); builder .partitionQuerySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - return builder; - } + builder + .listCollectionIdsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); - protected Builder(FirestoreStubSettings settings) { - super(settings); + builder + .batchWriteSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); - getDocumentSettings = settings.getDocumentSettings.toBuilder(); - listDocumentsSettings = settings.listDocumentsSettings.toBuilder(); - createDocumentSettings = settings.createDocumentSettings.toBuilder(); - updateDocumentSettings = settings.updateDocumentSettings.toBuilder(); - deleteDocumentSettings = settings.deleteDocumentSettings.toBuilder(); - batchGetDocumentsSettings = settings.batchGetDocumentsSettings.toBuilder(); - batchWriteSettings = settings.batchWriteSettings.toBuilder(); - beginTransactionSettings = settings.beginTransactionSettings.toBuilder(); - commitSettings = settings.commitSettings.toBuilder(); - rollbackSettings = settings.rollbackSettings.toBuilder(); - runQuerySettings = settings.runQuerySettings.toBuilder(); - writeSettings = settings.writeSettings.toBuilder(); - listenSettings = settings.listenSettings.toBuilder(); - listCollectionIdsSettings = settings.listCollectionIdsSettings.toBuilder(); - partitionQuerySettings = settings.partitionQuerySettings.toBuilder(); + builder + .createDocumentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); - unaryMethodSettingsBuilders = - ImmutableList.>of( - getDocumentSettings, - listDocumentsSettings, - createDocumentSettings, - updateDocumentSettings, - deleteDocumentSettings, - batchWriteSettings, - beginTransactionSettings, - commitSettings, - rollbackSettings, - listCollectionIdsSettings, - partitionQuerySettings); + return builder; } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -759,11 +805,6 @@ public UnaryCallSettings.Builder getDocumentSettin return listDocumentsSettings; } - /** Returns the builder for the settings used for calls to createDocument. */ - public UnaryCallSettings.Builder createDocumentSettings() { - return createDocumentSettings; - } - /** Returns the builder for the settings used for calls to updateDocument. */ public UnaryCallSettings.Builder updateDocumentSettings() { return updateDocumentSettings; @@ -780,11 +821,6 @@ public UnaryCallSettings.Builder deleteDocumentSet return batchGetDocumentsSettings; } - /** Returns the builder for the settings used for calls to batchWrite. */ - public UnaryCallSettings.Builder batchWriteSettings() { - return batchWriteSettings; - } - /** Returns the builder for the settings used for calls to beginTransaction. */ public UnaryCallSettings.Builder beginTransactionSettings() { @@ -807,6 +843,13 @@ public UnaryCallSettings.Builder rollbackSettings() { return runQuerySettings; } + /** Returns the builder for the settings used for calls to partitionQuery. */ + public PagedCallSettings.Builder< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> + partitionQuerySettings() { + return partitionQuerySettings; + } + /** Returns the builder for the settings used for calls to write. */ public StreamingCallSettings.Builder writeSettings() { return writeSettings; @@ -824,11 +867,14 @@ public StreamingCallSettings.Builder listenSettin return listCollectionIdsSettings; } - /** Returns the builder for the settings used for calls to partitionQuery. */ - public PagedCallSettings.Builder< - PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> - partitionQuerySettings() { - return partitionQuerySettings; + /** Returns the builder for the settings used for calls to batchWrite. */ + public UnaryCallSettings.Builder batchWriteSettings() { + return batchWriteSettings; + } + + /** Returns the builder for the settings used for calls to createDocument. */ + public UnaryCallSettings.Builder createDocumentSettings() { + return createDocumentSettings; } @Override diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java index 8990b5aac..56fb2a81c 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,18 +31,19 @@ import com.google.api.gax.rpc.StreamingCallSettings; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Google Cloud Firestore API. + * gRPC callable factory implementation for the Firestore service API. * *

This class is for advanced usage. */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +@Generated("by gapic-generator-java") public class GrpcFirestoreCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java index 14b902f69..a80ef708d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1.stub; import static com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; import static com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; import static com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -56,6 +56,7 @@ import com.google.firestore.v1.UpdateDocumentRequest; import com.google.firestore.v1.WriteRequest; import com.google.firestore.v1.WriteResponse; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.protobuf.Empty; import io.grpc.MethodDescriptor; import io.grpc.protobuf.ProtoUtils; @@ -64,16 +65,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Google Cloud Firestore API. + * gRPC stub implementation for the Firestore service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public class GrpcFirestoreStub extends FirestoreStub { - private static final MethodDescriptor getDocumentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -81,6 +80,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setRequestMarshaller(ProtoUtils.marshaller(GetDocumentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance())) .build(); + private static final MethodDescriptor listDocumentsMethodDescriptor = MethodDescriptor.newBuilder() @@ -91,15 +91,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setResponseMarshaller( ProtoUtils.marshaller(ListDocumentsResponse.getDefaultInstance())) .build(); - private static final MethodDescriptor - createDocumentMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.firestore.v1.Firestore/CreateDocument") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateDocumentRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance())) - .build(); + private static final MethodDescriptor updateDocumentMethodDescriptor = MethodDescriptor.newBuilder() @@ -109,6 +101,7 @@ public class GrpcFirestoreStub extends FirestoreStub { ProtoUtils.marshaller(UpdateDocumentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteDocumentMethodDescriptor = MethodDescriptor.newBuilder() @@ -118,6 +111,7 @@ public class GrpcFirestoreStub extends FirestoreStub { ProtoUtils.marshaller(DeleteDocumentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor batchGetDocumentsMethodDescriptor = MethodDescriptor.newBuilder() @@ -128,14 +122,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setResponseMarshaller( ProtoUtils.marshaller(BatchGetDocumentsResponse.getDefaultInstance())) .build(); - private static final MethodDescriptor - batchWriteMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.firestore.v1.Firestore/BatchWrite") - .setRequestMarshaller(ProtoUtils.marshaller(BatchWriteRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(BatchWriteResponse.getDefaultInstance())) - .build(); + private static final MethodDescriptor beginTransactionMethodDescriptor = MethodDescriptor.newBuilder() @@ -146,6 +133,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setResponseMarshaller( ProtoUtils.marshaller(BeginTransactionResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor commitMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -153,6 +141,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setRequestMarshaller(ProtoUtils.marshaller(CommitRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(CommitResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor rollbackMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -160,6 +149,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setRequestMarshaller(ProtoUtils.marshaller(RollbackRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor runQueryMethodDescriptor = MethodDescriptor.newBuilder() @@ -168,6 +158,18 @@ public class GrpcFirestoreStub extends FirestoreStub { .setRequestMarshaller(ProtoUtils.marshaller(RunQueryRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(RunQueryResponse.getDefaultInstance())) .build(); + + private static final MethodDescriptor + partitionQueryMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/PartitionQuery") + .setRequestMarshaller( + ProtoUtils.marshaller(PartitionQueryRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(PartitionQueryResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor writeMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.BIDI_STREAMING) @@ -175,6 +177,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setRequestMarshaller(ProtoUtils.marshaller(WriteRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(WriteResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor listenMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.BIDI_STREAMING) @@ -182,6 +185,7 @@ public class GrpcFirestoreStub extends FirestoreStub { .setRequestMarshaller(ProtoUtils.marshaller(ListenRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(ListenResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor listCollectionIdsMethodDescriptor = MethodDescriptor.newBuilder() @@ -192,44 +196,53 @@ public class GrpcFirestoreStub extends FirestoreStub { .setResponseMarshaller( ProtoUtils.marshaller(ListCollectionIdsResponse.getDefaultInstance())) .build(); - private static final MethodDescriptor - partitionQueryMethodDescriptor = - MethodDescriptor.newBuilder() + + private static final MethodDescriptor + batchWriteMethodDescriptor = + MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.firestore.v1.Firestore/PartitionQuery") - .setRequestMarshaller( - ProtoUtils.marshaller(PartitionQueryRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(PartitionQueryResponse.getDefaultInstance())) + .setFullMethodName("google.firestore.v1.Firestore/BatchWrite") + .setRequestMarshaller(ProtoUtils.marshaller(BatchWriteRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BatchWriteResponse.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; + private static final MethodDescriptor + createDocumentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/CreateDocument") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateDocumentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance())) + .build(); private final UnaryCallable getDocumentCallable; private final UnaryCallable listDocumentsCallable; private final UnaryCallable listDocumentsPagedCallable; - private final UnaryCallable createDocumentCallable; private final UnaryCallable updateDocumentCallable; private final UnaryCallable deleteDocumentCallable; private final ServerStreamingCallable batchGetDocumentsCallable; - private final UnaryCallable batchWriteCallable; private final UnaryCallable beginTransactionCallable; private final UnaryCallable commitCallable; private final UnaryCallable rollbackCallable; private final ServerStreamingCallable runQueryCallable; + private final UnaryCallable partitionQueryCallable; + private final UnaryCallable + partitionQueryPagedCallable; private final BidiStreamingCallable writeCallable; private final BidiStreamingCallable listenCallable; private final UnaryCallable listCollectionIdsCallable; private final UnaryCallable listCollectionIdsPagedCallable; - private final UnaryCallable partitionQueryCallable; - private final UnaryCallable - partitionQueryPagedCallable; + private final UnaryCallable batchWriteCallable; + private final UnaryCallable createDocumentCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcFirestoreStub create(FirestoreStubSettings settings) throws IOException { @@ -267,6 +280,7 @@ protected GrpcFirestoreStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings getDocumentTransportSettings = GrpcCallSettings.newBuilder() @@ -284,10 +298,16 @@ public Map extract(GetDocumentRequest request) { GrpcCallSettings listDocumentsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listDocumentsMethodDescriptor) - .build(); - GrpcCallSettings createDocumentTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createDocumentMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListDocumentsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("collection_id", String.valueOf(request.getCollectionId())); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) .build(); GrpcCallSettings updateDocumentTransportSettings = GrpcCallSettings.newBuilder() @@ -329,19 +349,6 @@ public Map extract(BatchGetDocumentsRequest request) { } }) .build(); - GrpcCallSettings batchWriteTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(batchWriteMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(BatchWriteRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("database", String.valueOf(request.getDatabase())); - return params.build(); - } - }) - .build(); GrpcCallSettings beginTransactionTransportSettings = GrpcCallSettings.newBuilder() @@ -395,13 +402,45 @@ public Map extract(RunQueryRequest request) { } }) .build(); + GrpcCallSettings + partitionQueryTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(partitionQueryMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(PartitionQueryRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); GrpcCallSettings writeTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(writeMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(WriteRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("database", String.valueOf(request.getDatabase())); + return params.build(); + } + }) .build(); GrpcCallSettings listenTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listenMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListenRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("database", String.valueOf(request.getDatabase())); + return params.build(); + } + }) .build(); GrpcCallSettings listCollectionIdsTransportSettings = @@ -417,20 +456,33 @@ public Map extract(ListCollectionIdsRequest request) { } }) .build(); - GrpcCallSettings - partitionQueryTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(partitionQueryMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(PartitionQueryRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); + GrpcCallSettings batchWriteTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchWriteMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(BatchWriteRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("database", String.valueOf(request.getDatabase())); + return params.build(); + } + }) + .build(); + GrpcCallSettings createDocumentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createDocumentMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreateDocumentRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("collection_id", String.valueOf(request.getCollectionId())); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); this.getDocumentCallable = callableFactory.createUnaryCallable( @@ -441,9 +493,6 @@ public Map extract(PartitionQueryRequest request) { this.listDocumentsPagedCallable = callableFactory.createPagedCallable( listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); - this.createDocumentCallable = - callableFactory.createUnaryCallable( - createDocumentTransportSettings, settings.createDocumentSettings(), clientContext); this.updateDocumentCallable = callableFactory.createUnaryCallable( updateDocumentTransportSettings, settings.updateDocumentSettings(), clientContext); @@ -455,9 +504,6 @@ public Map extract(PartitionQueryRequest request) { batchGetDocumentsTransportSettings, settings.batchGetDocumentsSettings(), clientContext); - this.batchWriteCallable = - callableFactory.createUnaryCallable( - batchWriteTransportSettings, settings.batchWriteSettings(), clientContext); this.beginTransactionCallable = callableFactory.createUnaryCallable( beginTransactionTransportSettings, settings.beginTransactionSettings(), clientContext); @@ -470,6 +516,12 @@ public Map extract(PartitionQueryRequest request) { this.runQueryCallable = callableFactory.createServerStreamingCallable( runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.partitionQueryCallable = + callableFactory.createUnaryCallable( + partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); + this.partitionQueryPagedCallable = + callableFactory.createPagedCallable( + partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); this.writeCallable = callableFactory.createBidiStreamingCallable( writeTransportSettings, settings.writeSettings(), clientContext); @@ -486,92 +538,115 @@ public Map extract(PartitionQueryRequest request) { listCollectionIdsTransportSettings, settings.listCollectionIdsSettings(), clientContext); - this.partitionQueryCallable = + this.batchWriteCallable = callableFactory.createUnaryCallable( - partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); - this.partitionQueryPagedCallable = - callableFactory.createPagedCallable( - partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); + batchWriteTransportSettings, settings.batchWriteSettings(), clientContext); + this.createDocumentCallable = + callableFactory.createUnaryCallable( + createDocumentTransportSettings, settings.createDocumentSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - public UnaryCallable getDocumentCallable() { - return getDocumentCallable; + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } - public UnaryCallable - listDocumentsPagedCallable() { - return listDocumentsPagedCallable; + @Override + public UnaryCallable getDocumentCallable() { + return getDocumentCallable; } + @Override public UnaryCallable listDocumentsCallable() { return listDocumentsCallable; } - public UnaryCallable createDocumentCallable() { - return createDocumentCallable; + @Override + public UnaryCallable + listDocumentsPagedCallable() { + return listDocumentsPagedCallable; } + @Override public UnaryCallable updateDocumentCallable() { return updateDocumentCallable; } + @Override public UnaryCallable deleteDocumentCallable() { return deleteDocumentCallable; } + @Override public ServerStreamingCallable batchGetDocumentsCallable() { return batchGetDocumentsCallable; } - public UnaryCallable batchWriteCallable() { - return batchWriteCallable; - } - + @Override public UnaryCallable beginTransactionCallable() { return beginTransactionCallable; } + @Override public UnaryCallable commitCallable() { return commitCallable; } + @Override public UnaryCallable rollbackCallable() { return rollbackCallable; } + @Override public ServerStreamingCallable runQueryCallable() { return runQueryCallable; } + @Override + public UnaryCallable partitionQueryCallable() { + return partitionQueryCallable; + } + + @Override + public UnaryCallable + partitionQueryPagedCallable() { + return partitionQueryPagedCallable; + } + + @Override public BidiStreamingCallable writeCallable() { return writeCallable; } + @Override public BidiStreamingCallable listenCallable() { return listenCallable; } - public UnaryCallable - listCollectionIdsPagedCallable() { - return listCollectionIdsPagedCallable; - } - + @Override public UnaryCallable listCollectionIdsCallable() { return listCollectionIdsCallable; } - public UnaryCallable - partitionQueryPagedCallable() { - return partitionQueryPagedCallable; + @Override + public UnaryCallable + listCollectionIdsPagedCallable() { + return listCollectionIdsPagedCallable; } - public UnaryCallable partitionQueryCallable() { - return partitionQueryCallable; + @Override + public UnaryCallable batchWriteCallable() { + return batchWriteCallable; + } + + @Override + public UnaryCallable createDocumentCallable() { + return createDocumentCallable; } @Override diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/BulkWriterTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/BulkWriterTest.java index 289952238..daf90171c 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/BulkWriterTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/BulkWriterTest.java @@ -422,6 +422,41 @@ public void sendWritesToDifferentDocsInSameBatch() throws Exception { assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result2.get().getUpdateTime()); } + @Test + public void buffersSubsequentOpsAfterReachingMaxPendingOpCount() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3")), + mergeResponses( + successResponse(1), + successResponse(2), + failedResponse(Code.FAILED_PRECONDITION_VALUE))); + put( + batchWrite( + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc4"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc5")), + mergeResponses(successResponse(4), successResponse(5))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter.setMaxPendingOpCount(3); + bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(firestoreMock.document("coll/doc3"), LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(firestoreMock.document("coll/doc4"), LocalFirestoreHelper.SINGLE_FIELD_MAP); + assertEquals(1, bulkWriter.getBufferedOperationsCount()); + bulkWriter.set(firestoreMock.document("coll/doc5"), LocalFirestoreHelper.SINGLE_FIELD_MAP); + assertEquals(2, bulkWriter.getBufferedOperationsCount()); + bulkWriter.close(); + responseStubber.verifyAllRequestsSent(); + } + @Test public void runsSuccessHandler() throws Exception { ResponseStubber responseStubber = @@ -1260,6 +1295,7 @@ public boolean onError(BulkWriterException error) { bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); bulkWriter.close(); + responseStubber.verifyAllRequestsSent(); assertEquals(2, retryAttempts[0]); } @@ -1291,6 +1327,7 @@ public boolean onError(BulkWriterException error) { bulkWriter.flush(); bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); bulkWriter.close(); + responseStubber.verifyAllRequestsSent(); } @Test diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java index 2d55b7d61..83cc545b4 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.firestore.v1; import static com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; @@ -58,20 +59,25 @@ import com.google.firestore.v1.RunQueryRequest; import com.google.firestore.v1.RunQueryResponse; import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.Value; import com.google.firestore.v1.Write; import com.google.firestore.v1.WriteRequest; import com.google.firestore.v1.WriteResponse; +import com.google.firestore.v1.WriteResult; import com.google.protobuf.AbstractMessage; import com.google.protobuf.ByteString; import com.google.protobuf.Empty; -import io.grpc.Status; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -79,31 +85,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class FirestoreClientTest { private static MockFirestore mockFirestore; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private FirestoreClient client; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockFirestore = new MockFirestore(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockFirestore)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); FirestoreSettings settings = FirestoreSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -118,23 +124,33 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void getDocumentTest() { - String name2 = "name2-1052831874"; - Document expectedResponse = Document.newBuilder().setName(name2).build(); + public void getDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); mockFirestore.addResponse(expectedResponse); - String name = "name3373707"; - GetDocumentRequest request = GetDocumentRequest.newBuilder().setName(name).build(); + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName("name3373707") + .setMask(DocumentMask.newBuilder().build()) + .build(); Document actualResponse = client.getDocument(request); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetDocumentRequest actualRequest = (GetDocumentRequest) actualRequests.get(0); + GetDocumentRequest actualRequest = ((GetDocumentRequest) actualRequests.get(0)); - Assert.assertEquals(name, actualRequest.getName()); + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertEquals(request.getMask(), actualRequest.getMask()); + Assert.assertEquals(request.getTransaction(), actualRequest.getTransaction()); + Assert.assertEquals(request.getReadTime(), actualRequest.getReadTime()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -142,52 +158,64 @@ public void getDocumentTest() { } @Test - @SuppressWarnings("all") public void getDocumentExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { - String name = "name3373707"; - GetDocumentRequest request = GetDocumentRequest.newBuilder().setName(name).build(); - + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName("name3373707") + .setMask(DocumentMask.newBuilder().build()) + .build(); client.getDocument(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listDocumentsTest() { - String nextPageToken = ""; - Document documentsElement = Document.newBuilder().build(); - List documents = Arrays.asList(documentsElement); + public void listDocumentsTest() throws Exception { + Document responsesElement = Document.newBuilder().build(); ListDocumentsResponse expectedResponse = ListDocumentsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllDocuments(documents) + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) .build(); mockFirestore.addResponse(expectedResponse); - String parent = "parent-995424086"; - String collectionId = "collectionId-821242276"; ListDocumentsRequest request = - ListDocumentsRequest.newBuilder().setParent(parent).setCollectionId(collectionId).build(); + ListDocumentsRequest.newBuilder() + .setParent("parent-995424086") + .setCollectionId("collectionId1636075609") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setMask(DocumentMask.newBuilder().build()) + .setShowMissing(true) + .build(); ListDocumentsPagedResponse pagedListResponse = client.listDocuments(request); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0)); List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListDocumentsRequest actualRequest = (ListDocumentsRequest) actualRequests.get(0); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertEquals(collectionId, actualRequest.getCollectionId()); + ListDocumentsRequest actualRequest = ((ListDocumentsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getCollectionId(), actualRequest.getCollectionId()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertEquals(request.getOrderBy(), actualRequest.getOrderBy()); + Assert.assertEquals(request.getMask(), actualRequest.getMask()); + Assert.assertEquals(request.getTransaction(), actualRequest.getTransaction()); + Assert.assertEquals(request.getReadTime(), actualRequest.getReadTime()); + Assert.assertEquals(request.getShowMissing(), actualRequest.getShowMissing()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -195,86 +223,37 @@ public void listDocumentsTest() { } @Test - @SuppressWarnings("all") public void listDocumentsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { - String parent = "parent-995424086"; - String collectionId = "collectionId-821242276"; ListDocumentsRequest request = - ListDocumentsRequest.newBuilder().setParent(parent).setCollectionId(collectionId).build(); - + ListDocumentsRequest.newBuilder() + .setParent("parent-995424086") + .setCollectionId("collectionId1636075609") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setMask(DocumentMask.newBuilder().build()) + .setShowMissing(true) + .build(); client.listDocuments(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createDocumentTest() { - String name = "name3373707"; - Document expectedResponse = Document.newBuilder().setName(name).build(); - mockFirestore.addResponse(expectedResponse); - - String parent = "parent-995424086"; - String collectionId = "collectionId-821242276"; - Document document = Document.newBuilder().build(); - CreateDocumentRequest request = - CreateDocumentRequest.newBuilder() - .setParent(parent) - .setCollectionId(collectionId) - .setDocument(document) + public void updateDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) .build(); - - Document actualResponse = client.createDocument(request); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockFirestore.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateDocumentRequest actualRequest = (CreateDocumentRequest) actualRequests.get(0); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertEquals(collectionId, actualRequest.getCollectionId()); - Assert.assertEquals(document, actualRequest.getDocument()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createDocumentExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockFirestore.addException(exception); - - try { - String parent = "parent-995424086"; - String collectionId = "collectionId-821242276"; - Document document = Document.newBuilder().build(); - CreateDocumentRequest request = - CreateDocumentRequest.newBuilder() - .setParent(parent) - .setCollectionId(collectionId) - .setDocument(document) - .build(); - - client.createDocument(request); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateDocumentTest() { - String name = "name3373707"; - Document expectedResponse = Document.newBuilder().setName(name).build(); mockFirestore.addResponse(expectedResponse); Document document = Document.newBuilder().build(); @@ -285,7 +264,7 @@ public void updateDocumentTest() { List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateDocumentRequest actualRequest = (UpdateDocumentRequest) actualRequests.get(0); + UpdateDocumentRequest actualRequest = ((UpdateDocumentRequest) actualRequests.get(0)); Assert.assertEquals(document, actualRequest.getDocument()); Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); @@ -296,25 +275,22 @@ public void updateDocumentTest() { } @Test - @SuppressWarnings("all") public void updateDocumentExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { Document document = Document.newBuilder().build(); DocumentMask updateMask = DocumentMask.newBuilder().build(); - client.updateDocument(document, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteDocumentTest() { + public void deleteDocumentTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockFirestore.addResponse(expectedResponse); @@ -324,7 +300,7 @@ public void deleteDocumentTest() { List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteDocumentRequest actualRequest = (DeleteDocumentRequest) actualRequests.get(0); + DeleteDocumentRequest actualRequest = ((DeleteDocumentRequest) actualRequests.get(0)); Assert.assertEquals(name, actualRequest.getName()); Assert.assertTrue( @@ -334,35 +310,33 @@ public void deleteDocumentTest() { } @Test - @SuppressWarnings("all") public void deleteDocumentExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { String name = "name3373707"; - client.deleteDocument(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") public void batchGetDocumentsTest() throws Exception { - String missing = "missing1069449574"; - ByteString transaction = ByteString.copyFromUtf8("-34"); BatchGetDocumentsResponse expectedResponse = BatchGetDocumentsResponse.newBuilder() - .setMissing(missing) - .setTransaction(transaction) + .setTransaction(ByteString.EMPTY) + .setReadTime(Timestamp.newBuilder().build()) .build(); mockFirestore.addResponse(expectedResponse); - String database = "database1789464955"; BatchGetDocumentsRequest request = - BatchGetDocumentsRequest.newBuilder().setDatabase(database).build(); + BatchGetDocumentsRequest.newBuilder() + .setDatabase("database1789464955") + .addAllDocuments(new ArrayList()) + .setMask(DocumentMask.newBuilder().build()) + .build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -376,13 +350,15 @@ public void batchGetDocumentsTest() throws Exception { } @Test - @SuppressWarnings("all") public void batchGetDocumentsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); - String database = "database1789464955"; BatchGetDocumentsRequest request = - BatchGetDocumentsRequest.newBuilder().setDatabase(database).build(); + BatchGetDocumentsRequest.newBuilder() + .setDatabase("database1789464955") + .addAllDocuments(new ArrayList()) + .setMask(DocumentMask.newBuilder().build()) + .build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -395,57 +371,15 @@ public void batchGetDocumentsExceptionTest() throws Exception { Assert.fail("No exception thrown"); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") - public void batchWriteTest() { - BatchWriteResponse expectedResponse = BatchWriteResponse.newBuilder().build(); - mockFirestore.addResponse(expectedResponse); - - String database = "database1789464955"; - BatchWriteRequest request = BatchWriteRequest.newBuilder().setDatabase(database).build(); - - BatchWriteResponse actualResponse = client.batchWrite(request); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockFirestore.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - BatchWriteRequest actualRequest = (BatchWriteRequest) actualRequests.get(0); - - Assert.assertEquals(database, actualRequest.getDatabase()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void batchWriteExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockFirestore.addException(exception); - - try { - String database = "database1789464955"; - BatchWriteRequest request = BatchWriteRequest.newBuilder().setDatabase(database).build(); - - client.batchWrite(request); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void beginTransactionTest() { - ByteString transaction = ByteString.copyFromUtf8("-34"); + public void beginTransactionTest() throws Exception { BeginTransactionResponse expectedResponse = - BeginTransactionResponse.newBuilder().setTransaction(transaction).build(); + BeginTransactionResponse.newBuilder().setTransaction(ByteString.EMPTY).build(); mockFirestore.addResponse(expectedResponse); String database = "database1789464955"; @@ -455,7 +389,7 @@ public void beginTransactionTest() { List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - BeginTransactionRequest actualRequest = (BeginTransactionRequest) actualRequests.get(0); + BeginTransactionRequest actualRequest = ((BeginTransactionRequest) actualRequests.get(0)); Assert.assertEquals(database, actualRequest.getDatabase()); Assert.assertTrue( @@ -465,25 +399,26 @@ public void beginTransactionTest() { } @Test - @SuppressWarnings("all") public void beginTransactionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { String database = "database1789464955"; - client.beginTransaction(database); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void commitTest() { - CommitResponse expectedResponse = CommitResponse.newBuilder().build(); + public void commitTest() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); mockFirestore.addResponse(expectedResponse); String database = "database1789464955"; @@ -494,7 +429,7 @@ public void commitTest() { List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CommitRequest actualRequest = (CommitRequest) actualRequests.get(0); + CommitRequest actualRequest = ((CommitRequest) actualRequests.get(0)); Assert.assertEquals(database, actualRequest.getDatabase()); Assert.assertEquals(writes, actualRequest.getWritesList()); @@ -505,36 +440,33 @@ public void commitTest() { } @Test - @SuppressWarnings("all") public void commitExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { String database = "database1789464955"; List writes = new ArrayList<>(); - client.commit(database, writes); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void rollbackTest() { + public void rollbackTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockFirestore.addResponse(expectedResponse); String database = "database1789464955"; - ByteString transaction = ByteString.copyFromUtf8("-34"); + ByteString transaction = ByteString.EMPTY; client.rollback(database, transaction); List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - RollbackRequest actualRequest = (RollbackRequest) actualRequests.get(0); + RollbackRequest actualRequest = ((RollbackRequest) actualRequests.get(0)); Assert.assertEquals(database, actualRequest.getDatabase()); Assert.assertEquals(transaction, actualRequest.getTransaction()); @@ -545,35 +477,31 @@ public void rollbackTest() { } @Test - @SuppressWarnings("all") public void rollbackExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { String database = "database1789464955"; - ByteString transaction = ByteString.copyFromUtf8("-34"); - + ByteString transaction = ByteString.EMPTY; client.rollback(database, transaction); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") public void runQueryTest() throws Exception { - ByteString transaction = ByteString.copyFromUtf8("-34"); - int skippedResults = 880286183; RunQueryResponse expectedResponse = RunQueryResponse.newBuilder() - .setTransaction(transaction) - .setSkippedResults(skippedResults) + .setTransaction(ByteString.EMPTY) + .setDocument(Document.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setSkippedResults(880286183) .build(); mockFirestore.addResponse(expectedResponse); - String parent = "parent-995424086"; - RunQueryRequest request = RunQueryRequest.newBuilder().setParent(parent).build(); + RunQueryRequest request = RunQueryRequest.newBuilder().setParent("parent-995424086").build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -586,12 +514,10 @@ public void runQueryTest() throws Exception { } @Test - @SuppressWarnings("all") public void runQueryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); - String parent = "parent-995424086"; - RunQueryRequest request = RunQueryRequest.newBuilder().setParent(parent).build(); + RunQueryRequest request = RunQueryRequest.newBuilder().setParent("parent-995424086").build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -603,21 +529,89 @@ public void runQueryExceptionTest() throws Exception { Assert.fail("No exception thrown"); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") + public void partitionQueryTest() throws Exception { + Cursor responsesElement = Cursor.newBuilder().build(); + PartitionQueryResponse expectedResponse = + PartitionQueryResponse.newBuilder() + .setNextPageToken("") + .addAllPartitions(Arrays.asList(responsesElement)) + .build(); + mockFirestore.addResponse(expectedResponse); + + PartitionQueryRequest request = + PartitionQueryRequest.newBuilder() + .setParent("parent-995424086") + .setPartitionCount(-1738969222) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + PartitionQueryPagedResponse pagedListResponse = client.partitionQuery(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPartitionsList().get(0), resources.get(0)); + + List actualRequests = mockFirestore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + PartitionQueryRequest actualRequest = ((PartitionQueryRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getStructuredQuery(), actualRequest.getStructuredQuery()); + Assert.assertEquals(request.getPartitionCount(), actualRequest.getPartitionCount()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void partitionQueryExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + + try { + PartitionQueryRequest request = + PartitionQueryRequest.newBuilder() + .setParent("parent-995424086") + .setPartitionCount(-1738969222) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.partitionQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test public void writeTest() throws Exception { - String streamId = "streamId-315624902"; - ByteString streamToken = ByteString.copyFromUtf8("122"); WriteResponse expectedResponse = - WriteResponse.newBuilder().setStreamId(streamId).setStreamToken(streamToken).build(); + WriteResponse.newBuilder() + .setStreamId("streamId1790933179") + .setStreamToken(ByteString.EMPTY) + .addAllWriteResults(new ArrayList()) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); mockFirestore.addResponse(expectedResponse); - String database = "database1789464955"; - WriteRequest request = WriteRequest.newBuilder().setDatabase(database).build(); + WriteRequest request = + WriteRequest.newBuilder() + .setDatabase("database1789464955") + .setStreamId("streamId1790933179") + .addAllWrites(new ArrayList()) + .setStreamToken(ByteString.EMPTY) + .putAllLabels(new HashMap()) + .build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -633,12 +627,17 @@ public void writeTest() throws Exception { } @Test - @SuppressWarnings("all") public void writeExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); - String database = "database1789464955"; - WriteRequest request = WriteRequest.newBuilder().setDatabase(database).build(); + WriteRequest request = + WriteRequest.newBuilder() + .setDatabase("database1789464955") + .setStreamId("streamId1790933179") + .addAllWrites(new ArrayList()) + .setStreamToken(ByteString.EMPTY) + .putAllLabels(new HashMap()) + .build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -652,18 +651,20 @@ public void writeExceptionTest() throws Exception { Assert.fail("No exception thrown"); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") public void listenTest() throws Exception { ListenResponse expectedResponse = ListenResponse.newBuilder().build(); mockFirestore.addResponse(expectedResponse); - String database = "database1789464955"; - ListenRequest request = ListenRequest.newBuilder().setDatabase(database).build(); + ListenRequest request = + ListenRequest.newBuilder() + .setDatabase("database1789464955") + .putAllLabels(new HashMap()) + .build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -679,12 +680,14 @@ public void listenTest() throws Exception { } @Test - @SuppressWarnings("all") public void listenExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); - String database = "database1789464955"; - ListenRequest request = ListenRequest.newBuilder().setDatabase(database).build(); + ListenRequest request = + ListenRequest.newBuilder() + .setDatabase("database1789464955") + .putAllLabels(new HashMap()) + .build(); MockStreamObserver responseObserver = new MockStreamObserver<>(); @@ -698,21 +701,18 @@ public void listenExceptionTest() throws Exception { Assert.fail("No exception thrown"); } catch (ExecutionException e) { Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") - public void listCollectionIdsTest() { - String nextPageToken = ""; - String collectionIdsElement = "collectionIdsElement1368994900"; - List collectionIds = Arrays.asList(collectionIdsElement); + public void listCollectionIdsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; ListCollectionIdsResponse expectedResponse = ListCollectionIdsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllCollectionIds(collectionIds) + .setNextPageToken("") + .addAllCollectionIds(Arrays.asList(responsesElement)) .build(); mockFirestore.addResponse(expectedResponse); @@ -721,12 +721,13 @@ public void listCollectionIdsTest() { ListCollectionIdsPagedResponse pagedListResponse = client.listCollectionIds(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getCollectionIdsList().get(0), resources.get(0)); List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListCollectionIdsRequest actualRequest = (ListCollectionIdsRequest) actualRequests.get(0); + ListCollectionIdsRequest actualRequest = ((ListCollectionIdsRequest) actualRequests.get(0)); Assert.assertEquals(parent, actualRequest.getParent()); Assert.assertTrue( @@ -736,48 +737,45 @@ public void listCollectionIdsTest() { } @Test - @SuppressWarnings("all") public void listCollectionIdsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { String parent = "parent-995424086"; - client.listCollectionIds(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void partitionQueryTest() { - String nextPageToken = ""; - Cursor partitionsElement = Cursor.newBuilder().build(); - List partitions = Arrays.asList(partitionsElement); - PartitionQueryResponse expectedResponse = - PartitionQueryResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllPartitions(partitions) + public void batchWriteTest() throws Exception { + BatchWriteResponse expectedResponse = + BatchWriteResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .addAllStatus(new ArrayList()) .build(); mockFirestore.addResponse(expectedResponse); - String parent = "parent-995424086"; - PartitionQueryRequest request = PartitionQueryRequest.newBuilder().setParent(parent).build(); - - PartitionQueryPagedResponse pagedListResponse = client.partitionQuery(request); + BatchWriteRequest request = + BatchWriteRequest.newBuilder() + .setDatabase("database1789464955") + .addAllWrites(new ArrayList()) + .putAllLabels(new HashMap()) + .build(); - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getPartitionsList().get(0), resources.get(0)); + BatchWriteResponse actualResponse = client.batchWrite(request); + Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockFirestore.getRequests(); Assert.assertEquals(1, actualRequests.size()); - PartitionQueryRequest actualRequest = (PartitionQueryRequest) actualRequests.get(0); + BatchWriteRequest actualRequest = ((BatchWriteRequest) actualRequests.get(0)); - Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(request.getDatabase(), actualRequest.getDatabase()); + Assert.assertEquals(request.getWritesList(), actualRequest.getWritesList()); + Assert.assertEquals(request.getLabelsMap(), actualRequest.getLabelsMap()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -785,19 +783,80 @@ public void partitionQueryTest() { } @Test - @SuppressWarnings("all") - public void partitionQueryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + public void batchWriteExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockFirestore.addException(exception); try { - String parent = "parent-995424086"; - PartitionQueryRequest request = PartitionQueryRequest.newBuilder().setParent(parent).build(); + BatchWriteRequest request = + BatchWriteRequest.newBuilder() + .setDatabase("database1789464955") + .addAllWrites(new ArrayList()) + .putAllLabels(new HashMap()) + .build(); + client.batchWrite(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } - client.partitionQuery(request); + @Test + public void createDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setCollectionId("collectionId1636075609") + .setDocumentId("documentId-814940266") + .setDocument(Document.newBuilder().build()) + .setMask(DocumentMask.newBuilder().build()) + .build(); + + Document actualResponse = client.createDocument(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateDocumentRequest actualRequest = ((CreateDocumentRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getCollectionId(), actualRequest.getCollectionId()); + Assert.assertEquals(request.getDocumentId(), actualRequest.getDocumentId()); + Assert.assertEquals(request.getDocument(), actualRequest.getDocument()); + Assert.assertEquals(request.getMask(), actualRequest.getMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createDocumentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + + try { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setCollectionId("collectionId1636075609") + .setDocumentId("documentId-814940266") + .setDocument(Document.newBuilder().build()) + .setMask(DocumentMask.newBuilder().build()) + .build(); + client.createDocument(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java index 7e29d1093..29fc4abc2 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * 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.BetaApi; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockFirestore implements MockGrpcService { private final MockFirestoreImpl serviceImpl; diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java index f095f896f..0b5ba4a44 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java @@ -1,11 +1,11 @@ /* - * Copyright 2020 Google LLC + * Copyright 2021 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 + * 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, @@ -13,6 +13,7 @@ * 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.BetaApi; @@ -50,9 +51,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockFirestoreImpl extends FirestoreImplBase { private List requests; private Queue responses; @@ -85,60 +87,84 @@ public void reset() { @Override public void getDocument(GetDocumentRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Document) { requests.add(request); - responseObserver.onNext((Document) response); + responseObserver.onNext(((Document) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetDocument, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Document.class.getName(), + Exception.class.getName()))); } } @Override public void listDocuments( ListDocumentsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof ListDocumentsResponse) { requests.add(request); - responseObserver.onNext((ListDocumentsResponse) response); + responseObserver.onNext(((ListDocumentsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListDocuments, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListDocumentsResponse.class.getName(), + Exception.class.getName()))); } } @Override public void updateDocument( UpdateDocumentRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Document) { requests.add(request); - responseObserver.onNext((Document) response); + responseObserver.onNext(((Document) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdateDocument, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Document.class.getName(), + Exception.class.getName()))); } } @Override public void deleteDocument( DeleteDocumentRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteDocument, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); } } @@ -146,87 +172,123 @@ public void deleteDocument( public void batchGetDocuments( BatchGetDocumentsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof BatchGetDocumentsResponse) { requests.add(request); - responseObserver.onNext((BatchGetDocumentsResponse) response); + responseObserver.onNext(((BatchGetDocumentsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method BatchGetDocuments, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BatchGetDocumentsResponse.class.getName(), + Exception.class.getName()))); } } @Override public void beginTransaction( BeginTransactionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof BeginTransactionResponse) { requests.add(request); - responseObserver.onNext((BeginTransactionResponse) response); + responseObserver.onNext(((BeginTransactionResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method BeginTransaction, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BeginTransactionResponse.class.getName(), + Exception.class.getName()))); } } @Override public void commit(CommitRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof CommitResponse) { requests.add(request); - responseObserver.onNext((CommitResponse) response); + responseObserver.onNext(((CommitResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method Commit, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + CommitResponse.class.getName(), + Exception.class.getName()))); } } @Override public void rollback(RollbackRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method Rollback, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); } } @Override public void runQuery(RunQueryRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof RunQueryResponse) { requests.add(request); - responseObserver.onNext((RunQueryResponse) response); + responseObserver.onNext(((RunQueryResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method RunQuery, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + RunQueryResponse.class.getName(), + Exception.class.getName()))); } } @Override public void partitionQuery( PartitionQueryRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof PartitionQueryResponse) { requests.add(request); - responseObserver.onNext((PartitionQueryResponse) response); + responseObserver.onNext(((PartitionQueryResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method PartitionQuery, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + PartitionQueryResponse.class.getName(), + Exception.class.getName()))); } } @@ -239,11 +301,17 @@ public void onNext(WriteRequest value) { requests.add(value); final Object response = responses.remove(); if (response instanceof WriteResponse) { - responseObserver.onNext((WriteResponse) response); + responseObserver.onNext(((WriteResponse) response)); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method Write, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + WriteResponse.class.getName(), + Exception.class.getName()))); } } @@ -270,11 +338,17 @@ public void onNext(ListenRequest value) { requests.add(value); final Object response = responses.remove(); if (response instanceof ListenResponse) { - responseObserver.onNext((ListenResponse) response); + responseObserver.onNext(((ListenResponse) response)); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method Listen, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListenResponse.class.getName(), + Exception.class.getName()))); } } @@ -295,45 +369,63 @@ public void onCompleted() { public void listCollectionIds( ListCollectionIdsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof ListCollectionIdsResponse) { requests.add(request); - responseObserver.onNext((ListCollectionIdsResponse) response); + responseObserver.onNext(((ListCollectionIdsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListCollectionIds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListCollectionIdsResponse.class.getName(), + Exception.class.getName()))); } } @Override public void batchWrite( BatchWriteRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof BatchWriteResponse) { requests.add(request); - responseObserver.onNext((BatchWriteResponse) response); + responseObserver.onNext(((BatchWriteResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method BatchWrite, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BatchWriteResponse.class.getName(), + Exception.class.getName()))); } } @Override public void createDocument( CreateDocumentRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); + Object response = responses.poll(); if (response instanceof Document) { requests.add(request); - responseObserver.onNext((Document) response); + responseObserver.onNext(((Document) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateDocument, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Document.class.getName(), + Exception.class.getName()))); } } } diff --git a/grpc-google-cloud-firestore-admin-v1/pom.xml b/grpc-google-cloud-firestore-admin-v1/pom.xml index 2807fafde..a551065d6 100644 --- a/grpc-google-cloud-firestore-admin-v1/pom.xml +++ b/grpc-google-cloud-firestore-admin-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-firestore-admin-v1 - 2.3.0 + 2.4.0 grpc-google-cloud-firestore-admin-v1 GRPC library for grpc-google-cloud-firestore-admin-v1 com.google.cloud google-cloud-firestore-parent - 2.3.0 + 2.4.0 diff --git a/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java b/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java index e0dcf4ec2..67fee8aa1 100644 --- a/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java +++ b/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java @@ -16,11 +16,6 @@ package com.google.firestore.admin.v1; import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** * @@ -491,7 +486,8 @@ public abstract static class FirestoreAdminImplBase implements io.grpc.BindableS public void createIndex( com.google.firestore.admin.v1.CreateIndexRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getCreateIndexMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateIndexMethod(), responseObserver); } /** @@ -505,7 +501,8 @@ public void listIndexes( com.google.firestore.admin.v1.ListIndexesRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getListIndexesMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListIndexesMethod(), responseObserver); } /** @@ -518,7 +515,7 @@ public void listIndexes( public void getIndex( com.google.firestore.admin.v1.GetIndexRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getGetIndexMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetIndexMethod(), responseObserver); } /** @@ -531,7 +528,8 @@ public void getIndex( public void deleteIndex( com.google.firestore.admin.v1.DeleteIndexRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getDeleteIndexMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteIndexMethod(), responseObserver); } /** @@ -544,7 +542,7 @@ public void deleteIndex( public void getField( com.google.firestore.admin.v1.GetFieldRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getGetFieldMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetFieldMethod(), responseObserver); } /** @@ -567,7 +565,8 @@ public void getField( public void updateField( com.google.firestore.admin.v1.UpdateFieldRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getUpdateFieldMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateFieldMethod(), responseObserver); } /** @@ -585,7 +584,7 @@ public void listFields( com.google.firestore.admin.v1.ListFieldsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getListFieldsMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getListFieldsMethod(), responseObserver); } /** @@ -605,7 +604,8 @@ public void listFields( public void exportDocuments( com.google.firestore.admin.v1.ExportDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getExportDocumentsMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getExportDocumentsMethod(), responseObserver); } /** @@ -622,7 +622,8 @@ public void exportDocuments( public void importDocuments( com.google.firestore.admin.v1.ImportDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getImportDocumentsMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getImportDocumentsMethod(), responseObserver); } @java.lang.Override @@ -630,57 +631,57 @@ public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( getCreateIndexMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.CreateIndexRequest, com.google.longrunning.Operation>(this, METHODID_CREATE_INDEX))) .addMethod( getListIndexesMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.ListIndexesRequest, com.google.firestore.admin.v1.ListIndexesResponse>( this, METHODID_LIST_INDEXES))) .addMethod( getGetIndexMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.GetIndexRequest, com.google.firestore.admin.v1.Index>(this, METHODID_GET_INDEX))) .addMethod( getDeleteIndexMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.DeleteIndexRequest, com.google.protobuf.Empty>( this, METHODID_DELETE_INDEX))) .addMethod( getGetFieldMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.GetFieldRequest, com.google.firestore.admin.v1.Field>(this, METHODID_GET_FIELD))) .addMethod( getUpdateFieldMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.UpdateFieldRequest, com.google.longrunning.Operation>(this, METHODID_UPDATE_FIELD))) .addMethod( getListFieldsMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.ListFieldsRequest, com.google.firestore.admin.v1.ListFieldsResponse>( this, METHODID_LIST_FIELDS))) .addMethod( getExportDocumentsMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.ExportDocumentsRequest, com.google.longrunning.Operation>(this, METHODID_EXPORT_DOCUMENTS))) .addMethod( getImportDocumentsMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.admin.v1.ImportDocumentsRequest, com.google.longrunning.Operation>(this, METHODID_IMPORT_DOCUMENTS))) @@ -719,7 +720,7 @@ protected FirestoreAdminStub build(io.grpc.Channel channel, io.grpc.CallOptions public void createIndex( com.google.firestore.admin.v1.CreateIndexRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getCreateIndexMethod(), getCallOptions()), request, responseObserver); @@ -736,7 +737,7 @@ public void listIndexes( com.google.firestore.admin.v1.ListIndexesRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getListIndexesMethod(), getCallOptions()), request, responseObserver); @@ -752,7 +753,7 @@ public void listIndexes( public void getIndex( com.google.firestore.admin.v1.GetIndexRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getGetIndexMethod(), getCallOptions()), request, responseObserver); } @@ -766,7 +767,7 @@ public void getIndex( public void deleteIndex( com.google.firestore.admin.v1.DeleteIndexRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getDeleteIndexMethod(), getCallOptions()), request, responseObserver); @@ -782,7 +783,7 @@ public void deleteIndex( public void getField( com.google.firestore.admin.v1.GetFieldRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getGetFieldMethod(), getCallOptions()), request, responseObserver); } @@ -806,7 +807,7 @@ public void getField( public void updateField( com.google.firestore.admin.v1.UpdateFieldRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getUpdateFieldMethod(), getCallOptions()), request, responseObserver); @@ -827,7 +828,7 @@ public void listFields( com.google.firestore.admin.v1.ListFieldsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getListFieldsMethod(), getCallOptions()), request, responseObserver); } @@ -848,7 +849,7 @@ public void listFields( public void exportDocuments( com.google.firestore.admin.v1.ExportDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getExportDocumentsMethod(), getCallOptions()), request, responseObserver); @@ -868,7 +869,7 @@ public void exportDocuments( public void importDocuments( com.google.firestore.admin.v1.ImportDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getImportDocumentsMethod(), getCallOptions()), request, responseObserver); @@ -906,7 +907,8 @@ protected FirestoreAdminBlockingStub build( */ public com.google.longrunning.Operation createIndex( com.google.firestore.admin.v1.CreateIndexRequest request) { - return blockingUnaryCall(getChannel(), getCreateIndexMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateIndexMethod(), getCallOptions(), request); } /** @@ -918,7 +920,8 @@ public com.google.longrunning.Operation createIndex( */ public com.google.firestore.admin.v1.ListIndexesResponse listIndexes( com.google.firestore.admin.v1.ListIndexesRequest request) { - return blockingUnaryCall(getChannel(), getListIndexesMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListIndexesMethod(), getCallOptions(), request); } /** @@ -930,7 +933,8 @@ public com.google.firestore.admin.v1.ListIndexesResponse listIndexes( */ public com.google.firestore.admin.v1.Index getIndex( com.google.firestore.admin.v1.GetIndexRequest request) { - return blockingUnaryCall(getChannel(), getGetIndexMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetIndexMethod(), getCallOptions(), request); } /** @@ -942,7 +946,8 @@ public com.google.firestore.admin.v1.Index getIndex( */ public com.google.protobuf.Empty deleteIndex( com.google.firestore.admin.v1.DeleteIndexRequest request) { - return blockingUnaryCall(getChannel(), getDeleteIndexMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteIndexMethod(), getCallOptions(), request); } /** @@ -954,7 +959,8 @@ public com.google.protobuf.Empty deleteIndex( */ public com.google.firestore.admin.v1.Field getField( com.google.firestore.admin.v1.GetFieldRequest request) { - return blockingUnaryCall(getChannel(), getGetFieldMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetFieldMethod(), getCallOptions(), request); } /** @@ -976,7 +982,8 @@ public com.google.firestore.admin.v1.Field getField( */ public com.google.longrunning.Operation updateField( com.google.firestore.admin.v1.UpdateFieldRequest request) { - return blockingUnaryCall(getChannel(), getUpdateFieldMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateFieldMethod(), getCallOptions(), request); } /** @@ -992,7 +999,8 @@ public com.google.longrunning.Operation updateField( */ public com.google.firestore.admin.v1.ListFieldsResponse listFields( com.google.firestore.admin.v1.ListFieldsRequest request) { - return blockingUnaryCall(getChannel(), getListFieldsMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListFieldsMethod(), getCallOptions(), request); } /** @@ -1011,7 +1019,8 @@ public com.google.firestore.admin.v1.ListFieldsResponse listFields( */ public com.google.longrunning.Operation exportDocuments( com.google.firestore.admin.v1.ExportDocumentsRequest request) { - return blockingUnaryCall(getChannel(), getExportDocumentsMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getExportDocumentsMethod(), getCallOptions(), request); } /** @@ -1027,7 +1036,8 @@ public com.google.longrunning.Operation exportDocuments( */ public com.google.longrunning.Operation importDocuments( com.google.firestore.admin.v1.ImportDocumentsRequest request) { - return blockingUnaryCall(getChannel(), getImportDocumentsMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getImportDocumentsMethod(), getCallOptions(), request); } } @@ -1062,7 +1072,7 @@ protected FirestoreAdminFutureStub build( */ public com.google.common.util.concurrent.ListenableFuture createIndex(com.google.firestore.admin.v1.CreateIndexRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getCreateIndexMethod(), getCallOptions()), request); } @@ -1076,7 +1086,7 @@ protected FirestoreAdminFutureStub build( public com.google.common.util.concurrent.ListenableFuture< com.google.firestore.admin.v1.ListIndexesResponse> listIndexes(com.google.firestore.admin.v1.ListIndexesRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getListIndexesMethod(), getCallOptions()), request); } @@ -1089,7 +1099,8 @@ protected FirestoreAdminFutureStub build( */ public com.google.common.util.concurrent.ListenableFuture getIndex(com.google.firestore.admin.v1.GetIndexRequest request) { - return futureUnaryCall(getChannel().newCall(getGetIndexMethod(), getCallOptions()), request); + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetIndexMethod(), getCallOptions()), request); } /** @@ -1101,7 +1112,7 @@ protected FirestoreAdminFutureStub build( */ public com.google.common.util.concurrent.ListenableFuture deleteIndex(com.google.firestore.admin.v1.DeleteIndexRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getDeleteIndexMethod(), getCallOptions()), request); } @@ -1114,7 +1125,8 @@ protected FirestoreAdminFutureStub build( */ public com.google.common.util.concurrent.ListenableFuture getField(com.google.firestore.admin.v1.GetFieldRequest request) { - return futureUnaryCall(getChannel().newCall(getGetFieldMethod(), getCallOptions()), request); + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetFieldMethod(), getCallOptions()), request); } /** @@ -1136,7 +1148,7 @@ protected FirestoreAdminFutureStub build( */ public com.google.common.util.concurrent.ListenableFuture updateField(com.google.firestore.admin.v1.UpdateFieldRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getUpdateFieldMethod(), getCallOptions()), request); } @@ -1154,7 +1166,7 @@ protected FirestoreAdminFutureStub build( public com.google.common.util.concurrent.ListenableFuture< com.google.firestore.admin.v1.ListFieldsResponse> listFields(com.google.firestore.admin.v1.ListFieldsRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getListFieldsMethod(), getCallOptions()), request); } @@ -1174,7 +1186,7 @@ protected FirestoreAdminFutureStub build( */ public com.google.common.util.concurrent.ListenableFuture exportDocuments(com.google.firestore.admin.v1.ExportDocumentsRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getExportDocumentsMethod(), getCallOptions()), request); } @@ -1191,7 +1203,7 @@ protected FirestoreAdminFutureStub build( */ public com.google.common.util.concurrent.ListenableFuture importDocuments(com.google.firestore.admin.v1.ImportDocumentsRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getImportDocumentsMethod(), getCallOptions()), request); } } diff --git a/grpc-google-cloud-firestore-v1/pom.xml b/grpc-google-cloud-firestore-v1/pom.xml index 6605b5abc..b246809bb 100644 --- a/grpc-google-cloud-firestore-v1/pom.xml +++ b/grpc-google-cloud-firestore-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-firestore-v1 - 2.3.0 + 2.4.0 grpc-google-cloud-firestore-v1 GRPC library for grpc-google-cloud-firestore-v1 com.google.cloud google-cloud-firestore-parent - 2.3.0 + 2.4.0 diff --git a/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java b/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java index bf49895d2..ad47c1282 100644 --- a/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java +++ b/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java @@ -16,17 +16,6 @@ package com.google.firestore.v1; import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; -import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; /** * @@ -750,7 +739,8 @@ public abstract static class FirestoreImplBase implements io.grpc.BindableServic public void getDocument( com.google.firestore.v1.GetDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getGetDocumentMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getGetDocumentMethod(), responseObserver); } /** @@ -764,7 +754,8 @@ public void listDocuments( com.google.firestore.v1.ListDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getListDocumentsMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListDocumentsMethod(), responseObserver); } /** @@ -777,7 +768,8 @@ public void listDocuments( public void updateDocument( com.google.firestore.v1.UpdateDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getUpdateDocumentMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateDocumentMethod(), responseObserver); } /** @@ -790,7 +782,8 @@ public void updateDocument( public void deleteDocument( com.google.firestore.v1.DeleteDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getDeleteDocumentMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteDocumentMethod(), responseObserver); } /** @@ -806,7 +799,8 @@ public void batchGetDocuments( com.google.firestore.v1.BatchGetDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getBatchGetDocumentsMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getBatchGetDocumentsMethod(), responseObserver); } /** @@ -820,7 +814,8 @@ public void beginTransaction( com.google.firestore.v1.BeginTransactionRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getBeginTransactionMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getBeginTransactionMethod(), responseObserver); } /** @@ -833,7 +828,7 @@ public void beginTransaction( public void commit( com.google.firestore.v1.CommitRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getCommitMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getCommitMethod(), responseObserver); } /** @@ -846,7 +841,7 @@ public void commit( public void rollback( com.google.firestore.v1.RollbackRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getRollbackMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRollbackMethod(), responseObserver); } /** @@ -859,7 +854,7 @@ public void rollback( public void runQuery( com.google.firestore.v1.RunQueryRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getRunQueryMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRunQueryMethod(), responseObserver); } /** @@ -875,7 +870,8 @@ public void partitionQuery( com.google.firestore.v1.PartitionQueryRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getPartitionQueryMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getPartitionQueryMethod(), responseObserver); } /** @@ -887,7 +883,8 @@ public void partitionQuery( */ public io.grpc.stub.StreamObserver write( io.grpc.stub.StreamObserver responseObserver) { - return asyncUnimplementedStreamingCall(getWriteMethod(), responseObserver); + return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall( + getWriteMethod(), responseObserver); } /** @@ -899,7 +896,8 @@ public io.grpc.stub.StreamObserver write( */ public io.grpc.stub.StreamObserver listen( io.grpc.stub.StreamObserver responseObserver) { - return asyncUnimplementedStreamingCall(getListenMethod(), responseObserver); + return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall( + getListenMethod(), responseObserver); } /** @@ -913,7 +911,8 @@ public void listCollectionIds( com.google.firestore.v1.ListCollectionIdsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getListCollectionIdsMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListCollectionIdsMethod(), responseObserver); } /** @@ -932,7 +931,7 @@ public void listCollectionIds( public void batchWrite( com.google.firestore.v1.BatchWriteRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getBatchWriteMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getBatchWriteMethod(), responseObserver); } /** @@ -945,7 +944,8 @@ public void batchWrite( public void createDocument( com.google.firestore.v1.CreateDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnimplementedUnaryCall(getCreateDocumentMethod(), responseObserver); + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateDocumentMethod(), responseObserver); } @java.lang.Override @@ -953,96 +953,96 @@ public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( getGetDocumentMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.GetDocumentRequest, com.google.firestore.v1.Document>( this, METHODID_GET_DOCUMENT))) .addMethod( getListDocumentsMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.ListDocumentsRequest, com.google.firestore.v1.ListDocumentsResponse>( this, METHODID_LIST_DOCUMENTS))) .addMethod( getUpdateDocumentMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.UpdateDocumentRequest, com.google.firestore.v1.Document>(this, METHODID_UPDATE_DOCUMENT))) .addMethod( getDeleteDocumentMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.DeleteDocumentRequest, com.google.protobuf.Empty>( this, METHODID_DELETE_DOCUMENT))) .addMethod( getBatchGetDocumentsMethod(), - asyncServerStreamingCall( + io.grpc.stub.ServerCalls.asyncServerStreamingCall( new MethodHandlers< com.google.firestore.v1.BatchGetDocumentsRequest, com.google.firestore.v1.BatchGetDocumentsResponse>( this, METHODID_BATCH_GET_DOCUMENTS))) .addMethod( getBeginTransactionMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.BeginTransactionRequest, com.google.firestore.v1.BeginTransactionResponse>( this, METHODID_BEGIN_TRANSACTION))) .addMethod( getCommitMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.CommitRequest, com.google.firestore.v1.CommitResponse>(this, METHODID_COMMIT))) .addMethod( getRollbackMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.RollbackRequest, com.google.protobuf.Empty>( this, METHODID_ROLLBACK))) .addMethod( getRunQueryMethod(), - asyncServerStreamingCall( + io.grpc.stub.ServerCalls.asyncServerStreamingCall( new MethodHandlers< com.google.firestore.v1.RunQueryRequest, com.google.firestore.v1.RunQueryResponse>(this, METHODID_RUN_QUERY))) .addMethod( getPartitionQueryMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.PartitionQueryRequest, com.google.firestore.v1.PartitionQueryResponse>( this, METHODID_PARTITION_QUERY))) .addMethod( getWriteMethod(), - asyncBidiStreamingCall( + io.grpc.stub.ServerCalls.asyncBidiStreamingCall( new MethodHandlers< com.google.firestore.v1.WriteRequest, com.google.firestore.v1.WriteResponse>( this, METHODID_WRITE))) .addMethod( getListenMethod(), - asyncBidiStreamingCall( + io.grpc.stub.ServerCalls.asyncBidiStreamingCall( new MethodHandlers< com.google.firestore.v1.ListenRequest, com.google.firestore.v1.ListenResponse>(this, METHODID_LISTEN))) .addMethod( getListCollectionIdsMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.ListCollectionIdsRequest, com.google.firestore.v1.ListCollectionIdsResponse>( this, METHODID_LIST_COLLECTION_IDS))) .addMethod( getBatchWriteMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.BatchWriteRequest, com.google.firestore.v1.BatchWriteResponse>(this, METHODID_BATCH_WRITE))) .addMethod( getCreateDocumentMethod(), - asyncUnaryCall( + io.grpc.stub.ServerCalls.asyncUnaryCall( new MethodHandlers< com.google.firestore.v1.CreateDocumentRequest, com.google.firestore.v1.Document>(this, METHODID_CREATE_DOCUMENT))) @@ -1083,7 +1083,7 @@ protected FirestoreStub build(io.grpc.Channel channel, io.grpc.CallOptions callO public void getDocument( com.google.firestore.v1.GetDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getGetDocumentMethod(), getCallOptions()), request, responseObserver); @@ -1100,7 +1100,7 @@ public void listDocuments( com.google.firestore.v1.ListDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getListDocumentsMethod(), getCallOptions()), request, responseObserver); @@ -1116,7 +1116,7 @@ public void listDocuments( public void updateDocument( com.google.firestore.v1.UpdateDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getUpdateDocumentMethod(), getCallOptions()), request, responseObserver); @@ -1132,7 +1132,7 @@ public void updateDocument( public void deleteDocument( com.google.firestore.v1.DeleteDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getDeleteDocumentMethod(), getCallOptions()), request, responseObserver); @@ -1151,7 +1151,7 @@ public void batchGetDocuments( com.google.firestore.v1.BatchGetDocumentsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( + io.grpc.stub.ClientCalls.asyncServerStreamingCall( getChannel().newCall(getBatchGetDocumentsMethod(), getCallOptions()), request, responseObserver); @@ -1168,7 +1168,7 @@ public void beginTransaction( com.google.firestore.v1.BeginTransactionRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getBeginTransactionMethod(), getCallOptions()), request, responseObserver); @@ -1184,7 +1184,7 @@ public void beginTransaction( public void commit( com.google.firestore.v1.CommitRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getCommitMethod(), getCallOptions()), request, responseObserver); } @@ -1198,7 +1198,7 @@ public void commit( public void rollback( com.google.firestore.v1.RollbackRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getRollbackMethod(), getCallOptions()), request, responseObserver); } @@ -1212,7 +1212,7 @@ public void rollback( public void runQuery( com.google.firestore.v1.RunQueryRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncServerStreamingCall( + io.grpc.stub.ClientCalls.asyncServerStreamingCall( getChannel().newCall(getRunQueryMethod(), getCallOptions()), request, responseObserver); } @@ -1229,7 +1229,7 @@ public void partitionQuery( com.google.firestore.v1.PartitionQueryRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getPartitionQueryMethod(), getCallOptions()), request, responseObserver); @@ -1244,7 +1244,7 @@ public void partitionQuery( */ public io.grpc.stub.StreamObserver write( io.grpc.stub.StreamObserver responseObserver) { - return asyncBidiStreamingCall( + return io.grpc.stub.ClientCalls.asyncBidiStreamingCall( getChannel().newCall(getWriteMethod(), getCallOptions()), responseObserver); } @@ -1257,7 +1257,7 @@ public io.grpc.stub.StreamObserver write( */ public io.grpc.stub.StreamObserver listen( io.grpc.stub.StreamObserver responseObserver) { - return asyncBidiStreamingCall( + return io.grpc.stub.ClientCalls.asyncBidiStreamingCall( getChannel().newCall(getListenMethod(), getCallOptions()), responseObserver); } @@ -1272,7 +1272,7 @@ public void listCollectionIds( com.google.firestore.v1.ListCollectionIdsRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getListCollectionIdsMethod(), getCallOptions()), request, responseObserver); @@ -1294,7 +1294,7 @@ public void listCollectionIds( public void batchWrite( com.google.firestore.v1.BatchWriteRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getBatchWriteMethod(), getCallOptions()), request, responseObserver); } @@ -1308,7 +1308,7 @@ public void batchWrite( public void createDocument( com.google.firestore.v1.CreateDocumentRequest request, io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( + io.grpc.stub.ClientCalls.asyncUnaryCall( getChannel().newCall(getCreateDocumentMethod(), getCallOptions()), request, responseObserver); @@ -1349,7 +1349,8 @@ protected FirestoreBlockingStub build( */ public com.google.firestore.v1.Document getDocument( com.google.firestore.v1.GetDocumentRequest request) { - return blockingUnaryCall(getChannel(), getGetDocumentMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetDocumentMethod(), getCallOptions(), request); } /** @@ -1361,7 +1362,8 @@ public com.google.firestore.v1.Document getDocument( */ public com.google.firestore.v1.ListDocumentsResponse listDocuments( com.google.firestore.v1.ListDocumentsRequest request) { - return blockingUnaryCall(getChannel(), getListDocumentsMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListDocumentsMethod(), getCallOptions(), request); } /** @@ -1373,7 +1375,8 @@ public com.google.firestore.v1.ListDocumentsResponse listDocuments( */ public com.google.firestore.v1.Document updateDocument( com.google.firestore.v1.UpdateDocumentRequest request) { - return blockingUnaryCall(getChannel(), getUpdateDocumentMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateDocumentMethod(), getCallOptions(), request); } /** @@ -1385,7 +1388,8 @@ public com.google.firestore.v1.Document updateDocument( */ public com.google.protobuf.Empty deleteDocument( com.google.firestore.v1.DeleteDocumentRequest request) { - return blockingUnaryCall(getChannel(), getDeleteDocumentMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteDocumentMethod(), getCallOptions(), request); } /** @@ -1399,7 +1403,7 @@ public com.google.protobuf.Empty deleteDocument( */ public java.util.Iterator batchGetDocuments( com.google.firestore.v1.BatchGetDocumentsRequest request) { - return blockingServerStreamingCall( + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( getChannel(), getBatchGetDocumentsMethod(), getCallOptions(), request); } @@ -1412,7 +1416,7 @@ public java.util.Iterator bat */ public com.google.firestore.v1.BeginTransactionResponse beginTransaction( com.google.firestore.v1.BeginTransactionRequest request) { - return blockingUnaryCall( + return io.grpc.stub.ClientCalls.blockingUnaryCall( getChannel(), getBeginTransactionMethod(), getCallOptions(), request); } @@ -1425,7 +1429,8 @@ public com.google.firestore.v1.BeginTransactionResponse beginTransaction( */ public com.google.firestore.v1.CommitResponse commit( com.google.firestore.v1.CommitRequest request) { - return blockingUnaryCall(getChannel(), getCommitMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCommitMethod(), getCallOptions(), request); } /** @@ -1436,7 +1441,8 @@ public com.google.firestore.v1.CommitResponse commit( * */ public com.google.protobuf.Empty rollback(com.google.firestore.v1.RollbackRequest request) { - return blockingUnaryCall(getChannel(), getRollbackMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRollbackMethod(), getCallOptions(), request); } /** @@ -1448,7 +1454,7 @@ public com.google.protobuf.Empty rollback(com.google.firestore.v1.RollbackReques */ public java.util.Iterator runQuery( com.google.firestore.v1.RunQueryRequest request) { - return blockingServerStreamingCall( + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( getChannel(), getRunQueryMethod(), getCallOptions(), request); } @@ -1463,7 +1469,8 @@ public java.util.Iterator runQuery( */ public com.google.firestore.v1.PartitionQueryResponse partitionQuery( com.google.firestore.v1.PartitionQueryRequest request) { - return blockingUnaryCall(getChannel(), getPartitionQueryMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getPartitionQueryMethod(), getCallOptions(), request); } /** @@ -1475,7 +1482,7 @@ public com.google.firestore.v1.PartitionQueryResponse partitionQuery( */ public com.google.firestore.v1.ListCollectionIdsResponse listCollectionIds( com.google.firestore.v1.ListCollectionIdsRequest request) { - return blockingUnaryCall( + return io.grpc.stub.ClientCalls.blockingUnaryCall( getChannel(), getListCollectionIdsMethod(), getCallOptions(), request); } @@ -1494,7 +1501,8 @@ public com.google.firestore.v1.ListCollectionIdsResponse listCollectionIds( */ public com.google.firestore.v1.BatchWriteResponse batchWrite( com.google.firestore.v1.BatchWriteRequest request) { - return blockingUnaryCall(getChannel(), getBatchWriteMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getBatchWriteMethod(), getCallOptions(), request); } /** @@ -1506,7 +1514,8 @@ public com.google.firestore.v1.BatchWriteResponse batchWrite( */ public com.google.firestore.v1.Document createDocument( com.google.firestore.v1.CreateDocumentRequest request) { - return blockingUnaryCall(getChannel(), getCreateDocumentMethod(), getCallOptions(), request); + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateDocumentMethod(), getCallOptions(), request); } } @@ -1543,7 +1552,7 @@ protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions */ public com.google.common.util.concurrent.ListenableFuture getDocument(com.google.firestore.v1.GetDocumentRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getGetDocumentMethod(), getCallOptions()), request); } @@ -1557,7 +1566,7 @@ protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions public com.google.common.util.concurrent.ListenableFuture< com.google.firestore.v1.ListDocumentsResponse> listDocuments(com.google.firestore.v1.ListDocumentsRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getListDocumentsMethod(), getCallOptions()), request); } @@ -1570,7 +1579,7 @@ protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions */ public com.google.common.util.concurrent.ListenableFuture updateDocument(com.google.firestore.v1.UpdateDocumentRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getUpdateDocumentMethod(), getCallOptions()), request); } @@ -1583,7 +1592,7 @@ protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions */ public com.google.common.util.concurrent.ListenableFuture deleteDocument(com.google.firestore.v1.DeleteDocumentRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getDeleteDocumentMethod(), getCallOptions()), request); } @@ -1597,7 +1606,7 @@ protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions public com.google.common.util.concurrent.ListenableFuture< com.google.firestore.v1.BeginTransactionResponse> beginTransaction(com.google.firestore.v1.BeginTransactionRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getBeginTransactionMethod(), getCallOptions()), request); } @@ -1611,7 +1620,8 @@ protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions public com.google.common.util.concurrent.ListenableFuture< com.google.firestore.v1.CommitResponse> commit(com.google.firestore.v1.CommitRequest request) { - return futureUnaryCall(getChannel().newCall(getCommitMethod(), getCallOptions()), request); + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCommitMethod(), getCallOptions()), request); } /** @@ -1623,7 +1633,8 @@ protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions */ public com.google.common.util.concurrent.ListenableFuture rollback( com.google.firestore.v1.RollbackRequest request) { - return futureUnaryCall(getChannel().newCall(getRollbackMethod(), getCallOptions()), request); + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRollbackMethod(), getCallOptions()), request); } /** @@ -1638,7 +1649,7 @@ public com.google.common.util.concurrent.ListenableFuture partitionQuery(com.google.firestore.v1.PartitionQueryRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getPartitionQueryMethod(), getCallOptions()), request); } @@ -1652,7 +1663,7 @@ public com.google.common.util.concurrent.ListenableFuture listCollectionIds(com.google.firestore.v1.ListCollectionIdsRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getListCollectionIdsMethod(), getCallOptions()), request); } @@ -1672,7 +1683,7 @@ public com.google.common.util.concurrent.ListenableFuture batchWrite(com.google.firestore.v1.BatchWriteRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getBatchWriteMethod(), getCallOptions()), request); } @@ -1685,7 +1696,7 @@ public com.google.common.util.concurrent.ListenableFuture createDocument(com.google.firestore.v1.CreateDocumentRequest request) { - return futureUnaryCall( + return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getCreateDocumentMethod(), getCallOptions()), request); } } diff --git a/pom.xml b/pom.xml index 9ca255f9b..e4040226d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-firestore-parent pom - 2.3.0 + 2.4.0 Google Cloud Firestore Parent https://github.com/googleapis/java-firestore @@ -159,33 +159,33 @@ com.google.api.grpc proto-google-cloud-firestore-admin-v1 - 2.3.0 + 2.4.0 com.google.cloud proto-google-cloud-firestore-bundle-v1 - 2.3.0 + 2.4.0 com.google.api.grpc proto-google-cloud-firestore-v1 - 2.3.0 + 2.4.0 com.google.api.grpc grpc-google-cloud-firestore-admin-v1 - 2.3.0 + 2.4.0 com.google.api.grpc grpc-google-cloud-firestore-v1 - 2.3.0 + 2.4.0 com.google.cloud google-cloud-shared-dependencies - 1.0.0 + 1.1.0 pom import diff --git a/proto-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml b/proto-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml index 28ed47355..dcf66f723 100644 --- a/proto-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml +++ b/proto-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml @@ -17,75 +17,19 @@ - - - - 7002 - com/google/firestore/admin/v1/FieldName - java.lang.String getCollectionId() - - - 7002 - com/google/firestore/admin/v1/FieldName - java.lang.String getFieldId() - - - - 7002 - com/google/firestore/admin/v1/FieldName$Builder - java.lang.String getCollectionId() - - - 7002 - com/google/firestore/admin/v1/FieldName$Builder - java.lang.String getFieldId() - - - 7002 - com/google/firestore/admin/v1/FieldName$Builder - com.google.firestore.admin.v1.FieldName$Builder setCollectionId(java.lang.String) - - 7002 - com/google/firestore/admin/v1/FieldName$Builder - com.google.firestore.admin.v1.FieldName$Builder setFieldId(java.lang.String) + 7012 + com/google/firestore/admin/v1/*OrBuilder + * get*(*) - - - 7002 - com/google/firestore/admin/v1/IndexName - java.lang.String getCollectionId() - - - 7002 - com/google/firestore/admin/v1/IndexName - java.lang.String getIndexId() - - - 7002 - com/google/firestore/admin/v1/IndexName$Builder - java.lang.String getCollectionId() + 7012 + com/google/firestore/admin/v1/*OrBuilder + boolean contains*(*) - 7002 - com/google/firestore/admin/v1/IndexName$Builder - java.lang.String getIndexId() + 7012 + com/google/firestore/admin/v1/*OrBuilder + boolean has*(*) - - 7002 - com/google/firestore/admin/v1/IndexName$Builder - com.google.firestore.admin.v1.IndexName$Builder setCollectionId(java.lang.String) - - - 7002 - com/google/firestore/admin/v1/IndexName$Builder - com.google.firestore.admin.v1.IndexName$Builder setIndexId(java.lang.String) - - - diff --git a/proto-google-cloud-firestore-admin-v1/pom.xml b/proto-google-cloud-firestore-admin-v1/pom.xml index 1066c057e..b8f8af565 100644 --- a/proto-google-cloud-firestore-admin-v1/pom.xml +++ b/proto-google-cloud-firestore-admin-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-firestore-admin-v1 - 2.3.0 + 2.4.0 proto-google-cloud-firestore-admin-v1 PROTO library for proto-google-cloud-firestore-admin-v1 com.google.cloud google-cloud-firestore-parent - 2.3.0 + 2.4.0 diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java index 28c6212c4..220aa164a 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java @@ -1,11 +1,11 @@ /* - * Copyright 2019 Google LLC + * Copyright 2021 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 + * 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, @@ -23,21 +23,33 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class CollectionGroupName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_DATABASE_COLLECTION = PathTemplate.createWithoutUrlEncoding( "projects/{project}/databases/{database}/collectionGroups/{collection}"); - private volatile Map fieldValuesMap; - private final String project; private final String database; private final String collection; + @Deprecated + protected CollectionGroupName() { + project = null; + database = null; + collection = null; + } + + private CollectionGroupName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + collection = Preconditions.checkNotNull(builder.getCollection()); + } + public String getProject() { return project; } @@ -58,12 +70,6 @@ public Builder toBuilder() { return new Builder(this); } - private CollectionGroupName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - database = Preconditions.checkNotNull(builder.getDatabase()); - collection = Preconditions.checkNotNull(builder.getCollection()); - } - public static CollectionGroupName of(String project, String database, String collection) { return newBuilder().setProject(project).setDatabase(database).setCollection(collection).build(); } @@ -82,7 +88,7 @@ public static CollectionGroupName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_DATABASE_COLLECTION.validatedMatch( formattedString, "CollectionGroupName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("database"), matchMap.get("collection")); } @@ -96,7 +102,7 @@ public static List parseList(List formattedStrings) } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (CollectionGroupName value : values) { if (value == null) { list.add(""); @@ -108,17 +114,24 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_DATABASE_COLLECTION.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("database", database); - fieldMapBuilder.put("collection", collection); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (collection != null) { + fieldMapBuilder.put("collection", collection); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -132,17 +145,44 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_DATABASE_COLLECTION.instantiate( "project", project, "database", database, "collection", collection); } - /** Builder for CollectionGroupName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + CollectionGroupName that = ((CollectionGroupName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.database, that.database) + && Objects.equals(this.collection, that.collection); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(database); + h *= 1000003; + h ^= Objects.hashCode(collection); + return h; + } + + /** Builder for projects/{project}/databases/{database}/collectionGroups/{collection}. */ + public static class Builder { private String project; private String database; private String collection; + protected Builder() {} + public String getProject() { return project; } @@ -170,8 +210,6 @@ public Builder setCollection(String collection) { return this; } - private Builder() {} - private Builder(CollectionGroupName collectionGroupName) { project = collectionGroupName.project; database = collectionGroupName.database; @@ -182,30 +220,4 @@ public CollectionGroupName build() { return new CollectionGroupName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CollectionGroupName) { - CollectionGroupName that = (CollectionGroupName) o; - return (this.project.equals(that.project)) - && (this.database.equals(that.database)) - && (this.collection.equals(that.collection)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= database.hashCode(); - h *= 1000003; - h ^= collection.hashCode(); - return h; - } } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java index 92e12e038..b86af52e8 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java @@ -1,11 +1,11 @@ /* - * Copyright 2019 Google LLC + * Copyright 2021 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 + * 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, @@ -23,19 +23,29 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class DatabaseName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_DATABASE = PathTemplate.createWithoutUrlEncoding("projects/{project}/databases/{database}"); - private volatile Map fieldValuesMap; - private final String project; private final String database; + @Deprecated + protected DatabaseName() { + project = null; + database = null; + } + + private DatabaseName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + } + public String getProject() { return project; } @@ -52,11 +62,6 @@ public Builder toBuilder() { return new Builder(this); } - private DatabaseName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - database = Preconditions.checkNotNull(builder.getDatabase()); - } - public static DatabaseName of(String project, String database) { return newBuilder().setProject(project).setDatabase(database).build(); } @@ -70,7 +75,7 @@ public static DatabaseName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_DATABASE.validatedMatch( formattedString, "DatabaseName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("database")); } @@ -84,7 +89,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (DatabaseName value : values) { if (value == null) { list.add(""); @@ -96,16 +101,21 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_DATABASE.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("database", database); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -119,15 +129,39 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project, "database", database); + return PROJECT_DATABASE.instantiate("project", project, "database", database); } - /** Builder for DatabaseName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + DatabaseName that = ((DatabaseName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.database, that.database); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(database); + return h; + } + + /** Builder for projects/{project}/databases/{database}. */ + public static class Builder { private String project; private String database; + protected Builder() {} + public String getProject() { return project; } @@ -146,8 +180,6 @@ public Builder setDatabase(String database) { return this; } - private Builder() {} - private Builder(DatabaseName databaseName) { project = databaseName.project; database = databaseName.database; @@ -157,26 +189,4 @@ public DatabaseName build() { return new DatabaseName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof DatabaseName) { - DatabaseName that = (DatabaseName) o; - return (this.project.equals(that.project)) && (this.database.equals(that.database)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= database.hashCode(); - return h; - } } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java index 4bbe3d74f..1032bc5a3 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java @@ -1,11 +1,11 @@ /* - * Copyright 2019 Google LLC + * Copyright 2021 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 + * 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, @@ -23,22 +23,36 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class FieldName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_DATABASE_COLLECTION_FIELD = PathTemplate.createWithoutUrlEncoding( "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}"); - private volatile Map fieldValuesMap; - private final String project; private final String database; private final String collection; private final String field; + @Deprecated + protected FieldName() { + project = null; + database = null; + collection = null; + field = null; + } + + private FieldName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + collection = Preconditions.checkNotNull(builder.getCollection()); + field = Preconditions.checkNotNull(builder.getField()); + } + public String getProject() { return project; } @@ -63,13 +77,6 @@ public Builder toBuilder() { return new Builder(this); } - private FieldName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - database = Preconditions.checkNotNull(builder.getDatabase()); - collection = Preconditions.checkNotNull(builder.getCollection()); - field = Preconditions.checkNotNull(builder.getField()); - } - public static FieldName of(String project, String database, String collection, String field) { return newBuilder() .setProject(project) @@ -94,7 +101,7 @@ public static FieldName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_DATABASE_COLLECTION_FIELD.validatedMatch( formattedString, "FieldName.parse: formattedString not in valid format"); return of( matchMap.get("project"), @@ -112,7 +119,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (FieldName value : values) { if (value == null) { list.add(""); @@ -124,18 +131,27 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_DATABASE_COLLECTION_FIELD.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("database", database); - fieldMapBuilder.put("collection", collection); - fieldMapBuilder.put("field", field); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (collection != null) { + fieldMapBuilder.put("collection", collection); + } + if (field != null) { + fieldMapBuilder.put("field", field); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -149,18 +165,51 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_DATABASE_COLLECTION_FIELD.instantiate( "project", project, "database", database, "collection", collection, "field", field); } - /** Builder for FieldName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + FieldName that = ((FieldName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.database, that.database) + && Objects.equals(this.collection, that.collection) + && Objects.equals(this.field, that.field); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(database); + h *= 1000003; + h ^= Objects.hashCode(collection); + h *= 1000003; + h ^= Objects.hashCode(field); + return h; + } + + /** + * Builder for + * projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}. + */ + public static class Builder { private String project; private String database; private String collection; private String field; + protected Builder() {} + public String getProject() { return project; } @@ -197,8 +246,6 @@ public Builder setField(String field) { return this; } - private Builder() {} - private Builder(FieldName fieldName) { project = fieldName.project; database = fieldName.database; @@ -210,33 +257,4 @@ public FieldName build() { return new FieldName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FieldName) { - FieldName that = (FieldName) o; - return (this.project.equals(that.project)) - && (this.database.equals(that.database)) - && (this.collection.equals(that.collection)) - && (this.field.equals(that.field)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= database.hashCode(); - h *= 1000003; - h ^= collection.hashCode(); - h *= 1000003; - h ^= field.hashCode(); - return h; - } } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java index 52c959b16..356b5a826 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java @@ -550,6 +550,19 @@ public interface IndexFieldOrBuilder */ com.google.protobuf.ByteString getFieldPathBytes(); + /** + * + * + *
+     * Indicates that this field supports ordering by the specified order or
+     * comparing using =, <, <=, >, >=.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return Whether the order field is set. + */ + boolean hasOrder(); /** * * @@ -577,6 +590,18 @@ public interface IndexFieldOrBuilder */ com.google.firestore.admin.v1.Index.IndexField.Order getOrder(); + /** + * + * + *
+     * Indicates that this field supports operations on `array_value`s.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return Whether the arrayConfig field is set. + */ + boolean hasArrayConfig(); /** * * @@ -1106,6 +1131,21 @@ public com.google.protobuf.ByteString getFieldPathBytes() { } public static final int ORDER_FIELD_NUMBER = 2; + /** + * + * + *
+     * Indicates that this field supports ordering by the specified order or
+     * comparing using =, <, <=, >, >=.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return Whether the order field is set. + */ + public boolean hasOrder() { + return valueModeCase_ == 2; + } /** * * @@ -1150,6 +1190,20 @@ public com.google.firestore.admin.v1.Index.IndexField.Order getOrder() { } public static final int ARRAY_CONFIG_FIELD_NUMBER = 3; + /** + * + * + *
+     * Indicates that this field supports operations on `array_value`s.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return Whether the arrayConfig field is set. + */ + public boolean hasArrayConfig() { + return valueModeCase_ == 3; + } /** * * @@ -1708,6 +1762,22 @@ public Builder setFieldPathBytes(com.google.protobuf.ByteString value) { return this; } + /** + * + * + *
+       * Indicates that this field supports ordering by the specified order or
+       * comparing using =, <, <=, >, >=.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return Whether the order field is set. + */ + @java.lang.Override + public boolean hasOrder() { + return valueModeCase_ == 2; + } /** * * @@ -1814,6 +1884,21 @@ public Builder clearOrder() { return this; } + /** + * + * + *
+       * Indicates that this field supports operations on `array_value`s.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return Whether the arrayConfig field is set. + */ + @java.lang.Override + public boolean hasArrayConfig() { + return valueModeCase_ == 3; + } /** * * diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java index ea2bdc363..b21ffaecf 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java @@ -1,11 +1,11 @@ /* - * Copyright 2019 Google LLC + * Copyright 2021 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 + * 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, @@ -23,22 +23,36 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class IndexName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_DATABASE_COLLECTION_INDEX = PathTemplate.createWithoutUrlEncoding( "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}"); - private volatile Map fieldValuesMap; - private final String project; private final String database; private final String collection; private final String index; + @Deprecated + protected IndexName() { + project = null; + database = null; + collection = null; + index = null; + } + + private IndexName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + collection = Preconditions.checkNotNull(builder.getCollection()); + index = Preconditions.checkNotNull(builder.getIndex()); + } + public String getProject() { return project; } @@ -63,13 +77,6 @@ public Builder toBuilder() { return new Builder(this); } - private IndexName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - database = Preconditions.checkNotNull(builder.getDatabase()); - collection = Preconditions.checkNotNull(builder.getCollection()); - index = Preconditions.checkNotNull(builder.getIndex()); - } - public static IndexName of(String project, String database, String collection, String index) { return newBuilder() .setProject(project) @@ -94,7 +101,7 @@ public static IndexName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_DATABASE_COLLECTION_INDEX.validatedMatch( formattedString, "IndexName.parse: formattedString not in valid format"); return of( matchMap.get("project"), @@ -112,7 +119,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (IndexName value : values) { if (value == null) { list.add(""); @@ -124,18 +131,27 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_DATABASE_COLLECTION_INDEX.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("database", database); - fieldMapBuilder.put("collection", collection); - fieldMapBuilder.put("index", index); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (collection != null) { + fieldMapBuilder.put("collection", collection); + } + if (index != null) { + fieldMapBuilder.put("index", index); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -149,18 +165,51 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_DATABASE_COLLECTION_INDEX.instantiate( "project", project, "database", database, "collection", collection, "index", index); } - /** Builder for IndexName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + IndexName that = ((IndexName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.database, that.database) + && Objects.equals(this.collection, that.collection) + && Objects.equals(this.index, that.index); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(database); + h *= 1000003; + h ^= Objects.hashCode(collection); + h *= 1000003; + h ^= Objects.hashCode(index); + return h; + } + + /** + * Builder for + * projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}. + */ + public static class Builder { private String project; private String database; private String collection; private String index; + protected Builder() {} + public String getProject() { return project; } @@ -197,8 +246,6 @@ public Builder setIndex(String index) { return this; } - private Builder() {} - private Builder(IndexName indexName) { project = indexName.project; database = indexName.database; @@ -210,33 +257,4 @@ public IndexName build() { return new IndexName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof IndexName) { - IndexName that = (IndexName) o; - return (this.project.equals(that.project)) - && (this.database.equals(that.database)) - && (this.collection.equals(that.collection)) - && (this.index.equals(that.index)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= database.hashCode(); - h *= 1000003; - h ^= collection.hashCode(); - h *= 1000003; - h ^= index.hashCode(); - return h; - } } diff --git a/proto-google-cloud-firestore-bundle-v1/pom.xml b/proto-google-cloud-firestore-bundle-v1/pom.xml index 6a7f7aa92..c82e134c4 100644 --- a/proto-google-cloud-firestore-bundle-v1/pom.xml +++ b/proto-google-cloud-firestore-bundle-v1/pom.xml @@ -5,14 +5,14 @@ 4.0.0 proto-google-cloud-firestore-bundle-v1 - 2.3.0 + 2.4.0 proto-google-cloud-firestore-bundle-v1 PROTO library for proto-google-cloud-firestore-bundle-v1 com.google.cloud google-cloud-firestore-parent - 2.3.0 + 2.4.0 diff --git a/proto-google-cloud-firestore-v1/pom.xml b/proto-google-cloud-firestore-v1/pom.xml index d43559aec..41d329159 100644 --- a/proto-google-cloud-firestore-v1/pom.xml +++ b/proto-google-cloud-firestore-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-firestore-v1 - 2.3.0 + 2.4.0 proto-google-cloud-firestore-v1 PROTO library for proto-google-cloud-firestore-v1 com.google.cloud google-cloud-firestore-parent - 2.3.0 + 2.4.0 diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequest.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequest.java index 4ec3371db..6f24813ba 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequest.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequest.java @@ -408,6 +408,21 @@ public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { } public static final int TRANSACTION_FIELD_NUMBER = 4; + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 4; + } /** * * @@ -1536,6 +1551,20 @@ public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { return maskBuilder_; } + /** + * + * + *
+     * Reads documents in a transaction.
+     * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 4; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequestOrBuilder.java index 8257d80c6..bc5719fbf 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequestOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequestOrBuilder.java @@ -154,6 +154,18 @@ public interface BatchGetDocumentsRequestOrBuilder */ com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponse.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponse.java index d6cbff668..b07c68ace 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponse.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponse.java @@ -245,6 +245,21 @@ public com.google.firestore.v1.DocumentOrBuilder getFoundOrBuilder() { } public static final int MISSING_FIELD_NUMBER = 2; + /** + * + * + *
+   * A document name that was requested but does not exist. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string missing = 2; + * + * @return Whether the missing field is set. + */ + public boolean hasMissing() { + return resultCase_ == 2; + } /** * * @@ -1009,6 +1024,22 @@ public com.google.firestore.v1.DocumentOrBuilder getFoundOrBuilder() { return foundBuilder_; } + /** + * + * + *
+     * A document name that was requested but does not exist. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string missing = 2; + * + * @return Whether the missing field is set. + */ + @java.lang.Override + public boolean hasMissing() { + return resultCase_ == 2; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponseOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponseOrBuilder.java index 0321f75fe..b6681d83b 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponseOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponseOrBuilder.java @@ -58,6 +58,19 @@ public interface BatchGetDocumentsResponseOrBuilder */ com.google.firestore.v1.DocumentOrBuilder getFoundOrBuilder(); + /** + * + * + *
+   * A document name that was requested but does not exist. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string missing = 2; + * + * @return Whether the missing field is set. + */ + boolean hasMissing(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransform.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransform.java index f44df3dbe..8c93fcfeb 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransform.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransform.java @@ -162,6 +162,20 @@ public interface FieldTransformOrBuilder */ com.google.protobuf.ByteString getFieldPathBytes(); + /** + * + * + *
+     * Sets the field to the given server value.
+     * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return Whether the setToServerValue field is set. + */ + boolean hasSetToServerValue(); /** * * @@ -703,7 +717,8 @@ public enum ServerValue implements com.google.protobuf.ProtocolMessageEnum { * *
        * The time at which the server processed the request, with millisecond
-       * precision.
+       * precision. If used on multiple fields (same or different documents) in
+       * a transaction, all the fields will get the same server timestamp.
        * 
* * REQUEST_TIME = 1; @@ -727,7 +742,8 @@ public enum ServerValue implements com.google.protobuf.ProtocolMessageEnum { * *
        * The time at which the server processed the request, with millisecond
-       * precision.
+       * precision. If used on multiple fields (same or different documents) in
+       * a transaction, all the fields will get the same server timestamp.
        * 
* * REQUEST_TIME = 1; @@ -928,6 +944,22 @@ public com.google.protobuf.ByteString getFieldPathBytes() { } public static final int SET_TO_SERVER_VALUE_FIELD_NUMBER = 2; + /** + * + * + *
+     * Sets the field to the given server value.
+     * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return Whether the setToServerValue field is set. + */ + public boolean hasSetToServerValue() { + return transformTypeCase_ == 2; + } /** * * @@ -1986,6 +2018,23 @@ public Builder setFieldPathBytes(com.google.protobuf.ByteString value) { return this; } + /** + * + * + *
+       * Sets the field to the given server value.
+       * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return Whether the setToServerValue field is set. + */ + @java.lang.Override + public boolean hasSetToServerValue() { + return transformTypeCase_ == 2; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequest.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequest.java index 995ff53c1..8e0c52af5 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequest.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequest.java @@ -299,6 +299,21 @@ public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { } public static final int TRANSACTION_FIELD_NUMBER = 3; + /** + * + * + *
+   * Reads the document in a transaction.
+   * 
+ * + * bytes transaction = 3; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 3; + } /** * * @@ -1108,6 +1123,20 @@ public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { return maskBuilder_; } + /** + * + * + *
+     * Reads the document in a transaction.
+     * 
+ * + * bytes transaction = 3; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 3; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequestOrBuilder.java index 3fd4be1a7..d13a4f89f 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequestOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequestOrBuilder.java @@ -91,6 +91,18 @@ public interface GetDocumentRequestOrBuilder */ com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); + /** + * + * + *
+   * Reads the document in a transaction.
+   * 
+ * + * bytes transaction = 3; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequest.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequest.java index 7d45c0d11..ca5510dad 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequest.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequest.java @@ -508,6 +508,21 @@ public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { } public static final int TRANSACTION_FIELD_NUMBER = 8; + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 8; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 8; + } /** * * @@ -1813,6 +1828,20 @@ public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { return maskBuilder_; } + /** + * + * + *
+     * Reads documents in a transaction.
+     * 
+ * + * bytes transaction = 8; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 8; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequestOrBuilder.java index 7ff66b64b..3c6a5b4de 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequestOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequestOrBuilder.java @@ -189,6 +189,18 @@ public interface ListDocumentsRequestOrBuilder */ com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 8; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequest.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequest.java index 80238b7b1..f56568f71 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequest.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequest.java @@ -307,6 +307,21 @@ public com.google.firestore.v1.TargetOrBuilder getAddTargetOrBuilder() { } public static final int REMOVE_TARGET_FIELD_NUMBER = 3; + /** + * + * + *
+   * The ID of a target to remove from this stream.
+   * 
+ * + * int32 remove_target = 3; + * + * @return Whether the removeTarget field is set. + */ + @java.lang.Override + public boolean hasRemoveTarget() { + return targetChangeCase_ == 3; + } /** * * @@ -1181,6 +1196,20 @@ public com.google.firestore.v1.TargetOrBuilder getAddTargetOrBuilder() { return addTargetBuilder_; } + /** + * + * + *
+     * The ID of a target to remove from this stream.
+     * 
+ * + * int32 remove_target = 3; + * + * @return Whether the removeTarget field is set. + */ + public boolean hasRemoveTarget() { + return targetChangeCase_ == 3; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequestOrBuilder.java index 064c3272f..b08f090f5 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequestOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequestOrBuilder.java @@ -85,6 +85,18 @@ public interface ListenRequestOrBuilder */ com.google.firestore.v1.TargetOrBuilder getAddTargetOrBuilder(); + /** + * + * + *
+   * The ID of a target to remove from this stream.
+   * 
+ * + * int32 remove_target = 3; + * + * @return Whether the removeTarget field is set. + */ + boolean hasRemoveTarget(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Precondition.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Precondition.java index ec3d8ebc5..b2c6f499d 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Precondition.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Precondition.java @@ -171,6 +171,22 @@ public ConditionTypeCase getConditionTypeCase() { } public static final int EXISTS_FIELD_NUMBER = 1; + /** + * + * + *
+   * When set to `true`, the target document must exist.
+   * When set to `false`, the target document must not exist.
+   * 
+ * + * bool exists = 1; + * + * @return Whether the exists field is set. + */ + @java.lang.Override + public boolean hasExists() { + return conditionTypeCase_ == 1; + } /** * * @@ -624,6 +640,21 @@ public Builder clearConditionType() { return this; } + /** + * + * + *
+     * When set to `true`, the target document must exist.
+     * When set to `false`, the target document must not exist.
+     * 
+ * + * bool exists = 1; + * + * @return Whether the exists field is set. + */ + public boolean hasExists() { + return conditionTypeCase_ == 1; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PreconditionOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PreconditionOrBuilder.java index a1bc84ff9..f5811a9ed 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PreconditionOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PreconditionOrBuilder.java @@ -23,6 +23,19 @@ public interface PreconditionOrBuilder // @@protoc_insertion_point(interface_extends:google.firestore.v1.Precondition) com.google.protobuf.MessageOrBuilder { + /** + * + * + *
+   * When set to `true`, the target document must exist.
+   * When set to `false`, the target document must not exist.
+   * 
+ * + * bool exists = 1; + * + * @return Whether the exists field is set. + */ + boolean hasExists(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequest.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequest.java index 1372dddf5..99bb6db17 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequest.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequest.java @@ -371,6 +371,21 @@ public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuil } public static final int TRANSACTION_FIELD_NUMBER = 5; + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } /** * * @@ -1327,6 +1342,20 @@ public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuil return structuredQueryBuilder_; } + /** + * + * + *
+     * Reads documents in a transaction.
+     * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequestOrBuilder.java index c34cb4767..b7b5ec424 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequestOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequestOrBuilder.java @@ -93,6 +93,18 @@ public interface RunQueryRequestOrBuilder */ com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder(); + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Target.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Target.java index 6b2ce715b..bce15cf4f 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Target.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Target.java @@ -2302,6 +2302,22 @@ public com.google.firestore.v1.Target.DocumentsTargetOrBuilder getDocumentsOrBui } public static final int RESUME_TOKEN_FIELD_NUMBER = 4; + /** + * + * + *
+   * A resume token from a prior [TargetChange][google.firestore.v1.TargetChange] for an identical target.
+   * Using a resume token with a different target is unsupported and may fail.
+   * 
+ * + * bytes resume_token = 4; + * + * @return Whether the resumeToken field is set. + */ + @java.lang.Override + public boolean hasResumeToken() { + return resumeTypeCase_ == 4; + } /** * * @@ -3324,6 +3340,21 @@ public com.google.firestore.v1.Target.DocumentsTargetOrBuilder getDocumentsOrBui return documentsBuilder_; } + /** + * + * + *
+     * A resume token from a prior [TargetChange][google.firestore.v1.TargetChange] for an identical target.
+     * Using a resume token with a different target is unsupported and may fail.
+     * 
+ * + * bytes resume_token = 4; + * + * @return Whether the resumeToken field is set. + */ + public boolean hasResumeToken() { + return resumeTypeCase_ == 4; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetOrBuilder.java index 99b1d4fc0..97f709936 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetOrBuilder.java @@ -93,6 +93,19 @@ public interface TargetOrBuilder */ com.google.firestore.v1.Target.DocumentsTargetOrBuilder getDocumentsOrBuilder(); + /** + * + * + *
+   * A resume token from a prior [TargetChange][google.firestore.v1.TargetChange] for an identical target.
+   * Using a resume token with a different target is unsupported and may fail.
+   * 
+ * + * bytes resume_token = 4; + * + * @return Whether the resumeToken field is set. + */ + boolean hasResumeToken(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java index 5965bdf11..4743283b3 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java @@ -280,6 +280,20 @@ public ValueTypeCase getValueTypeCase() { } public static final int NULL_VALUE_FIELD_NUMBER = 11; + /** + * + * + *
+   * A null value.
+   * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return Whether the nullValue field is set. + */ + public boolean hasNullValue() { + return valueTypeCase_ == 11; + } /** * * @@ -319,6 +333,21 @@ public com.google.protobuf.NullValue getNullValue() { } public static final int BOOLEAN_VALUE_FIELD_NUMBER = 1; + /** + * + * + *
+   * A boolean value.
+   * 
+ * + * bool boolean_value = 1; + * + * @return Whether the booleanValue field is set. + */ + @java.lang.Override + public boolean hasBooleanValue() { + return valueTypeCase_ == 1; + } /** * * @@ -339,6 +368,21 @@ public boolean getBooleanValue() { } public static final int INTEGER_VALUE_FIELD_NUMBER = 2; + /** + * + * + *
+   * An integer value.
+   * 
+ * + * int64 integer_value = 2; + * + * @return Whether the integerValue field is set. + */ + @java.lang.Override + public boolean hasIntegerValue() { + return valueTypeCase_ == 2; + } /** * * @@ -359,6 +403,21 @@ public long getIntegerValue() { } public static final int DOUBLE_VALUE_FIELD_NUMBER = 3; + /** + * + * + *
+   * A double value.
+   * 
+ * + * double double_value = 3; + * + * @return Whether the doubleValue field is set. + */ + @java.lang.Override + public boolean hasDoubleValue() { + return valueTypeCase_ == 3; + } /** * * @@ -436,6 +495,23 @@ public com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder() { } public static final int STRING_VALUE_FIELD_NUMBER = 17; + /** + * + * + *
+   * A string value.
+   * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
+   * Only the first 1,500 bytes of the UTF-8 representation are considered by
+   * queries.
+   * 
+ * + * string string_value = 17; + * + * @return Whether the stringValue field is set. + */ + public boolean hasStringValue() { + return valueTypeCase_ == 17; + } /** * * @@ -498,6 +574,23 @@ public com.google.protobuf.ByteString getStringValueBytes() { } public static final int BYTES_VALUE_FIELD_NUMBER = 18; + /** + * + * + *
+   * A bytes value.
+   * Must not exceed 1 MiB - 89 bytes.
+   * Only the first 1,500 bytes are considered by queries.
+   * 
+ * + * bytes bytes_value = 18; + * + * @return Whether the bytesValue field is set. + */ + @java.lang.Override + public boolean hasBytesValue() { + return valueTypeCase_ == 18; + } /** * * @@ -520,6 +613,21 @@ public com.google.protobuf.ByteString getBytesValue() { } public static final int REFERENCE_VALUE_FIELD_NUMBER = 5; + /** + * + * + *
+   * A reference to a document. For example:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string reference_value = 5; + * + * @return Whether the referenceValue field is set. + */ + public boolean hasReferenceValue() { + return valueTypeCase_ == 5; + } /** * * @@ -1337,6 +1445,21 @@ public Builder clearValueType() { return this; } + /** + * + * + *
+     * A null value.
+     * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return Whether the nullValue field is set. + */ + @java.lang.Override + public boolean hasNullValue() { + return valueTypeCase_ == 11; + } /** * * @@ -1435,6 +1558,20 @@ public Builder clearNullValue() { return this; } + /** + * + * + *
+     * A boolean value.
+     * 
+ * + * bool boolean_value = 1; + * + * @return Whether the booleanValue field is set. + */ + public boolean hasBooleanValue() { + return valueTypeCase_ == 1; + } /** * * @@ -1490,6 +1627,20 @@ public Builder clearBooleanValue() { return this; } + /** + * + * + *
+     * An integer value.
+     * 
+ * + * int64 integer_value = 2; + * + * @return Whether the integerValue field is set. + */ + public boolean hasIntegerValue() { + return valueTypeCase_ == 2; + } /** * * @@ -1545,6 +1696,20 @@ public Builder clearIntegerValue() { return this; } + /** + * + * + *
+     * A double value.
+     * 
+ * + * double double_value = 3; + * + * @return Whether the doubleValue field is set. + */ + public boolean hasDoubleValue() { + return valueTypeCase_ == 3; + } /** * * @@ -1823,6 +1988,24 @@ public com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder() { return timestampValueBuilder_; } + /** + * + * + *
+     * A string value.
+     * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
+     * Only the first 1,500 bytes of the UTF-8 representation are considered by
+     * queries.
+     * 
+ * + * string string_value = 17; + * + * @return Whether the stringValue field is set. + */ + @java.lang.Override + public boolean hasStringValue() { + return valueTypeCase_ == 17; + } /** * * @@ -1957,6 +2140,22 @@ public Builder setStringValueBytes(com.google.protobuf.ByteString value) { return this; } + /** + * + * + *
+     * A bytes value.
+     * Must not exceed 1 MiB - 89 bytes.
+     * Only the first 1,500 bytes are considered by queries.
+     * 
+ * + * bytes bytes_value = 18; + * + * @return Whether the bytesValue field is set. + */ + public boolean hasBytesValue() { + return valueTypeCase_ == 18; + } /** * * @@ -2021,6 +2220,22 @@ public Builder clearBytesValue() { return this; } + /** + * + * + *
+     * A reference to a document. For example:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string reference_value = 5; + * + * @return Whether the referenceValue field is set. + */ + @java.lang.Override + public boolean hasReferenceValue() { + return valueTypeCase_ == 5; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java index 7f46b4315..a409d5918 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java @@ -23,6 +23,18 @@ public interface ValueOrBuilder // @@protoc_insertion_point(interface_extends:google.firestore.v1.Value) com.google.protobuf.MessageOrBuilder { + /** + * + * + *
+   * A null value.
+   * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return Whether the nullValue field is set. + */ + boolean hasNullValue(); /** * * @@ -48,6 +60,18 @@ public interface ValueOrBuilder */ com.google.protobuf.NullValue getNullValue(); + /** + * + * + *
+   * A boolean value.
+   * 
+ * + * bool boolean_value = 1; + * + * @return Whether the booleanValue field is set. + */ + boolean hasBooleanValue(); /** * * @@ -61,6 +85,18 @@ public interface ValueOrBuilder */ boolean getBooleanValue(); + /** + * + * + *
+   * An integer value.
+   * 
+ * + * int64 integer_value = 2; + * + * @return Whether the integerValue field is set. + */ + boolean hasIntegerValue(); /** * * @@ -74,6 +110,18 @@ public interface ValueOrBuilder */ long getIntegerValue(); + /** + * + * + *
+   * A double value.
+   * 
+ * + * double double_value = 3; + * + * @return Whether the doubleValue field is set. + */ + boolean hasDoubleValue(); /** * * @@ -128,6 +176,21 @@ public interface ValueOrBuilder */ com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder(); + /** + * + * + *
+   * A string value.
+   * The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes.
+   * Only the first 1,500 bytes of the UTF-8 representation are considered by
+   * queries.
+   * 
+ * + * string string_value = 17; + * + * @return Whether the stringValue field is set. + */ + boolean hasStringValue(); /** * * @@ -159,6 +222,20 @@ public interface ValueOrBuilder */ com.google.protobuf.ByteString getStringValueBytes(); + /** + * + * + *
+   * A bytes value.
+   * Must not exceed 1 MiB - 89 bytes.
+   * Only the first 1,500 bytes are considered by queries.
+   * 
+ * + * bytes bytes_value = 18; + * + * @return Whether the bytesValue field is set. + */ + boolean hasBytesValue(); /** * * @@ -174,6 +251,19 @@ public interface ValueOrBuilder */ com.google.protobuf.ByteString getBytesValue(); + /** + * + * + *
+   * A reference to a document. For example:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string reference_value = 5; + * + * @return Whether the referenceValue field is set. + */ + boolean hasReferenceValue(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Write.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Write.java index 9c59027a4..702d87b78 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Write.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Write.java @@ -292,6 +292,21 @@ public com.google.firestore.v1.DocumentOrBuilder getUpdateOrBuilder() { } public static final int DELETE_FIELD_NUMBER = 2; + /** + * + * + *
+   * A document name to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string delete = 2; + * + * @return Whether the delete field is set. + */ + public boolean hasDelete() { + return operationCase_ == 2; + } /** * * @@ -1340,6 +1355,22 @@ public com.google.firestore.v1.DocumentOrBuilder getUpdateOrBuilder() { return updateBuilder_; } + /** + * + * + *
+     * A document name to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string delete = 2; + * + * @return Whether the delete field is set. + */ + @java.lang.Override + public boolean hasDelete() { + return operationCase_ == 2; + } /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteOrBuilder.java index 330fc6b49..01a830bc4 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteOrBuilder.java @@ -58,6 +58,19 @@ public interface WriteOrBuilder */ com.google.firestore.v1.DocumentOrBuilder getUpdateOrBuilder(); + /** + * + * + *
+   * A document name to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string delete = 2; + * + * @return Whether the delete field is set. + */ + boolean hasDelete(); /** * * diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/common.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/common.proto index 4367f168d..3bc978ca9 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/common.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/common.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto index 148d2bddd..5238a943c 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto index e035d1b4e..b149a7634 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto index eea1d1178..304499847 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/write.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/write.proto index a6befb0e6..c78437bab 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/write.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/write.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -80,7 +80,8 @@ message DocumentTransform { SERVER_VALUE_UNSPECIFIED = 0; // The time at which the server processed the request, with millisecond - // precision. + // precision. If used on multiple fields (same or different documents) in + // a transaction, all the fields will get the same server timestamp. REQUEST_TIME = 1; } diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 710f7de0b..06bcab727 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-firestore - 2.2.6 + 2.3.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 93b4011b4..c9490eea6 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-firestore - 2.2.6 + 2.3.0 diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 1a9b62966..248d97149 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -33,7 +33,7 @@ com.google.cloud libraries-bom - 20.1.0 + 20.4.0 pom import diff --git a/synth.metadata b/synth.metadata index c437ef940..9a098091b 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,22 +4,22 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-firestore.git", - "sha": "998dcd4958c2632d673fc637139cbd12250ef7bc" + "sha": "43b949fd5483fd8f79557d82032fa4ff629478c8" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "9c00a2f0dc8cc1c8d93b938fc097851335c08692", - "internalRef": "335923930" + "sha": "299383230f69e9f2272adda8e0d93c4fdf231deb", + "internalRef": "367054341" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "8285c2b4cdbc3771d031ad91e1c4ec9e55fff45d" + "sha": "4f4b1b9b8d8b52f1e9e4a76165896debce5ab7f1" } } ], @@ -118,6 +118,7 @@ "codecov.yaml", "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java", "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java", + "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json", "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java", "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java", "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java", @@ -128,6 +129,7 @@ "google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java", "google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java", "google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java", + "google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json", "google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java", "google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java", "google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java", diff --git a/versions.txt b/versions.txt index 7721f1e43..33ee63baf 100644 --- a/versions.txt +++ b/versions.txt @@ -1,11 +1,11 @@ # Format: # module:released-version:current-version -google-cloud-firestore:2.3.0:2.3.0 -google-cloud-firestore-admin:2.3.0:2.3.0 -google-cloud-firestore-bom:2.3.0:2.3.0 -google-cloud-firestore-parent:2.3.0:2.3.0 -grpc-google-cloud-firestore-admin-v1:2.3.0:2.3.0 -grpc-google-cloud-firestore-v1:2.3.0:2.3.0 -proto-google-cloud-firestore-admin-v1:2.3.0:2.3.0 -proto-google-cloud-firestore-v1:2.3.0:2.3.0 +google-cloud-firestore:2.4.0:2.4.0 +google-cloud-firestore-admin:2.4.0:2.4.0 +google-cloud-firestore-bom:2.4.0:2.4.0 +google-cloud-firestore-parent:2.4.0:2.4.0 +grpc-google-cloud-firestore-admin-v1:2.4.0:2.4.0 +grpc-google-cloud-firestore-v1:2.4.0:2.4.0 +proto-google-cloud-firestore-admin-v1:2.4.0:2.4.0 +proto-google-cloud-firestore-v1:2.4.0:2.4.0